qfai 1.9.2 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +67 -6
  2. package/assets/init/.qfai/assistant/README.md +27 -0
  3. package/assets/init/.qfai/assistant/agents/acceptance-test-engineer.md +1 -0
  4. package/assets/init/.qfai/assistant/agents/backend-engineer.md +1 -0
  5. package/assets/init/.qfai/assistant/agents/completion-reviewer.md +29 -2
  6. package/assets/init/.qfai/assistant/agents/delivery-planner.md +17 -0
  7. package/assets/init/.qfai/assistant/agents/frontend-engineer.md +1 -0
  8. package/assets/init/.qfai/assistant/agents/implementation-reviewer.md +17 -0
  9. package/assets/init/.qfai/assistant/agents/orchestrator.md +2 -2
  10. package/assets/init/.qfai/assistant/agents/qa-gatekeeper.md +183 -5
  11. package/assets/init/.qfai/assistant/agents/test-design-analyst.md +22 -3
  12. package/assets/init/.qfai/assistant/catalog/cli-ux-guidelines.md +2 -2
  13. package/assets/init/.qfai/assistant/catalog/spec_required_files.json +2 -1
  14. package/assets/init/.qfai/assistant/catalog/test-layers-ci-lanes.md +60 -0
  15. package/assets/init/.qfai/assistant/catalog/test-layers.md +430 -13
  16. package/assets/init/.qfai/assistant/catalog/worklog-entry.schema.md +165 -0
  17. package/assets/init/.qfai/assistant/constitution/communication.md +1 -1
  18. package/assets/init/.qfai/assistant/constitution/constitution.md +1 -1
  19. package/assets/init/.qfai/assistant/constitution/drift-protocol.md +359 -10
  20. package/assets/init/.qfai/assistant/constitution/quality.md +35 -5
  21. package/assets/init/.qfai/assistant/constitution/requirements-decomposition.md +37 -0
  22. package/assets/init/.qfai/assistant/constitution/shared-skill-delegation-baseline.md +419 -8
  23. package/assets/init/.qfai/assistant/constitution/shared-skill-operating-baseline.md +122 -5
  24. package/assets/init/.qfai/assistant/constitution/workflow.md +53 -7
  25. package/assets/init/.qfai/assistant/manifest/agent-catalog.yml +439 -946
  26. package/assets/init/.qfai/assistant/manifest/agent-routing.yml +116 -4
  27. package/assets/init/.qfai/assistant/manifest/review-profiles.yml +9 -0
  28. package/assets/init/.qfai/assistant/process/migrations/v1.4.27-atdd-alignment.md +1 -1
  29. package/assets/init/.qfai/assistant/skills/qfai-atdd/SKILL.md +150 -53
  30. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/credential-reuse.md +146 -0
  31. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/red-provenance.md +456 -0
  32. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/review-fix-rounds.md +128 -0
  33. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/scaffolding.md +29 -0
  34. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/shared-test-artifacts.md +96 -0
  35. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/stale-manifest.md +34 -0
  36. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/test-case-depth-checklist.md +52 -5
  37. package/assets/init/.qfai/assistant/skills/qfai-configure/SKILL.md +16 -8
  38. package/assets/init/.qfai/assistant/skills/qfai-discussion/SKILL.md +8 -4
  39. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/design-md-brand-catalog.md +2 -2
  40. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/discussion-completion-matrix.md +17 -7
  41. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/rcp_footer.md +10 -4
  42. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/review-cycle-playbook.md +5 -1
  43. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui-bearing-playbook.md +4 -4
  44. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux/review_audit_playbook.md +1 -1
  45. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux/trend_scan_playbook.md +1 -1
  46. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux_best_practices.md +17 -7
  47. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/01_Context.md +1 -1
  48. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/02_Inception-Deck.md +1 -1
  49. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/03_Story-Workshop.md +11 -3
  50. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/05_Scope.md +5 -2
  51. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/07_NFR.md +1 -1
  52. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/09_Constraints.md +7 -4
  53. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/10_Policy.md +1 -1
  54. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/11_OQ-Register.md +1 -1
  55. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/12_OQ-Resolution-Log.md +1 -1
  56. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/14_Review-Request.md +14 -7
  57. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/99_delta.md +1 -1
  58. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/Rxx_reviewer.md +16 -7
  59. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/review_request.md +9 -6
  60. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/summary.json +2 -0
  61. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/uiux/40_screen_contracts.md +3 -2
  62. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/uiux/50_review_input_bundle.md +4 -2
  63. package/assets/init/.qfai/assistant/skills/qfai-implement/SKILL.md +252 -130
  64. package/assets/init/.qfai/assistant/skills/qfai-implement/references/change-request-reset.md +93 -0
  65. package/assets/init/.qfai/assistant/skills/qfai-implement/references/checkpoint-verification.md +210 -0
  66. package/assets/init/.qfai/assistant/skills/qfai-implement/references/cross-spec-ownership.md +73 -0
  67. package/assets/init/.qfai/assistant/skills/qfai-implement/references/evidence-revision.md +291 -0
  68. package/assets/init/.qfai/assistant/skills/qfai-implement/references/execution-ledger.md +389 -0
  69. package/assets/init/.qfai/assistant/skills/qfai-implement/references/final-checklist.md +28 -0
  70. package/assets/init/.qfai/assistant/skills/qfai-implement/references/finding-classification.md +49 -0
  71. package/assets/init/.qfai/assistant/skills/qfai-implement/references/ledger-preconditions.md +55 -0
  72. package/assets/init/.qfai/assistant/skills/qfai-implement/references/oracle-strength.md +81 -0
  73. package/assets/init/.qfai/assistant/skills/qfai-implement/references/parallelization-policy.md +235 -0
  74. package/assets/init/.qfai/assistant/skills/qfai-implement/references/red-admissibility.md +91 -0
  75. package/assets/init/.qfai/assistant/skills/qfai-implement/references/red-not-observable.md +112 -0
  76. package/assets/init/.qfai/assistant/skills/qfai-implement/references/relevant-test-suite.md +87 -0
  77. package/assets/init/.qfai/assistant/skills/qfai-implement/references/review-artifact-layout.md +44 -0
  78. package/assets/init/.qfai/assistant/skills/qfai-implement/references/round-evidence.md +118 -0
  79. package/assets/init/.qfai/assistant/skills/qfai-implement/references/selector-granularity.md +24 -0
  80. package/assets/init/.qfai/assistant/skills/qfai-implement/references/upstream-artifact-ordering.md +33 -0
  81. package/assets/init/.qfai/assistant/skills/qfai-implement/references/volume-policy.md +149 -0
  82. package/assets/init/.qfai/assistant/skills/qfai-prototyping/SKILL.md +35 -18
  83. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/evidence-requirements.md +1 -1
  84. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/generator-prompt.md +106 -7
  85. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/handoff.md +40 -11
  86. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/iteration-loop.md +48 -1
  87. package/assets/init/.qfai/assistant/skills/qfai-prototyping/templates/DESIGN.md.sample +6 -0
  88. package/assets/init/.qfai/assistant/skills/qfai-sdd/SKILL.md +87 -22
  89. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/contract-artifact-rules.md +148 -0
  90. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/rcp_footer.md +10 -4
  91. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/review-cycle-playbook.md +5 -1
  92. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-execution-playbook.md +4 -2
  93. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-phase-checklists.md +18 -0
  94. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-quality-gate.md +44 -3
  95. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-triage.md +60 -7
  96. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/spec-traceability-rules.md +171 -6
  97. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/change-request.md +125 -0
  98. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/contracts/db-contract.sample.sql +6 -0
  99. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/evidence/sdd-spec.md +92 -0
  100. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/01_Objective.md +27 -0
  101. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/02_Initiative.md +30 -0
  102. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/05_Contracts.md +16 -6
  103. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/06_Glossary.md +19 -0
  104. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/07_Constraints.md +25 -0
  105. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/08_Decisions.md +22 -2
  106. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/11_Slice-Policy.md +37 -10
  107. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/02_User-stories.md +20 -0
  108. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/03_Acceptance-Criteria.md +19 -0
  109. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/04_Business-Rules.md +32 -3
  110. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/06_Test-Cases.md +56 -0
  111. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/07_Decisions.md +29 -2
  112. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/10_Plan.md +41 -0
  113. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/16_Traceability-ledger.md +58 -0
  114. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/tdd/test-list.md +56 -0
  115. package/assets/init/.qfai/assistant/skills/qfai-verify/SKILL.md +57 -102
  116. package/assets/init/.qfai/assistant/skills/qfai-verify/references/articles.md +24 -0
  117. package/assets/init/.qfai/assistant/skills/qfai-verify/references/context-load.md +22 -0
  118. package/assets/init/.qfai/assistant/skills/qfai-verify/references/verify-output-contract.md +48 -0
  119. package/assets/init/.qfai/assistant/skills/qfai-verify/templates/verify-evidence.md +48 -0
  120. package/assets/init/.qfai/assistant/skills/web-research/SKILL.md +25 -7
  121. package/assets/init/.qfai/waivers.yml +11 -5
  122. package/assets/init/root/.github/workflows/qfai-tests.yml +318 -0
  123. package/assets/init/root/.github/workflows/qfai-validate.yml +327 -24
  124. package/assets/init/root/DESIGN.md +6 -0
  125. package/assets/init/root/qfai.config.yaml +15 -12
  126. package/dist/cli/index.cjs +20646 -13620
  127. package/dist/cli/index.cjs.map +1 -1
  128. package/dist/cli/index.mjs +22101 -15061
  129. package/dist/cli/index.mjs.map +1 -1
  130. package/dist/index.cjs +13954 -8829
  131. package/dist/index.cjs.map +1 -1
  132. package/dist/index.d.cts +423 -14
  133. package/dist/index.d.ts +423 -14
  134. package/dist/index.mjs +9330 -4224
  135. package/dist/index.mjs.map +1 -1
  136. package/package.json +22 -19
@@ -0,0 +1,146 @@
1
+ # Credential reuse across parallel workers
2
+
3
+ Acceptance tests that need an authenticated actor pay for the sign-in once per worker, not once
4
+ per test. This file is the rule set. It is prose guidance — it adds no validator, no finding code,
5
+ no test layer and no annotation token, and nothing here is checked by a tool.
6
+
7
+ ## Scope
8
+
9
+ These rules oblige the **E2E, API and Integration** layers only, which is this skill's whole scope.
10
+ They introduce no unit or component obligation: those layers belong to `/qfai-implement`, and a
11
+ unit test that needs a credential is describing an integration.
12
+
13
+ This guidance names no test runner and no browser automation library. Every rule below is stated
14
+ about a _session cache_ and a _worker_, which every parallel runner has under some spelling, so
15
+ choosing the tool stays the adopter's decision.
16
+
17
+ ## Not dogfooded here
18
+
19
+ **QFAI's own suite has zero credentials.** Nothing in this repository signs in, so none of these
20
+ rules is exercised by running the tests here. They are recorded because the rule set is the
21
+ transferable asset, not because they were verified by execution in this tree — read them as
22
+ guidance to adopt, not as a report of something that already runs.
23
+
24
+ ## The seven session-reuse rules
25
+
26
+ Each is a separate obligation. A harness can satisfy six of them and still authenticate on every
27
+ test, or still leak one account across workers.
28
+
29
+ ### 1. Never sign in per test
30
+
31
+ Authentication belongs to worker setup, not to a test body. A suite that signs in per test pays
32
+ the slowest operation it has once per case, and the cost grows with the suite instead of with the
33
+ worker count.
34
+
35
+ ### 2. Never share one account across parallel workers
36
+
37
+ Two workers driving the same actor at the same time is a race with no test to blame it on: a
38
+ sign-out, a session invalidation or a state change made by one worker arrives inside the other's
39
+ assertions. One account per worker, always — a shared account is not an optimisation, it is a
40
+ cross-test dependency that the runner cannot see.
41
+
42
+ ### 3. Key the cached session by the pair of worker index and actor
43
+
44
+ Neither half is sufficient on its own. Keyed by actor alone, two workers exercising the same role
45
+ collide — rule 2 again, arriving through the cache. Keyed by worker alone, a suite that needs an
46
+ administrator and an ordinary user hands the second one the first one's session, and the test
47
+ fails on an authorisation it never intended to exercise. The key is the **pair**.
48
+
49
+ ### 4. Tear the cache down at worker exit
50
+
51
+ A session cache that outlives its worker is a credential on disk. It also becomes a correctness
52
+ problem the next run: a restored session from a previous run reflects a state the current run
53
+ never established, so a test can pass against data it did not create. Bind the cache's lifetime to
54
+ the worker's.
55
+
56
+ ### 5. Re-authenticate and rewrite the cache when a restored session is rejected
57
+
58
+ A cached session expires, gets revoked, or stops being valid because the environment was reset
59
+ between runs. The harness must detect the rejection, sign in again, and **overwrite** the cache
60
+ with the fresh session. Two failure modes this closes: a suite that treats the rejection as a test
61
+ failure reports a red that says nothing about the product, and a suite that retries against the
62
+ stale cache loops.
63
+
64
+ ### 6. A test that mutates its own account creates a dedicated one
65
+
66
+ Changing a password, disabling the account, altering a profile, consuming a one-time entitlement:
67
+ each of those breaks the cached session every _other_ test on that actor depends on. A test whose
68
+ subject is the account itself provisions its own actor, uses it, and does not put it back in the
69
+ pool.
70
+
71
+ ### 7. Test-level parallelism costs more workers, not more sign-ins
72
+
73
+ Raising parallelism adds workers; each new worker pays one sign-in. If raising parallelism raises
74
+ the sign-in count faster than the worker count, one of the six rules above is not being followed —
75
+ most often rule 1, and most often because a helper was called from a test body rather than from
76
+ setup. The ratio is the diagnostic.
77
+
78
+ ## The companion rule: a caller-injected environment is not the harness's to manage
79
+
80
+ When the caller injects an environment identifier — a target URL, a tenant, a named deployment,
81
+ any handle that says _use this one_ — the harness **must not provision that environment and must
82
+ not tear it down.** It signs in against it, runs, and leaves it exactly as it found it.
83
+
84
+ The reason is that the injection is what tells the harness the environment is owned elsewhere.
85
+ A harness that provisions when it was handed a target creates a second environment nobody asked
86
+ for; a harness that tears one down at the end of a run destroys a shared or long-lived environment
87
+ that other work depends on. Both are irreversible from inside the run.
88
+
89
+ The rule is about _ownership_, not about the shape of the value: a harness that creates its own
90
+ ephemeral environment when nothing was injected is following this rule, not breaking it.
91
+
92
+ ## Script naming: adopter guidance
93
+
94
+ **A credential-free lane and a credentialed lane should be reachable under different script
95
+ names.** A lane that structurally cannot touch the network is a different thing from one that must
96
+ have a working account, and giving them one name makes that difference invisible to whoever runs
97
+ them: contributors without credentials cannot tell which lane they can run, and CI cannot express
98
+ "run the half that needs no secrets" without a name for it.
99
+
100
+ Two properties do the work, whatever the names are:
101
+
102
+ - the credential-free lane is runnable by someone who has no account at all, and
103
+ - reading the script name tells you which of the two you are about to run.
104
+
105
+ **This is adopter guidance and QFAI adopts none of it.** QFAI keeps its own script names unchanged;
106
+ because its suite has no credentials there is no credentialed lane here to name, and renaming a
107
+ lane to model a distinction this repository does not have would be a cost with no reader.
108
+
109
+ ## A worked example, as one illustration among possible backends
110
+
111
+ The shape below is **one** way to satisfy the rules, sketched in no particular tool. Any runner
112
+ with per-worker setup and a place to persist a session can express it, and the rules — not this
113
+ sketch — are what has to survive the translation.
114
+
115
+ ```text
116
+ worker setup:
117
+ key = (worker index, actor role)
118
+ cached = load(key) # rule 3: the pair is the key
119
+ if cached is absent:
120
+ session = sign_in(actor for key) # rule 1: once per worker
121
+ save(key, session)
122
+ else:
123
+ if not accepted(cached): # rule 5: a restored session can be rejected
124
+ session = sign_in(actor for key)
125
+ save(key, session) # ...and the cache is rewritten
126
+
127
+ each test:
128
+ attach the session for this worker's key # never sign_in here
129
+
130
+ a test that mutates its actor:
131
+ actor = create_dedicated_actor() # rule 6: not from the pool
132
+ ...
133
+ (the pooled session is untouched)
134
+
135
+ worker teardown:
136
+ discard(key) # rule 4: lifetime is the worker's
137
+
138
+ environment:
139
+ if the caller injected a target:
140
+ use it; provision nothing; tear down nothing # the companion rule
141
+ else:
142
+ the harness may create and destroy its own
143
+ ```
144
+
145
+ Nothing in that sketch names a library, and it should not: the moment a rule is expressed as one
146
+ tool's API call, it stops being portable to the next one.
@@ -0,0 +1,456 @@
1
+ # RED Provenance for an ATDD-owned Ledger Row
2
+
3
+ `.qfai/specs/<spec-id>/tdd/test-list.md` is `/qfai-implement`'s execution
4
+ ledger, and `qfai-implement/SKILL.md` states the split: **`Layer = E2E`,
5
+ `Layer = API` and `Layer = Integration` rows are tracked there, but their tests
6
+ are authored here.** This skill therefore writes into a ledger whose status
7
+ lifecycle it does not define.
8
+
9
+ ## What this skill produces
10
+
11
+ - **Evidence, not ledger cells.** `/qfai-implement` writes `Status`, `DR-ID`
12
+ and `Evidence` for every row — one writer, as
13
+ `constitution/drift-protocol.md` grants it. This stage produces the evidence
14
+ those cells point at, in `.qfai/evidence/atdd-<spec-id>.md` under
15
+ `## Ledger rows advanced`, and hands it over.
16
+ - The lifecycle is
17
+ `../../qfai-implement/references/execution-ledger.md#allowed-transitions`. It is
18
+ forward-only from `todo`, and `todo -> red` requires an **admissible RED**: an
19
+ assertion inside the row's own selector raised the failure, observed before
20
+ the production code that makes it pass exists
21
+ (`../../qfai-implement/references/red-admissibility.md`).
22
+
23
+ ## Why the stage order makes this a real question
24
+
25
+ Work Orders build the API and integration surfaces a journey needs (P3, P4). A
26
+ journey written _after_ its surface passes on the first run, so there is nothing
27
+ to watch fail — and `qfai-implement/SKILL.md` classifies a test that
28
+ unexpectedly passes as an anomaly bound for `exception`.
29
+
30
+ Left unaddressed, that makes `exception` the only terminal state an ATDD-owned
31
+ row can reach, and a spec closes with its journeys recorded as anomalies rather
32
+ than as completed work.
33
+
34
+ ## The three branches (MUST)
35
+
36
+ Take the first that applies, and record which one in the evidence file.
37
+
38
+ 1. **Observed RED (preferred).** Write the journey or API test **against the
39
+ current tree**, before this cycle builds any surface it needs.
40
+ 1. **Ask `/qfai-implement` for the minimal seam first — for a surface that does not exist.** A row that reached branch 1 from branch 2's first-run check has its surface already; skip to step 2 and read the note there. A test for a route
41
+ that does not exist yet fails with a 404 or an import error, and that is a
42
+ missing seam, not a RED — but the seam is production code, and this stage
43
+ owns none: its `red` phase is `acceptance-test-engineer` and
44
+ `qa-gatekeeper`, with no backend or frontend agent. Hand the row over for
45
+ its Phase Red step 3a — register the route, or add the export the test
46
+ imports, so it **resolves but does not satisfy the row's predicate** — and
47
+ come back with the seam in place. Skipping it makes the first failure of
48
+ any new-surface row a resolution error by construction; writing it here
49
+ is the ownership breach step 5 exists to prevent.
50
+
51
+ **The seam must not return the contracted status.** When the row's
52
+ predicate _is_ the status — `201` on create, `204` on delete, `403` on a
53
+ refusal — a handler registered with "the declared status" passes the
54
+ assertion the moment it exists, so there is no RED left to observe and the
55
+ row's behaviour was implemented before its test failed, which is what
56
+ branch 1 exists to prevent. Answer with a not-implemented sentinel the
57
+ contract does not use (`501`, or `500` from an explicit
58
+ `NotImplementedError`) and a **schema-compatible neutral body** — the
59
+ shape the selector decodes, with the contracted predicate absent or at a
60
+ value the row does not own. Not an empty body: a selector that decodes
61
+ JSON before asserting raises a parse error, which the admissibility rule
62
+ a few lines below rejects as a non-assertion failure, so the gate could
63
+ not accept the RED and P1c stopped. Routing resolves, the status
64
+ assertion fails on the predicate the row owns, and the RED is admissible.
65
+ If the contract genuinely uses that sentinel too, pick another status
66
+ outside its declared set — the requirement is that no assertion in this
67
+ row's selector can pass against the seam.
68
+
69
+ **Neutral, not empty.** The seam has to fail the row's predicate while
70
+ still satisfying what the selector needs to _reach_ it. An empty body
71
+ raises a parse error in a test that decodes JSON before asserting, and a
72
+ handler that throws does the same in a server that re-raises — both are
73
+ non-assertion failures
74
+ `../../qfai-implement/references/red-admissibility.md` rejects, so the row
75
+ cannot obtain an admissible RED at all. Return the status, headers and
76
+ body _shape_ the selector assumes, with only the contracted predicate
77
+ withheld.
78
+
79
+ 2. **With the scope approved (step 3), run the test.** An admissible failure is an assertion — or an
80
+ expected-status check — inside this row's own selector, naming the
81
+ predicate the row owns. Record the command and output as the row's RED
82
+ pair, **and the revision it was observed at** — `git rev-parse HEAD` for
83
+ a clean tree. An uncommitted tree is the ordinary case here, and it needs
84
+ a **content** address rather than a status one: `git status --porcelain`
85
+ names the changed paths and their states, so editing the very file under
86
+ test after the RED leaves the digest identical and a stale observation
87
+ reads as fresh. Record `working-tree+<content hash>` by the **one** procedure in
88
+ `../../qfai-implement/references/evidence-revision.md` — do not restate
89
+ it here — **the record shape least of all**: restated as
90
+ `path + NUL + blob hash` it fell behind the canonical's `kind` and `mode`,
91
+ and two spellings give a producer and a gatekeeper different addresses for
92
+ one tree. It excludes the ledger and `.qfai/evidence/**`, and a
93
+ producer hashing all of `git diff HEAD` instead got a different value from
94
+ the `qa-gatekeeper` reviewing the same tree — in the ordinary multi-row
95
+ loop, where the previous row's evidence is already written, the two
96
+ observations of one RED tree could not be matched up at all. **Not
97
+ `git stash create`** — it has no `-u`, so the tree it builds omits
98
+ untracked files, and a brand-new acceptance test is untracked in exactly
99
+ the case this address exists for.
100
+
101
+ **Record the test's own content hash as well.** The working-tree hash
102
+ covers everything at once, and Phase Green necessarily changes the
103
+ production files in it — so the reviewer cannot recompute it from the
104
+ final tree, and cannot tell "only production changed, as it should" from
105
+ "the acceptance test was edited after the handoff, so the RED is stale".
106
+ Record `RED test hash` alongside `RED revision`: a hash over the contents
107
+ of the files the row's **`Test file`** column names, plus the
108
+ acceptance-test-owned artifacts those files read — fixtures, snapshots,
109
+ expected-value JSON, test helpers. Not the production tree. Limiting it to
110
+ the test module let an edit to a snapshot or a fixture reshape the
111
+ assertion after the handoff with the hash unchanged, which is the same
112
+ stale-RED the field exists to catch; and since the working-tree hash cannot
113
+ be recomputed from the final tree, nothing else would have caught it.
114
+
115
+ **Record the manifest, not only the hash.** `RED test manifest` lists the
116
+ repo-relative path of every file that went into it, sorted, one per line —
117
+ and the hash is taken over `path + NUL + kind + NUL + mode + NUL + blob hash`
118
+ in that order, the same shape the revision manifest uses. `kind` and `mode`
119
+ are in it for the reason they are in that one, and more so here: after
120
+ Phase Green the original `RED revision` cannot be recomputed, so this hash
121
+ is the only thing still watching the test-owned artifacts — without them a
122
+ `chmod +x` on an acceptance script, or a file swapped for a symlink with
123
+ the same payload, changes how the test runs and moves nothing. Naming the _kinds_ of file is not enough:
124
+ the consumer recomputes this before GREEN, and two readers who choose
125
+ different sets get different values from an unchanged tree, so the gate
126
+ either loops or passes an edit it never looked at.
127
+
128
+ Not the `Selector` — that column is a test _name_ in the ordinary case
129
+ (`../../qfai-implement/references/checkpoint-verification.md` runs
130
+ `<Test file> -t '<Selector>'`), so keying the hash on it yields an empty
131
+ or guessed value and detects no edit at all. That hash **is** recomputable
132
+ later — Phase Green does not touch those files — so it is what makes the
133
+ freshness claim checkable rather than asserted.
134
+
135
+ **Both are recorded when observed, never reconstructed.**
136
+ `/qfai-implement` Phase Green changes the tree, and its completion gate
137
+ requires the handed-over RED to name the revision it was taken at
138
+ (`../../qfai-implement/references/evidence-revision.md`). A value worked
139
+ out afterwards is a guess, and a guess fails the freshness gate exactly as
140
+ a missing one does.
141
+
142
+ 3. **Scope approval — obtained before step 2 runs, listed here for the
143
+ contract it carries.** Take it first: this step requires a scope REVISE to
144
+ be settled _before_ the RED is submitted, and a REVISE changes the test or
145
+ its selector — so a RED recorded ahead of approval is evidence for a scope
146
+ that no longer exists, and its `RED test hash` addresses a file the
147
+ repair rewrites. Approve, then run.
148
+ `qfai-implement/SKILL.md` makes it the only authority on whether a
149
+ selector covers a sufficient slice of its obligation, and requires a scope
150
+ REVISE to be settled _before_ the RED is submitted. Approving the RED
151
+ first leaves the planner nothing but "keep the PASS and open a new row",
152
+ which cannot repair a handoff at the wrong granularity — the row has to be
153
+ split before its RED is taken, not after.
154
+ 4. **Submit that run to `qa-gatekeeper` (routing phase `red`) before any
155
+ production code exists, and wait for PASS.** `qfai-implement/SKILL.md`
156
+ requires an independent reviewer to confirm the RED while the surface is
157
+ still absent; a confirmation sought after it is built is post-hoc
158
+ self-attestation of a state nobody can re-observe. Record the verdict
159
+ beside the pair.
160
+ 5. **Stop there. Do not build the surface.** This skill owns acceptance
161
+ tests, not production code — `agent-routing.yml` gives its implementation
162
+ phase `acceptance-test-engineer` and no backend or frontend agent. The
163
+ surface is built by `/qfai-implement` Phase Green from this handover, and
164
+ the GREEN pair is recorded there. Branch 1's output is the RED pair, its
165
+ `qa-gatekeeper` PASS, and the `Oracle proof` plan.
166
+
167
+ Stage gate **P1b** is where steps 1-4 happen.
168
+
169
+ 2. **Falsifiability (the surface is there and the test passes on its first
170
+ run).** The usual shape when the surface predates this cycle, or this cycle
171
+ built it before the journey was written — branch 1's seam step was not taken,
172
+ or the work order sequenced surfaces first.
173
+
174
+ **Run the test before choosing this branch.** Surface existence is not the
175
+ condition; a first-run **pass** is. A surface that exists can still be wrong,
176
+ and a correct test against a buggy one fails naturally — that is an observed
177
+ RED, and the row belongs in branch 1 — **at its step 2**. Only step 1 is
178
+ skipped: the surface exists, so there is no seam to ask for. Steps 3 and 4
179
+ still run — `delivery-planner` still approves the slice before the RED is
180
+ confirmed, and `qa-gatekeeper` still passes it, because the handover table
181
+ requires that PASS on every `observed-red` entry. What the gatekeeper
182
+ confirms is not "no production code exists" but that the failure is an
183
+ assertion inside this row's selector, naming the predicate the row owns,
184
+ observed **against the tree before the fix**. Record that pair, get the
185
+ PASS, hand the fix to `/qfai-implement` Phase Green, and take the GREEN
186
+ from the corrected surface. Record the branch as `observed-red` with a note
187
+ that the surface existed and was wrong. Choosing branch 2 from existence alone sends a real,
188
+ legitimately observed defect to `exception` or to a stop, because the
189
+ mutation step cannot run against a test that is already failing and there is
190
+ no GREEN to restore to.
191
+
192
+ When it does pass: do **not** weaken it to manufacture a failure.
193
+
194
+ **The mutation is production code, so `/qfai-implement` applies it.** This
195
+ stage's `evidence` phase is `devops-ci-engineer` and `qa-gatekeeper`, and
196
+ neither owns production source — the same ownership boundary branch 1 step 5
197
+ states. Hand the row over naming the predicate to break: its Phase Red
198
+ **step 3c** applies the mutation, runs this row's selector, captures the
199
+ failure, reverts, and writes the trio into this row's entry here. The row
200
+ is not deferred waiting for evidence only that step can produce. Writing
201
+ the mutation here to "just take the evidence" is the breach the boundary
202
+ exists to prevent, and the alternative — stopping because no agent may
203
+ touch the file — sends a row with a perfectly good falsifiability story to
204
+ `exception`.
205
+
206
+ Use the shared path in
207
+ `../../qfai-implement/references/red-not-observable.md`: record `Satisfied-by`,
208
+ mutate the production predicate the journey asserts on, run this row's test
209
+ and confirm it fails, restore, and record `Falsifiability command` /
210
+ `Falsifiability result` beside the GREEN pair. `qa-gatekeeper` accepts this
211
+ form as the row's minimum evidence, and the row proceeds to `green` and
212
+ `done` normally.
213
+
214
+ **`Satisfied-by` takes whatever already implements the predicate.** The
215
+ shared reference names a sibling `TDD-NNNN` because that is its usual case,
216
+ but an ATDD surface often has none — a pre-existing route, or one this cycle
217
+ built outside the ledger. Record what actually satisfies it: a `TDD-NNNN`
218
+ when there is one, otherwise the production **path and symbol**
219
+ (`src/api/routes/evaluations.py::register`). What the field has to answer is
220
+ "what would I mutate to falsify this row", and a path and symbol answer it as
221
+ well as a row id does. **A commit id does not**, and is not an alternative
222
+ form: a commit that touches several routes and a helper names no single
223
+ predicate, so `qa-gatekeeper`'s boundary — owned code is the predicate
224
+ `Satisfied-by` names — cannot be applied to it, and it either REVISEs a
225
+ correct mutation or accepts an unrelated one. Add the commit alongside if it
226
+ helps whoever reads the row later; it does not stand in for the symbol.
227
+
228
+ **The row still moves `todo -> red -> green`.** Falsifiability _is_ the RED
229
+ for this row — `red-not-observable.md` says so for its own case and
230
+ `qa-gatekeeper` accepts it as the row's minimum evidence — so the mutation
231
+ run satisfies `todo -> red` and the restored passing run is the GREEN. There
232
+ is no `todo -> green` edge and none is needed. Hand the pair over in that
233
+ order, so `/qfai-implement` writes the same two transitions it writes for
234
+ any other row.
235
+
236
+ 3. **Neither is possible.** Only then is the row an `exception`, with a `DR-*`
237
+ naming what made both branches unavailable. An obligation with no persisted
238
+ form, or one genuinely unobservable at L5, belongs here — but "the surface
239
+ was built first in this same cycle" does not, because branch 1 or 2 covers
240
+ it.
241
+
242
+ Branch 3 is the last resort, not the default. A stage that routes every row it
243
+ owns to `exception` has not measured anything; it has recorded that it did not
244
+ try branches 1 and 2.
245
+
246
+ ## Evidence shape
247
+
248
+ Exactly one form per row, never both and never neither:
249
+
250
+ | Branch | Recorded |
251
+ | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
252
+ | Observed RED | Row identity (`Layer`, `Test file`, `Selector`) and the obligation reference the `Layer` selects (`TC-ref` / `US-ref` / `CON-API-ref`), RED command+result, `RED failure mode`, `RED revision`, **`RED test hash` and its manifest**, `qa-gatekeeper` PASS, the `Oracle proof` plan |
253
+ | Falsifiability | Row identity (as above), `Satisfied-by`, `Falsifiability command`, `Falsifiability result`, `RED failure mode: falsifiability`, **`RED test hash` and its manifest**, **`Falsifiability revision`**, **`qa-gatekeeper` PASS**, GREEN pair |
254
+ | `exception` | Row identity (`Layer`, `Test file`, `Selector`) and the obligation reference the `Layer` selects, recorded **before** P1d routes the gate — its audit subject is those plus the `DR-ID` and the DR artifact, so a row without them has nothing reproducible for `qa-gatekeeper` to hash. Then write `todo -> exception` with the `DR-*` the stage recorded; do not re-derive it, and do not enter Phase Green. |
255
+
256
+ `RED failure mode` is on both rows because the consumer's per-item contract
257
+ requires it before the reviewers run, and neither branch was recording it — an
258
+ otherwise correct ATDD-owned row reached the completion gate missing a mandatory
259
+ field. On an observed RED it is the kind the failure actually was
260
+ (`assertion` | `expected-error`); on branch 2 it is `falsifiability`, which is
261
+ what that form is.
262
+
263
+ Every branch carries the row identity and the obligation reference: the audit
264
+ subject hashes them and the gatekeeper judges before `/qfai-implement` can add
265
+ anything, so recorded later they move a stored hash and left out they can be repointed.
266
+
267
+ **Where each form lives.** The `## Ledger rows advanced` table is an index: one
268
+ row per `TDD-*`, holding the branch and an anchor. The commands and their output
269
+ go in that row's own `### TDD-NNNN` section, in fenced blocks. They cannot go in
270
+ a table cell: a GFM row is one physical line and a cell ends at every unescaped
271
+ `|`, so a multi-line run, a shell pipe or a regex alternation in the output
272
+ either truncates the proof or breaks every row below it
273
+ (`../../qfai-implement/references/execution-ledger.md#evidence-cell-contract`).
274
+
275
+ `qa-gatekeeper` requires an `Oracle proof` on **every** item — a named
276
+ production mutation that makes the test fail, or a recorded `equivalent-mutant`
277
+ — because a passing run does not show the test depends on the behaviour the row
278
+ owns. A natural RED is not a substitute: it shows the test failed before the
279
+ code existed, not that it discriminates once the code does. Branch 2 satisfies
280
+ this with the mutation it already performs; branch 1 names the mutation it
281
+ intends and `/qfai-implement` records the run at GREEN, when there is production
282
+ code to mutate.
283
+ Criteria: `../../qfai-implement/references/oracle-strength.md`.
284
+
285
+ The `Evidence` cell is a pointer; the payload lives in
286
+ `.qfai/evidence/atdd-<spec-id>.md` under `## Ledger rows advanced`
287
+ (`../../qfai-implement/references/execution-ledger.md#evidence-cell-encoding`).
288
+
289
+ ## Handover to /qfai-implement
290
+
291
+ `/qfai-implement` Phase Red step 3b routes an `E2E` / `API` row here instead of
292
+ through its own steps 4 and 5. Those steps re-run the test and watch it fail —
293
+ but by the time that skill reaches the row, the surface exists, so the run
294
+ passes and step 5 classifies it as an anomaly bound for `exception`. That is the
295
+ terminal state branch 2 exists to avoid, reached through the branch itself.
296
+
297
+ Read the row's entry and take the branch it names:
298
+
299
+ | Branch | What `/qfai-implement` does |
300
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
301
+ | `observed-red` | Verify the RED pair names this row's selector and the predicate it owns and that `qa-gatekeeper` passed it, write `todo -> red` from it, then run Phase Green normally — the surface does not exist yet, and building it is this skill's work. Do **not** re-run for a second RED. |
302
+ | `falsifiability` | If the trio is present, verify it and treat the mutation run as `todo -> red` with the restored run as GREEN. If it is not — the ordinary case, since only this skill owns the production code the mutation touches — Phase Red **step 3c** performs it and writes it here first. |
303
+ | `exception` | Write `todo -> exception` with the `DR-*` the stage recorded; do not re-derive it, and do not enter Phase Green. |
304
+
305
+ **A branch-2 row whose evidence is not written yet is not a stop, and not a defer either.** P1b fixes every row branch; the mutation needs production code this stage does not own, so `/qfai-implement` performs it at Phase Red step 3c and records it here. Treating the empty trio as a malformed handoff stopped the run on the first such row; deferring it left nobody able to produce the evidence, since the only phase with a production agent was waiting for it.
306
+
307
+ ## A shared test artifact outlives the row that recorded it
308
+
309
+ P1c closes one row before the next test is written, so a `done` row’s
310
+ `RED test manifest` addresses a fixture, snapshot or helper a later row may still
311
+ edit — and a `done` row has no re-entry edge of its own. Where those artifacts
312
+ are stabilised, what a later row that must edit one owes the rows that read it,
313
+ and how the resulting hash mismatch is cleared: `shared-test-artifacts.md`.
314
+
315
+ ## A spec with no ATDD-owned rows
316
+
317
+ `/qfai-sdd` Phase 2b seeds a ledger row per **coverage-target** `TC-*`, which
318
+ excludes `L4` / `L5`; `US-*` and `CON-API-*` are not row-producing
319
+ obligations there. A first run therefore finds **zero** `Layer = E2E` /
320
+ `Layer = API` rows, legitimately, and this stage cannot create them — it is
321
+ not the ledger's writer under any circumstance.
322
+
323
+ Zero is a count, not "nothing to do". The US and CON-API coverage obligations
324
+ are this skill's own (Success Criteria) and are discharged by the tests and
325
+ their annotations, not by ledger rows. Report the row count as zero with that
326
+ reason and carry on with the obligations.
327
+
328
+ **Do not raise it as a request for rows.** `/qfai-sdd` Phase 2b seeds one row
329
+ per coverage-target `TC-*`, and the ledger template says in as many words that
330
+ `US-*` and `CON-API-*` are not rows there — so the request returns nothing and
331
+ the spec is handed back and forth for rows no skill may write. Writing them
332
+ here is not the alternative either: that would make this stage a second writer
333
+ of a single-writer artifact. What the completion gate actually requires is
334
+ `QFAI-ATDD-111` / `QFAI-ATDD-113` clean, which the annotations discharge and
335
+ which this stage does own
336
+ (`../../qfai-implement/SKILL.md`, spec completion conditions).
337
+
338
+ ## A project without the `red` phase
339
+
340
+ `npx qfai init --force` regenerates `assistant/skills/**` and
341
+ `assistant/agents/**` but leaves `assistant/manifest/**` alone, so an existing
342
+ project can take this skill's update without the `red` phase it relies on — and
343
+ without the `agent-catalog.yml` role contracts the reviewers read. The gate
344
+ still applies. What is stale, why routing it by hand is not enough on its own,
345
+ and how to bring both files forward: `stale-manifest.md`.
346
+
347
+ ## What the nested run owes
348
+
349
+ P1c hands a branch-1 row to `/qfai-implement` and gets it to GREEN and its
350
+ checkpoint **before** P5 and P6; **P4b hands a branch-2 row over on the same
351
+ terms**, and it too sits before P5/P6, so both are covered by everything below.
352
+ Naming only P1c here left the falsifiability rows stopped at `refactor` by the
353
+ completion inputs their own stage had not produced yet. Either run is an **item
354
+ cycle**, not this spec's completion: its blocking reviewers judge the row's own RED/GREEN evidence, and
355
+ the completion-gate inputs — `.qfai/report/validate.log`, the coverage reports,
356
+ runtime evidence — are P5/P6 artifacts that do not exist yet and are not owed
357
+ here. **That applies to every blocking reviewer of the nested run, not only
358
+ `qa-gatekeeper`**: `completion-reviewer` is mandatory and blocking there too and
359
+ requires validate evidence, so exempting one and not the other left the first
360
+ branch-1 row stopped at the same gate for a different reason. In an item-cycle
361
+ invocation each of them judges the row's own phase-authored evidence and nothing
362
+ else (`../../../agents/qa-gatekeeper.md` and
363
+ `../../../agents/completion-reviewer.md`, the note above their completion-gate
364
+ inputs).
365
+
366
+ Requiring them would strand the first branch-1 row at `refactor`, which Phase
367
+ Red does not re-select, and P2 would never be reached — the gate blocking on
368
+ artifacts its own ordering produces later.
369
+
370
+ ## Branch 3 does not close a spec on its own
371
+
372
+ `exception` is a legal terminal status for a row and a legal outcome for this
373
+ stage. It is **not** a completion: `qfai-implement/SKILL.md` lists `exception`
374
+ as a blocking output and forbids declaring completion while one stands, unless
375
+ the row carries a **user-approved accepted-risk waiver** — a `TDDLIST-001` entry
376
+ in `.qfai/waivers.yml`.
377
+
378
+ So a branch-3 row ends in one of two places, and the stage has to say which:
379
+
380
+ - **the waiver is obtained** — user approval is a decision this stage asks for,
381
+ never one it makes. Raise it with the `DR-*` in hand: what could not be
382
+ observed, why neither branch was available, and what risk is being accepted;
383
+ - **the row is parked and the spec stays open** — recorded as such, not reported
384
+ as done.
385
+
386
+ Recording the `DR-*` and handing the row over discharges the _branch_. Treating
387
+ that as closing the spec leaves a spec that can never legally close, because
388
+ nothing later in the flow can produce the approval retroactively.
389
+
390
+ ## A `review-fix` row comes back here for a new RED
391
+
392
+ A reviewer's REVISE that asks for a change to the acceptance test returns the
393
+ row to this stage: `/qfai-implement` does not author those tests and its `red`
394
+ phase has no `acceptance-test-engineer`. What the corrected test owes — a fresh
395
+ RED when it fails, the no-round path plus a re-addressed manifest and a proof
396
+ marked stale when it passes, and where the round block goes — is in
397
+ `review-fix-rounds.md`.
398
+
399
+ ## Which stage hands a row over
400
+
401
+ All three branches are handed to `/qfai-implement`. None of them writes its own
402
+ ledger transition — that skill owns `Status` / `DR-ID` / `Evidence` for every
403
+ row — so a row `/qfai-atdd` never hands over stays at `todo` however complete
404
+ its work is. What differs is _when_, and a run consisting only of branch-2 or
405
+ only of branch-3 rows has to hand them over just as a branch-1 run does.
406
+
407
+ | Branch | Handed over | Why then |
408
+ | ---------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
409
+ | `observed-red` | P1c, one row at a time | The row ends with a deliberately failing test and no production code, and P5-P8 need a green suite. A second deliberate RED left open elsewhere fails the first row's checkpoint. |
410
+ | `falsifiability` | P4b, after P4 and before P6 | The trio is produced by Phase Red **step 3c**, the only step that runs the mutation, and the mutation needs the surface P2-P4 build. The trio is the row's RED payload, so P6 has nothing to capture and P8 nothing to judge until step 3c has run. |
411
+ | `exception` | P1d, once the `DR-*` is written | Only `/qfai-implement` can write `todo -> exception`. A run with no branch-1 row otherwise ends with the Decision Record recorded and the ledger untouched. |
412
+
413
+ A branch-2 row is _passed over_ by `/qfai-implement` when it is not the named
414
+ row — see the note above — which is neither a stop nor a defer of the branch:
415
+ P4b hands it over in its turn.
416
+
417
+ ### What each stage gate owes
418
+
419
+ **P1b — choose, for every row.** A row with no branch chosen is the one that
420
+ leaves P1b with no legal transition out of `todo`. **The choice is provisional
421
+ until the row's own handoff**: re-run the test against the tree as it stands
422
+ immediately before handing the row over and take the branch that result names.
423
+ An earlier branch-1 row's production code can satisfy a later row's predicate,
424
+ so a branch recorded at P1b as `observed-red` can have no observable RED left by
425
+ the time that row's turn comes.
426
+
427
+ **P1b and P1c are one loop per `TDD-ID`**, not two phases. P1c takes each row
428
+ through GREEN and its checkpoint before the next row's failing test is written;
429
+ completing every branch-1 RED in P1b first would leave several deliberate
430
+ failures open at once, and every row's checkpoint runs the full suite
431
+ (`../../qfai-implement/references/checkpoint-verification.md`). A second deliberate
432
+ RED left open elsewhere fails the first row's checkpoint — and that row is then
433
+ stranded at `refactor`, which Phase Red does not re-select.
434
+
435
+ **P1c — discharge branch 1, one row at a time.** Branch 1 ends with a
436
+ deliberately failing test and no production code, and this stage does not write
437
+ that code. P5-P8 require the suite and the repo quality gates to pass, which
438
+ the RED makes impossible, so the handover is not deferred to the end: run
439
+ `/qfai-implement` for the row now, let its Phase Green build the surface and
440
+ take the GREEN, and return with the tree green. Name the row in the handoff —
441
+ `/qfai-implement` passes over a branch-2 row sitting above it rather than
442
+ stopping, which is what keeps this round-trip from deadlocking against its own
443
+ P6.
444
+
445
+ **What the blocking `qa-gatekeeper` judges.** The `red` phase's gatekeeper
446
+ judges the rows that have evidence at P1b — the branch 1 ones. It cannot judge a
447
+ branch 2 row there: that row's payload is the falsifiability trio, which does
448
+ not exist yet by the same rule that lets the row leave P1b. A run whose rows are
449
+ all branch 2 passes P1b with nothing submitted, and its rows are gated when the
450
+ trio lands.
451
+
452
+ If the entry is absent, names no branch, or is malformed in any other way, the
453
+ row **stays at `todo`** and `/qfai-implement` **stops with a handoff note**.
454
+ Writing `red` first and discovering the gap afterwards parks a `red` row with
455
+ no RED behind it; inventing one for a test it did not author is a drift
456
+ violation, not a recovery.