1. Maintenance and evolution guide

Maintenance and evolution guide

What to update when you add an application module, build a feature, or change architecture rules.

As you build new features and add application modules, you must keep the QA system updated. This guide explains the exact steps an engineer should follow to ensure new code passes the quality gate.

The development lifecycle for a feature

When you pick up an implementation spec from docs/implementation/, follow these five steps.

Step 1. Implement feature code and automated tests

Write your application logic under src/ according to the architectural layer rules:

  • Components go in src/presentation/.
  • Network and API routes go in src/transport/.
  • Pure business decisions go in src/domain/.
  • Capability interfaces go in src/capabilities/.
  • Third-party SDK integrations go in src/vendors/.

Write deterministic tests under tests/unit/ or tests/integration/. Every test must assert concrete outcomes, never placeholder mocks.

Step 2. Triggering the application build tripwire

If you add the first application file under src/app/, scripts/check-repository.mjs will intentionally fail pnpm check with this error:

The first application entry must add a real build to pnpm check.
The first application entry must add application tests to pnpm check.

To clear this error:

  1. Open package.json.
  2. Add "build": "next build", or the appropriate framework build command.
  3. Add "test:app": "node --test tests/app/*.test.mjs".
  4. Update the "check" script to include both commands.
  5. Register the new module under productModules in tooling/architecture-policy.mjs.

Step 3. Update the acceptance manifest

Open tooling/qa/manifest/acceptance-manifest.json and locate the relevant acceptance ID:

{
  "acceptanceId": "IMPORT-01",
  "primarySpec": "04",
  "owningFeature": "import-preview",
  "status": "implemented",
  "testSelectors": [
    "tests/unit/import-parser.test.mjs",
    "tests/integration/import-preview.test.mjs"
  ],
  "agentTasks": ["task-import-modes"],
  "oracleDescription": "Paste, CSV, XLSX and Sheets imports preview correctly; empty/oversized/invalid input rejected with actionable feedback."
}
  1. Flip "status" from "unimplemented" to "implemented".
  2. Add your automated test files to "testSelectors".
  3. Add the browser exploration task ID to "agentTasks".

Step 4. Update the execution plan resolver

Open tooling/qa/policy/resolver.mjs.

In resolveExecutionPlan, inspect candidate.stagedFiles. If staged files affect your new feature directory, map those changes to the required agent tasks:

if (candidate.stagedFiles.some((f) => f.path.startsWith("src/domain/imports/"))) {
  requiredTasks.push({
    taskId: "task-import-modes",
    acceptanceId: "IMPORT-01",
    prompt:
      "Verify that CSV and XLSX files preview valid rows and show error feedback for empty files.",
  });
}

This ensures that when future commits touch import code, the QA agent automatically exercises the import preview flow in the browser.

Step 5. Run the pre-commit gate locally

Stage your files and run the gate:

git add .
pnpm qa

If the run passes:

  • Exit code is 0.
  • A summary appears on stdout.
  • A signed receipt is saved in .qa-reports/runs/<runId>/receipt.json.

Now you can create your git commit safely.


What happens when you change policy files

If you modify tooling/architecture-policy.mjs, tooling/repository-policy.mjs, or eslint.config.mjs:

  1. tooling/qa/policy/resolver.mjs computes a new composite sha256 hash.
  2. Any previously issued receipts will no longer match the active policy digest.
  3. CI will invalidate cached results and force a fresh evaluation of incoming commits.

This cryptographic binding ensures that changing a rule immediately forces all affected code to re-prove its compliance.