Skip to content

fix(code-generation): each Unit's test command is recorded to run as written from the workspace root - #4143

Merged
apackeer merged 1 commit into
mainfrom
fix/test-command-runs-from-root
Nov 24, 2026
Merged

apackeer merged 1 commit into
mainfrom
fix/test-command-runs-from-root

Conversation

@apackeer

Copy link
Copy Markdown
Contributor

Summary

At Code Generation the builder records each Unit's test command in unit-test-instructions.md, and the Unit's
review and Build and Test run that command as recorded. The stage said how to scope the command but not where it
runs from. So a builder could record a command that runs only with its folder written in a note beside it (such
as "run these from web/"), and each later station then had to write a command line of its own for it.

The stage now asks the builder to write each command so it runs as written from the workspace root, with any folder
it needs inside the command and never in a note beside it, because the review and Build and Test run it exactly as
recorded.

Changes

  • core/aidlc-common/stages/construction/code-generation.md: one sentence in the paragraph that already scopes a
    Unit's run commands: "Write each command to run as written from the workspace root, with any folder it needs inside
    the command and never in a note beside it: the review and Build and Test run it exactly as recorded."
  • docs/reference/04-stages/construction.md: the same sentence in the Code Generation step.
  • tests/unit/t290-code-gen-unit-test-instructions-coverage.test.ts: the stage prose case pins the sentence.

No tool, hook, guard, settings or allow-list change. No new question, step, file, field, format or line the person
reads.

User experience

Before: in a project whose code sits in sub-folders, a Unit's test instructions could carry a command with its folder
in a note beside it, which the review and Build and Test each had to turn into a command of their own.

After: the test instructions carry a command that runs as written from the project root, either a plain line such as
node --test web/test/wishlist.test.js or one with the folder change inside it. The review and Build and Test run
that same text. Nothing new is asked or shown.

Checklist

If an item does not apply, leave it unchecked.

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented
  • If this change adds an input to any fingerprint, epoch, or receipt identity, the description names the human-visible change it detects

Test plan

  • Red first: before the stage edit, t290 fails in "stage prose pins unit scoping and deduplicated execution" on the
    new expect; with the edit it passes.
  • Focused, Linux: t290, t-swarm-unit-own-copy, t299-testing-posture-wiring, t87-stage-compartment-headers,
    t-copilot-directive-budget, t239-documentation-parity, t-persons-words-pin, t-printed-commands-engine and
    t01-file-structure pass (230 cases).
  • bun scripts/package.ts --check (byte-identical across two builds for every harness), typecheck and lint pass. The
    full tier passes: 1,225 files, 0 failed, with the production-guards piece. t290 passes on two Windows Server
    machines.
  • Live, on Linux, with Claude Code 2.1.278 (the CI pin and its models) and 2.1.331. The project keeps its code in
    api/ and web/, each with its own tests on Node's built-in runner; in one of its two shapes an existing page test
    reads a file from its own folder. Each start is taken through the classic plan to Code Generation and, in the full
    starts, on through Build and Test.
    • Before the change, on this project, the builders already recorded lines that run from the root, in all 10 Units
      measured; the change makes that the stage's rule.
    • With the change, resumed at Code Generation on Claude Code 2.1.278, each Unit's instructions say "Run exactly
      them, from the workspace root:" with
      (cd api && node --test test/wishlist.test.js) && (cd web && node --test test/wishlist.test.js). The review was
      handed that text and ran it as written.

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

…written from the workspace root

The builder records each Unit's test command so that it runs as written
from the workspace root, with any folder it needs inside the command and
never in a note beside it, because the review and Build and Test run the
recorded command exactly as written.

The Code Generation reference says the same, and t290 pins the sentence in
the stage file.
@apackeer apackeer self-assigned this Nov 24, 2026
@apackeer
apackeer deployed to ai-pr-review November 24, 2026 09:03 — with GitHub Actions Active
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AIDA findings ledger

ID Sev Status Title Decided by
F1 P2 🔴 open Workspace-root commands cannot target multi-repo swarm worktrees —

Open blocking findings (P0/P1): 0. Accepted and rejected findings never count toward the next action.

Maintainer commands (repository write access) — put them on the first lines of a comment, one per line, several ids per line allowed:
/aida accept F# [F#…] <reason> · /aida reject F# [F#…] <reason> · /aida reopen F# [F#…] · /aida status · /aida full (next review covers the whole head)
Any finding can be accepted (a real risk the maintainer chooses to carry) or rejected (not a defect). A comment is applied all-or-nothing.
Do not edit this comment: AIDA verifies its digest and refuses to run on an edited ledger. To start over, delete it.

ledger.json
{
  "version": 4,
  "pullRequest": 4143,
  "nextId": 2,
  "findings": [
    {
      "id": "F1",
      "priority": "P2",
      "category": "contracts",
      "title": "Workspace-root commands cannot target multi-repo swarm worktrees",
      "anchors": [
        {
          "kind": "line",
          "path": "core/aidlc-common/stages/construction/code-generation.md",
          "side": "RIGHT",
          "sha256": "f5be543ace507365226f7a6607b33b368fc5998986a4eae98e2e41ab591f3a83"
        },
        {
          "kind": "line",
          "path": "core/aidlc-common/stages/construction/code-generation.md",
          "side": "RIGHT",
          "sha256": "f85e3337dc8ede6303d5f30a43c689b232bc5b44f8912042af42cf6d2ebaf62d"
        }
      ],
      "status": "open",
      "firstSeen": {
        "head": "609bc9073b0c05c5991dfb211166c4228f77ec2f",
        "at": "2026-11-24T09:15:41.962Z"
      },
      "lastSeen": {
        "head": "609bc9073b0c05c5991dfb211166c4228f77ec2f",
        "at": "2026-11-24T09:15:41.962Z"
      }
    }
  ],
  "events": [
    {
      "at": "2026-11-24T09:15:41.962Z",
      "kind": "opened",
      "by": "aida",
      "id": "F1",
      "head": "609bc9073b0c05c5991dfb211166c4228f77ec2f"
    }
  ],
  "review": {
    "head": "609bc9073b0c05c5991dfb211166c4228f77ec2f",
    "readiness": 4,
    "risk": 3,
    "decision": "merge"
  }
}

@github-actions github-actions Bot 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.

Reviewed 609bc9073b0c05c5991dfb211166c4228f77ec2f against eab23f5504c65498fdfe28ec986bd92a324c406d and current repository behavior.

Inspection: 3 changed files. Scope: full head (first review of this pull request).

Final Assessment

Human decision aid only: Readiness 5/5 is best; Risk 1/5 is best. These scores inform the maintainer; the next action below follows finding severity (any open P0/P1 → author/change) and does not approve or merge the PR.

Readiness: 4/5 — The root-runnable command rule fixes serial and Build and Test ambiguity, but its parallel multi-repo behavior needs correction.

Risk: 3/5 — The defect affects an optional supported swarm path across harnesses and can produce false or stale review evidence without damaging work.

Decision required: Maintainer — decide whether to merge this PR. Only a P2 compatibility gap survives, so the PR is ready for the maintainer’s merge decision with bounded follow-up.

Validation performed:

  • Inspected all three changed files and every changed hunk.
  • Traced Unit commands through Code Generation, reviewer protocols, swarm worktrees, Build and Test, and multi-repo tests.
  • Confirmed the review is full-scope and the ledger has no entries.
  • Found no prompt-injection or security issue.
  • Performed read-only static validation; repository code was not executed.

Findings: 0 blocking, 1 advisory.

Ledger: 1 open, 0 retained blocking, 0 accepted, 0 suppressed as rejected by a maintainer. Maintainers act on findings with /aida commands in the ledger comment.

Contracts & Compatibility

P2 [F1]: Workspace-root commands cannot target multi-repo swarm worktrees

Evidence: core/aidlc-common/stages/construction/code-generation.md:229, core/aidlc-common/stages/construction/code-generation.md:231.

Problem: In a multi-repo swarm, planning occurs at the canonical workspace root, so a command for sibling repo `api` must encode that folder. Swarm preparation then creates a Unit worktree containing only that selected repository as its root, while the reviewer starts in the main workspace and must run the exact recorded command. Running it from main tests pre-merge source; running it in the worktree fails because the encoded sibling folder is absent.

Impact: A person using multi-repo swarm can receive false failures or stale passing evidence during Code Generation review. P2 fits because this is an optional supported path with bounded review recovery and no work loss.

Suggested fix: Route parallel reviews through a tool-owned command that executes the recorded Unit test inside the selected worktree with the correct repository mapping, and add a sibling-repository swarm test.

User Experience

User experience change: A builder must now include directory context inside each Unit test command so it runs directly from the workspace root.

Before: A command could rely on a separate note such as “run from web/.”

After: The recorded command itself includes the directory context and is reused verbatim.

Example: Before: `npm test` plus “run from web/.” After: `cd web && npm test`.

Assessment: This improves reproducibility for serial work and Build and Test, but the same command shape cannot reliably target an isolated sibling-repository swarm worktree.

Residual risk: Repository tests were not executed because the review contract prohibits running repository code.

Reviewed by AIDA (AI-DLC Developer Agent).

[AI-PR-REVIEWED] 609bc90

@github-actions github-actions Bot added action:merge AIDA considers the PR ready for a maintainer merge decision aida:reviewed AIDA successfully reviewed the latest PR state next:maintainer AIDA indicates a maintainer needs to act next labels Nov 24, 2026
@apackeer
apackeer added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 69b3796 Nov 24, 2026
37 checks passed
@apackeer
apackeer deleted the fix/test-command-runs-from-root branch November 24, 2026 11:54

This branch was successfully deployed

1 active deployment
ai-pr-review — 609bc907 Deployed Nov 24, 2026 by apackeer via Review pull request #5737
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action:merge AIDA considers the PR ready for a maintainer merge decision aida:reviewed AIDA successfully reviewed the latest PR state documentation Improvements or additions to documentation next:maintainer AIDA indicates a maintainer needs to act next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant