Skip to content

feat: domain-design + contract-design restructure; infra-design conso… - #711

Open
SiddhJog wants to merge 1 commit into
v2from
feature/design-output-restructure
Open

feat: domain-design + contract-design restructure; infra-design conso…#711
SiddhJog wants to merge 1 commit into
v2from
feature/design-output-restructure

Conversation

@SiddhJog

@SiddhJog SiddhJog commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Restructures the Inception design outputs and consolidates Infrastructure Design, rebased onto current v2 (2.5.36) as a single commit. Ships as v2.6.1.

Domain / Contract design

  • application-designdomain-design (2.6): the five artifacts (components, component-methods, services, component-dependency, decisions) collapse into a single consolidated components.md — a fenced ```yaml component catalogue (source of truth: behaviour, responsibilities, depends_on/dependents, external_dependencies, owned entities with identifier + cross-component references) plus a derived human view (mermaid + summary/ownership/rationale tables).
  • NEW contract-design stage (2.8, CONDITIONAL — skips single-unit systems): formalises inter-unit contracts so teams build in parallel; produces contract-summary. Delivery Planning → 2.9.
  • functional-design outputs → entities / rules / functional-spec (yaml sources of truth + derived human view).
  • aidlc-architect-agent reframed to own the logical/application concerns (domain + contract design), distinct from infrastructure.

Infrastructure design consolidation

  • infrastructure-design five artifacts → three: deployment-architecture + infrastructure-services + shared-infrastructure fold into a tabular infrastructure-specification.md; monitoring-design and cicd-pipeline stay dedicated (Operation stages consume them independently). Closer to the pre-v2 single-infra-doc shape.

Numbering

Uses v2's engine-driven numbering (no authored number: frontmatter): the rename is carried by the stage-graph.json pin (domain-design@2.6), contract-design and the renumbered delivery-planning@2.9 ride the pins, and v2's numeric topo-tiebreak keeps ordering consistent.

Breaking changes

Consumers that read Inception design or infrastructure artifacts must migrate: the five app-design names, three functional-design names, and deployment-architecture/infrastructure-services/shared-infrastructure are gone. Read components.md, contract-summary.md, entities.md/rules.md/functional-spec.md, and infrastructure-specification.md instead. See CHANGELOG 2.6.0/2.6.1.

Counts

  • Stages 32 → 33 (new contract-design); artifact registry → 117.

Review

Two /code-review --effort high rounds addressed (12 findings). During the v2 rebase, four v2-owned surfaces were reconciled with the rename: the ars-priors.json composer data, the 05-scopes-and-depth.md stage-by-scope matrix, and two auto-merged test helpers.

Testing

  • bun scripts/package.ts --check clean across all 5 harness trees.
  • Smoke + unit + affected integration tiers green.
  • Two failures remain and are pre-existing/environmentalt248-codekb-scope-diff and t255-workspace-sync, both v2-owned git/LFS/worktree integration tests with zero overlap with this change (verified: our diff touches neither subject, and neither test references any renamed stage/artifact).

@leandrodamascena leandrodamascena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the substantial design and artifact-model improvements. The focused suites and package parity pass, but I found four behavioral/documentation gaps plus the current merge conflict.

1. P1: upgrading can strand in-flight workflows

The latest 2.6.1 entry tells users to re-copy the shell, but the graph removes application-design without an alias or state migration. A workflow whose Current Stage is still application-design reaches emitRunStageForSlug() and fails because that slug no longer exists.

References: CHANGELOG.md:6, core/tools/aidlc-orchestrate.ts:2525-2559, :2785-2790.

Please migrate/alias persisted state, or make the latest upgrade instructions explicitly prevent shell replacement while an old-schema workflow is active.

2. P1: Code Generation does not receive contract-summary

Code Generation reads contract-summary.md in its stage prose, but does not declare contract-summary in consumes. Consequently it is absent from the resolved directive and from the architecture reviewer’s permitted shared-contract context.

Reproduction:

$ bun dist/claude/.claude/tools/aidlc-graph.ts consumers contract-summary
functional-design

References: core/aidlc-common/stages/construction/code-generation.md:16-32, :75; core/aidlc-common/protocols/stage-protocol.md:964; core/knowledge/aidlc-architecture-reviewer-agent/reviewing.md:27.

Please add contract-summary as an optional consume and add a directive-resolution test.

3. P2: Workshop always skips Contract Design

The workshop scope says it runs the full Inception design pass and executes Units Generation, but contract-design excludes workshop. A multi-unit workshop therefore cannot run the new stage even when its execution condition is satisfied.

References: core/aidlc-common/stages/inception/contract-design.md:28-31, core/scopes/aidlc-workshop.md:24-38, dist/claude/.claude/tools/data/scope-grid.json:315-318.

Please include workshop, or document and enforce the intended alternative contract source.

4. P2: current surfaces still advertise the removed graph

Several active and user-facing surfaces still describe 32 stages, Inception 2.1-2.8, and Application Design. This includes the Claude session announcement, scope descriptions, agent metadata, depth guidance, and Delivery Planning’s own numbering.

Representative references:

  • harness/claude/settings.json:3
  • core/scopes/aidlc-enterprise.md:28
  • core/scopes/aidlc-feature.md:27
  • core/aidlc-common/protocols/stage-protocol.md:725-737
  • core/aidlc-common/stages/inception/delivery-planning.md:80

Please complete the repository-wide rename/count/numbering sweep and regenerate dist/.

Merge blocker

The PR is currently CONFLICTING / DIRTY and is based on 2.5.36, while v2 has advanced. It needs a rebase and version/changelog reconciliation.

Verification

  • 30 affected smoke/unit test files passed.
  • 13 affected integration test files passed.
  • bun scripts/package.ts --check passed.
  • git diff --check passed.
  • Remote CI is green.

I recommend keeping this at CHANGES_REQUESTED until these gaps and the merge conflict are resolved.

@apackeer apackeer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional review findings beyond the existing changes-requested review. The Domain -> Units -> Contract -> Delivery direction is sound; these comments focus on responsibilities and end-to-end wiring that the core-stage change still needs.

One non-inline plugin issue: plugins/test-pro/contributions/construction/build-and-test.md:74 still asks for the removed business-rules artifact instead of rules, so its requirement traceability can omit the new source of truth.

The focused smoke/unit/integration slice passed (16 files, 472 assertions), but both new stages remain behaviorally uncovered in tests/.coverage-registry.json.

Comment thread CHANGELOG.md Outdated

## [2.6.0] - 2026-07-22

Inception design output restructure. Application Design becomes **Domain Design** (2.6): it now produces a single consolidated `components.md` — a fenced `yaml` component catalogue (source of truth) plus a derived human view (mermaid diagram + summary/ownership/rationale tables) — instead of the five separate `components`/`component-methods`/`services`/`component-dependency`/`decisions` artifacts. Entities are captured at the ownership level (identifier, attributes, cross-component references, external dependencies), with the full schema still deferred to Functional Design. A new **Contract Design** stage (2.8, CONDITIONAL, produces `contract-summary.md`) formalises inter-unit contracts so teams can build in parallel; Delivery Planning moves to 2.9. Functional Design's outputs are restructured into `entities.md` + `rules.md` (fenced `yaml` sources of truth) + `functional-spec.md` (derived human view), replacing `business-logic-model`/`business-rules`/`domain-entities`. The `aidlc-architect-agent` is reframed to own the logical/application concerns (domain + contract design) distinct from infrastructure. **Breaking for consumers that read inception design artifacts:** the five old app-design artifact names and the three old functional-design names are gone — read `components.md`, `contract-summary.md`, `entities.md`, `rules.md`, `functional-spec.md` instead. **Upgrade:** re-copy your `dist/<harness>/` shell into the project; existing in-flight workflows on the old stage names should finish on the prior shell.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 - upgrade can strand any v7 workflow crossing the changed Inception graph. The state schema still reports version 7, so an old state passes --doctor even though it has an application-design row and no domain-design or contract-design rows. When the new graph advances to one of those slugs, setCheckbox() is a no-op for the missing row but Current Stage is still updated; report then fails with Stage "..." is not present in the state file. The active-application-design case also fails because that slug no longer exists. Please add a state migration/alias or bump the state version so old states are rejected, and make the 2.6.0/2.6.1 upgrade instruction unambiguous.

reviewer: aidlc-architecture-reviewer-agent
reviewer_max_iterations: 2
produces:
- contract-summary

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 - the approved contract is not propagated through the workflow. aidlc-graph consumers contract-summary currently returns only functional-design. Delivery Planning cannot map contract ownership/blockers to Bolts or the walking skeleton; NFR and Infrastructure Design do not receive the retry/failure and integration-mechanism decisions; and Code Generation omits the artifact from consumes even though its body explicitly says to read it. This is especially risky for unit-major design and autonomous code-generation batches, which need one shared boundary contract. Please wire contract-summary into the relevant downstream stage contracts and read steps.

- **domain-entities.md**: Entities, relationships, data structures, attributes, lifecycle states, and entity interaction patterns
- **entities.md**: The entity model. Carries a fenced ```yaml source-of-truth block listing each entity with its description, attributes (name, logical type, required/unique, references, allowed values, defaults, min/max, constraints), entity-level constraints, and relationships (cardinality + direction). Follow the block with a short human-readable summary of the entity set.
- **rules.md**: The business rules. Carries a fenced ```yaml source-of-truth block listing each numbered rule (`id: BR-NNN`) with its statement, category (validation/authorization/constraint/calculation/policy), what it applies to, trigger, logic (IF…THEN in plain language), violation behaviour, and source (FR-n/NFR-n). Follow the block with a short human-readable rules summary table.
- **functional-spec.md**: The derived human view. An entity-relationship `mermaid` diagram (reflecting entities.md — the YAML is source of truth), state machines for lifecycle entities, workflows as numbered step sequences, and a rules summary. Everything here is derived from entities.md and rules.md.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 - functional-spec.md cannot be fully derived from the declared sources. entities.md and rules.md do not define workflow sequences or state-transition models, yet this requires workflows and state machines and says everything is derived from those two files. UI units make the contradiction concrete: produces_kinds gives them functional-spec but neither entities nor rules. Please add authoritative workflow/state schemas or define functional-spec as an independently authoritative artifact with explicit upstream sources.

slug: contract-design
phase: inception
execution: CONDITIONAL
condition: Execute when the system decomposes into more than one unit that must integrate. Skip for a single-unit system where there are no inter-unit boundaries to formalise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 - single-unit public APIs no longer have a contract-design owner. The removed Application Design stage specified component public interfaces and service communication contracts. Domain Design deliberately omits interfaces, this condition skips Contract Design for every single-unit system, and Functional Design declares no API-spec output. A single deployable API can therefore reach Code Generation with no approved external contract. Please broaden this condition to formal contracts rather than only inter-unit contracts, or assign public API specifications to another explicit stage/artifact.

- **Component Summary** — a table: `| Component | Purpose | Depends On | Dependents | Entities Owned |`.
- **Entity Ownership** — a table: `| Entity | Owning Component | Identifier | Attributes | References |`.
- **External Dependencies** — a table: `| Component | Dependency | Kind | Purpose |`.
- **Rationale** — a table explaining why each component is a separate building block (distinct lifecycle, distinct concern, distinct data ownership, distinct change rate — pick what applies).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 - removing decisions.md leaves the mandatory ADR contract unsatisfied. core/memory/phases/inception.md still requires ADRs with Context, Decision, Consequences, and Alternatives Rejected, and the architect persona still says it produces ADRs for significant choices. This rationale table records component-boundary reasoning but is not an ADR and has no place for the required structure. Please retain an explicit decisions/ADR artifact or update the phase rule and persona with a concrete replacement location and schema.

- The Q&A file path (e.g., `<record>/<phase>/<stage>/<stage>-questions.md`)
- All artifact file paths produced by the stage (the `produces` artifacts)
- For a per-unit stage (`directive.unit` present), also the resolved paths in `directive.consumes` (all upstream artifacts the stage declares, including the shared inception contracts that pin cross-unit boundaries - `components.md`, `component-methods.md`, `services.md`, `unit-of-work.md` - paths only, per the context-budget rule)
- For a per-unit stage (`directive.unit` present), also the resolved paths in `directive.consumes` (all upstream artifacts the stage declares, including the shared inception contracts that pin cross-unit boundaries - `components.md`, `contract-summary.md`, `unit-of-work.md` - paths only, per the context-budget rule)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 - the new Contract Design reviewer is not passed the evidence it must verify. This protocol passes directive.consumes only when directive.unit exists. Contract Design is workflow-level, so its architecture reviewer receives the produced summary but not the unit DAG, unit definitions, requirements, or component catalogue used to justify it. Pass declared upstream artifacts to non-per-unit reviewers as well, or add a contract-stage-specific evidence rule.

Comment thread CHANGELOG.md Outdated
* Stage `application-design` renamed to `domain-design` (2.6); its per-stage runner becomes `/aidlc-domain-design`. Its `produces` collapses from five artifacts to a single `components` (`components.md`).
* NEW stage `contract-design` (2.8, CONDITIONAL — skips for single-unit systems); per-stage runner `/aidlc-contract-design`; produces `contract-summary`. Delivery Planning renumbered 2.8 → 2.9. The framework now ships 33 stages (was 32).
* Functional Design `produces` renamed: `business-logic-model` → `functional-spec`, `business-rules` → `rules`, `domain-entities` → `entities`. Downstream consumes in `nfr-requirements`, `nfr-design`, `infrastructure-design`, and `code-generation` were rewired accordingly.
* Stage frontmatter now honours an authored `number:` / `name:` field (the compiler prefers it over the pinned graph value), so a renamed or inserted stage controls its own display number without a manual graph edit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 - this describes compiler behavior that is not implemented. compileStageGraph() explicitly keeps the pinned number and name for an existing slug. For new slugs, authored number: is only a relative tie-break hint; the engine assigns the next contiguous index, so the authored absolute number never overrides the graph. Please either implement this stated contract with collision/ordering safeguards or revise the release note to match the current pinning behavior.

@SiddhJog
SiddhJog force-pushed the feature/design-output-restructure branch from 31ba59f to 0510a82 Compare August 7, 2026 10:52
@SiddhJog

SiddhJog commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest v2 (2.5.55) and addressed all findings.

P1

State schema bumped 7→8 — pre-2.6 states now fail --doctor with a clear message instead of breaking on renamed rows (leandro #1, apackeer #1).
contract-summary wired into delivery-planning, nfr-requirements, nfr-design, infrastructure-design, code-generation; consumers contract-summary now returns all six. Added directive-resolution + graph tests (leandro #2, apackeer #2).

P2

workshop added to contract-design scopes (leandro #3).
Repo-wide stale sweep: 32→33, AD→DD/CD, Inception 2.1–2.9, personas, settings legend, docs (leandro #4).
functional-spec is now source of truth for workflows/state machines; ER + rules views derived (apackeer #3).
contract-design condition broadened to cover single-unit public APIs (apackeer #4).
Retained decisions.md ADR log on domain-design (apackeer #5).
Reviewer evidence now passed to workflow-level reviewers too (apackeer #6).
Dropped the inaccurate compiler-behavior CHANGELOG note (apackeer #7).
Cleanup: plugin fixture business-rules→rules; both new stages now covered.

Verified: package --check, coverage --check, t68 green. Residual test failures are known-environmental (t248/t255/t92), SDK-gated, or pre-existing t260 cases (confirmed identical on clean v2).

…lidation (v2.6.1)

Inception design-output restructure plus infrastructure-design consolidation.

Domain/Contract (was 2.6.0):
- application-design -> domain-design (2.6): five artifacts collapse to a single
  consolidated components.md — a fenced yaml component catalogue (source of
  truth: behaviour, responsibilities, depends_on/dependents,
  external_dependencies, owned entities with identifier + cross-component
  references) plus a derived human view (mermaid + summary/ownership/rationale)
- NEW contract-design stage (2.8, CONDITIONAL): formalises inter-unit contracts
  so teams build in parallel; produces contract-summary. Delivery Planning -> 2.9
- functional-design outputs -> entities / rules / functional-spec
- aidlc-architect-agent reframed to own domain + contract design
- compiler: honour authored frontmatter number:/name: over the stale graph pin;
  bump maxIndexByPhasePrefix on every number path; duplicate-number guard

Infra consolidation (was 2.6.1):
- infrastructure-design five artifacts -> three: deployment + services + shared
  fold into a tabular infrastructure-specification.md; monitoring-design and
  cicd-pipeline stay dedicated (Operation stages consume them independently)
- consumers rewired (code-generation, observability-setup, incident-response,
  environment-provisioning, deployment-pipeline)

Artifact registry 122 -> 117; stages 32 -> 33. Two code-review rounds addressed
(12 findings). All tiers green; package --check clean across all 5 harness trees.
Breaking for consumers of inception design + infra artifacts — see CHANGELOG.
@SiddhJog
SiddhJog force-pushed the feature/design-output-restructure branch from 0510a82 to 557b18d Compare August 7, 2026 10:59
@apackeer

apackeer commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Round-2 verification of 557b18d5. Most prior asks are now addressed in the authored source: the v8 doctor gate, six-consumer contract-summary wiring, functional-spec authority, single-unit public API ownership, retained ADR log, compiler-note removal, plugin rename, workshop scope, and coverage-registry entries all check out.

I am keeping this at changes requested for the following:

P1: two deterministic test regressions from the artifact rename

  • tests/unit/t272-unit-major-code-gen.test.ts:67-92 still creates the removed functional- and infrastructure-design artifact names. Functional Design therefore never settles and the unit-major walk repeatedly returns to it. This is the current smoke/unit CI failure: three assertions fail. The fixture also retains State Version 7 and application-design at :143 and :162.
  • tests/e2e/t134-swarm-referee.test.ts:185-188 creates the same removed functional-design artifacts. Required-artifact fingerprinting then rejects the review receipt, producing six deterministic failures in the swarm-finalize paths. CI does not run this e2e file.

Both are branch-caused: t272 and t134 pass on clean current v2, but fail on this branch.

P2: workflow-level reviewer evidence is not wired through the harnesses

core/aidlc-common/protocols/stage-protocol.md:1023-1025 correctly says to pass directive.consumes to every reviewer-bearing stage, including workflow-level Contract Design. However, the actual harness orchestrator instructions still restrict those paths to per-unit stages (harness/claude/skills/aidlc/SKILL.md:83, harness/codex/skills/aidlc/SKILL.md:79, with the same wording in the other harnesses).

tests/unit/t217-reviewer-read-scope.test.ts:26-31,62-72 also continues to pin only the old per-unit rule. Please update every harness skill and add a workflow-level assertion so Contract Design reliably receives its unit DAG, components, and requirements evidence.

P2: the state-upgrade remediation points at a retired layout

The new doctor check works, but its fix text tells users to run mv aidlc-docs aidlc-docs.v7-archive (core/tools/aidlc-utility.ts:1877,1883). The current layout is under aidlc/spaces/<space>/intents/; core/tools/aidlc-lib.ts:1402-1407 explicitly says there is no flat aidlc-docs/ root.

Please provide a valid archive/restart command and add a regression test for "v7 state -> failing doctor row + non-zero exit". Current tests only pin the happy-path State Version 8 text.

P2: the repository-wide semantics and numbering sweep is incomplete

  • CHANGELOG.md:14 still calls functional-spec a derived human view, while the stage now makes workflows/state machines authoritative there.
  • CHANGELOG.md:17 says Contract Design skips single-unit systems, contradicting the new public/external API condition.
  • core/aidlc-common/stages/inception/contract-design.md:35 still describes only inter-unit contracts.
  • core/knowledge/aidlc-delivery-agent/workflow-planning-guide.md:53,57 calls Bolt/Delivery Planning Stage 2.8; it is now 2.9.
  • docs/guide/workshop-mode.md:59,63 still says Inception ends at 2.8 and Delivery Planning is 2.8.

Merge/rebase blockers

The PR is currently CONFLICTING/DIRTY against v2 at 5f6b310f (2.5.59).

  • Current v2 already contains t273-scope-aware-phase-dirs.test.ts and t274-voice-parity.test.ts; the new t273-contract-design-wiring.test.ts needs renumbering, and its describe block still says t271.
  • The modify/delete conflict on application-design.md includes the newer completion-handoff wording from the base. Port that wording into both replacement stages: domain-design.md:165 and contract-design.md:105 still use the old sentence.
  • Reconcile the version/changelog and regenerate dist/ after rebasing.

Verification:

  • Focused 16-file slice: tests/logs/2026-08-08T09-53-37Z, Result: FAIL - only t272, three assertions.
  • Branch t134: tests/logs/2026-08-08T10-10-08Z, Result: FAIL - six assertions.
  • Clean-v2 controls: t272 PASS at tests/logs/2026-08-08T09-55-30Z; t134 PASS at tests/logs/2026-08-08T10-12-07Z.
  • bun scripts/package.ts --check passes across all five harnesses on the current branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants