pi-aia-asf 0.1.1 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.1] - 2026-08-14
11
+
12
+ ### Added
13
+
14
+ - **Scale-based flow.** Every ASF activation is now classified **small** or **large**:
15
+ - **Small** (small features, minor bugfixes, small refactors) — runs **automatically**: no intake question barrage (at most one clarifying question), no research, no adversarial gate, no PLAN.md, no approval. State the intent, capture specs silently, implement test-first, verify, deliver.
16
+ - **Large** (new projects, significant features, major bugfixes, architectural refactors) — full gated flow unchanged: intake → research → specs → adversarial → PLAN.md → **explicit approval** → implementation → verification.
17
+ - When in doubt, **default to small and start working**; re-classify upward if the work grows.
18
+ - **`/asf small`** command — starts a small session directly in implementation phase. `/asf status` now shows the scale (`automatic — no gates` for small).
19
+
20
+ ### Changed
21
+
22
+ - All gates (1–5) explicitly apply to large work only; Phase 2 (research) and Phase 5 (PLAN.md + approval) are skipped entirely for small work.
23
+ - References `01-intake`, `04-adversarial`, `05-plan` annotated with the scale rule.
24
+ - Anti-patterns: no question barrage or PLAN.md/approval demand for small work; when in doubt, start small.
25
+
26
+
27
+ ## [0.2.0] - 2026-08-14
28
+
29
+ ### Added
30
+
31
+ - **Mandatory testing & QA standard** (`references/06b-testing-qa.md`) — 11 rules distilled from real shipped-broken failures: test the packaged artifact (not just source), assert the observable end state, probe for silent failures, read the actual error before editing, clean-room verification against stale caches, a regression test for every bug fixed, test triggers *and* non-triggers, state-machine deadlock tests, mandatory browser testing for web surfaces, a definition-of-done checklist, and honest reporting.
32
+ - **`/asf verify`** — an explicit definition-of-done gate that itemises the 9 required checks, points at the QA standard, and forbids self-certifying unverifiable specs.
33
+
34
+ ### Changed
35
+
36
+ - Phase 6 and Phase 7 of the skill now require the QA standard; Phase 7 additionally requires verifying the packaged artifact and the observable end state, plus honest reporting of skipped or inconclusive checks.
37
+ - Anti-patterns extended: shipping without inspecting the packaged file list, treating "no error" as success, verifying against a stale install, guessing before reading the error, fixing without a regression test, and claiming assumed verification.
38
+
39
+ ### Fixed
40
+
41
+ - **`/asf-approve` rubber-stamped Gate 5.** It marked the plan approved even when no `PLAN.md` existed — approving a plan the user had never seen. It now refuses unless `PLAN.md` is present, and advances the phase to implementation on success.
42
+
43
+
10
44
  ## [0.1.1] - 2026-08-14
11
45
 
12
46
  ### Fixed
package/index.ts CHANGED
@@ -30,14 +30,30 @@ type AsfPhase =
30
30
  | "implementation"
31
31
  | "verification";
32
32
 
33
+ type AsfScale = "small" | "large";
34
+
33
35
  interface AsfState {
34
36
  workType?: "new-project" | "feature" | "major-bugfix" | "refactor";
37
+ scale?: AsfScale;
35
38
  phase: AsfPhase;
36
39
  planApproved?: boolean;
37
40
  startedAt?: string;
38
41
  updatedAt: string;
39
42
  }
40
43
 
44
+ /** Definition-of-done checks (references/06b-testing-qa.md, Rule 10). */
45
+ const QA_CHECKLIST: Array<{ key: string; label: string }> = [
46
+ { key: "build", label: "Typecheck/build passes" },
47
+ { key: "tests", label: "Full test suite green (not a subset)" },
48
+ { key: "regression", label: "Regression test added for every bug fixed this cycle" },
49
+ { key: "triggers", label: "Triggers AND non-triggers tested for conditional behavior" },
50
+ { key: "artifact", label: "Shipped artifact inspected (npm pack file list) + clean-room install" },
51
+ { key: "observable", label: "Observable end state verified as a user would experience it" },
52
+ { key: "browser", label: "Web surfaces exercised through a real browser (n/a if none)" },
53
+ { key: "specs", label: "Every MUST spec 'met' with concrete evidence" },
54
+ { key: "honest", label: "Skipped/inconclusive checks reported explicitly" },
55
+ ];
56
+
41
57
  interface ProjectStateFile {
42
58
  current: AsfState | null;
43
59
  history: Array<{ workType: string; phase: AsfPhase; startedAt: string; endedAt: string }>;
@@ -147,7 +163,7 @@ export default function register(pi: ExtensionAPI): void {
147
163
  // Startup check: warn once per session if deps are missing (unless disabled)
148
164
  // The extension loads at startup; log to console so it surfaces in logs.
149
165
 
150
- const setPhase = async (ctx: ExtensionCommandContext, phase: AsfPhase, workType?: AsfState["workType"]): Promise<string> => {
166
+ const setPhase = async (ctx: ExtensionCommandContext, phase: AsfPhase, workType?: AsfState["workType"], scale?: AsfScale): Promise<string> => {
151
167
  const project = projectName();
152
168
  const state = await loadState(project);
153
169
  const now = new Date().toISOString();
@@ -170,6 +186,7 @@ export default function register(pi: ExtensionAPI): void {
170
186
  };
171
187
  }
172
188
  if (workType) state.current.workType = workType;
189
+ if (scale) state.current.scale = scale;
173
190
  state.current.phase = phase;
174
191
  state.current.updatedAt = now;
175
192
  }
@@ -183,13 +200,15 @@ export default function register(pi: ExtensionAPI): void {
183
200
 
184
201
  switch (sub) {
185
202
  case "new":
186
- return await setPhase(ctx, "intake", "new-project");
203
+ return await setPhase(ctx, "intake", "new-project", "large");
187
204
  case "feature":
188
- return await setPhase(ctx, "intake", "feature");
205
+ return await setPhase(ctx, "intake", "feature", "large");
189
206
  case "bugfix":
190
- return await setPhase(ctx, "intake", "major-bugfix");
207
+ return await setPhase(ctx, "intake", "major-bugfix", "large");
191
208
  case "refactor":
192
- return await setPhase(ctx, "intake", "refactor");
209
+ return await setPhase(ctx, "intake", "refactor", "large");
210
+ case "small":
211
+ return await setPhase(ctx, "implementation", undefined, "small");
193
212
  case "status": {
194
213
  const project = projectName();
195
214
  const state = await loadState(project);
@@ -197,22 +216,40 @@ export default function register(pi: ExtensionAPI): void {
197
216
  return (
198
217
  `ASF status (${project}):\n` +
199
218
  ` work type: ${state.current.workType || "unset"}\n` +
219
+ ` scale: ${state.current.scale || "unset"}${state.current.scale === "small" ? " (automatic — no gates)" : ""}\n` +
200
220
  ` phase: ${state.current.phase}\n` +
201
221
  ` plan approved: ${state.current.planApproved ? "yes" : "no"}\n` +
202
222
  ` started: ${state.current.startedAt || "?"}\n` +
203
223
  ` history: ${state.history.length} completed session(s)`
204
224
  );
205
225
  }
226
+ case "verify": {
227
+ // Gate 7: force an explicit, itemised QA pass before delivery.
228
+ const project = projectName();
229
+ const state = await loadState(project);
230
+ if (!state.current) return "No active ASF session — nothing to verify.";
231
+ await setPhase(ctx, "verification");
232
+ return (
233
+ `ASF verification gate (${project}) — Definition of Done.\n` +
234
+ `Read references/06b-testing-qa.md. Confirm EACH item with concrete evidence\n` +
235
+ `(command output, file list, screenshot). Do not tick anything you did not run.\n\n` +
236
+ QA_CHECKLIST.map((c, i) => ` ${i + 1}. [ ] ${c.label}`).join("\n") +
237
+ `\n\nThen run get_task_specs and close every spec with update_spec_status.\n` +
238
+ `Unverifiable → 'partial' + ask the user. Never self-certify.`
239
+ );
240
+ }
206
241
  case "abort":
207
242
  return await setPhase(ctx, "none");
208
243
  default:
209
244
  return (
210
245
  "ASF commands:\n" +
211
- " /asf new — start a new software project\n" +
212
- " /asf feature — add a feature to an existing project\n" +
213
- " /asf bugfix — major bugfix\n" +
214
- " /asf refactor — architectural refactor\n" +
246
+ " /asf new — start a new software project (large, gated)\n" +
247
+ " /asf feature — add a feature to an existing project (large, gated)\n" +
248
+ " /asf bugfix — major bugfix (large, gated)\n" +
249
+ " /asf refactor — architectural refactor (large, gated)\n" +
250
+ " /asf small — small change, automatic (no gates)\n" +
215
251
  " /asf status — show current phase\n" +
252
+ " /asf verify — run the definition-of-done QA gate\n" +
216
253
  " /asf abort — end the current session\n\n" +
217
254
  dependencySummary()
218
255
  );
@@ -224,9 +261,25 @@ export default function register(pi: ExtensionAPI): void {
224
261
  const project = projectName();
225
262
  const state = await loadState(project);
226
263
  if (!state.current) return "No active ASF session — start one with /asf new|feature|bugfix|refactor.";
264
+
265
+ // Gate 5 must approve something that actually exists: refuse to rubber-stamp
266
+ // when no PLAN.md is present (a plan the user never saw cannot be approved).
267
+ const planPath = join(process.cwd(), "PLAN.md");
268
+ if (!existsSync(planPath)) {
269
+ return (
270
+ `No PLAN.md found in ${process.cwd()}.\n` +
271
+ "Gate 5 approves a written plan — write PLAN.md and present it to the user first."
272
+ );
273
+ }
274
+
227
275
  state.current.planApproved = true;
276
+ state.current.phase = "implementation";
228
277
  state.current.updatedAt = new Date().toISOString();
229
278
  await saveState(project, state);
230
- return "Plan approved ✓ — Gate 5 passed, implementation may begin.";
279
+ return (
280
+ "Plan approved ✓ — Gate 5 passed, implementation may begin.\n" +
281
+ "Test-first, strict codebase isolation, regression test per bug fixed.\n" +
282
+ "Run /asf verify before delivery."
283
+ );
231
284
  });
232
285
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-aia-asf",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Ai Applied Agentic Software Factory — codifies the full software development flow: intake, research, spec capture, adversarial analysis, planning with approval gates, test-first implementation, and release. Requires pi-vigilant, pi-smart-web-search, pi-smart-fetch, and pi-aia-browser.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -4,15 +4,17 @@ description: >-
4
4
  Agentic Software Factory — run a complete, disciplined software development
5
5
  cycle. Use when the user wants to start a NEW software project, add a
6
6
  SIGNIFICANT FEATURE to an existing project, perform a MAJOR BUGFIX, or do an
7
- ARCHITECTURAL REFACTOR. The flow classifies the work, asks questions until the
8
- intent is clear, researches SOTA and existing packages, captures hard
9
- specifications (via capture_spec, shared with pi-vigilant), runs adversarial
10
- analysis, produces a PLAN.md and gets explicit user approval, then implements
11
- test-first with strict codebase isolation and mandatory browser testing of any
12
- web interfaces (pi-aia-browser). Do NOT activate for simple Q&A, one-line
13
- fixes, casual conversation, content writing, or non-software tasks. When in
14
- doubt about whether work qualifies as a project/feature/bugfix/refactor, ask
15
- the user.
7
+ ARCHITECTURAL REFACTOR and also for SMALL software changes (small features,
8
+ minor bugfixes, small refactors), which run AUTOMATICALLY with no intake
9
+ questions, no PLAN.md, and no approval. LARGE work (new projects, significant
10
+ features, major bugfixes, architectural refactors) runs the full gated flow:
11
+ classify, ask until intent is clear, research SOTA and packages, capture hard
12
+ specifications (via capture_spec, shared with pi-vigilant), run adversarial
13
+ analysis, produce a PLAN.md and get explicit user approval, then implement
14
+ test-first with strict codebase isolation and mandatory browser testing of web
15
+ interfaces (pi-aia-browser). Do NOT activate for simple Q&A, one-line fixes,
16
+ casual conversation, content writing, or non-software tasks. When in doubt,
17
+ ask the user.
16
18
  ---
17
19
 
18
20
  # AIA Agentic Software Factory (ASF)
@@ -28,24 +30,35 @@ You are running the **Ai Applied Agentic Software Factory**. This skill codifies
28
30
 
29
31
  ## Phase 0 — Classify the work (gate)
30
32
 
31
- Determine the work type. If it is not ASF work, **do not run the factory** — just help normally.
33
+ Determine the work type **and scale**. If it is not ASF work, **do not run the factory** — just help normally.
32
34
 
33
- | Work type | ASF? |
34
- |---|---|
35
- | New software project | ✅ yes full flow |
36
- | Significant feature in an existing project | ✅ yes — full flow (research: medium depth) |
37
- | Major bugfix (multi-file, behavior change, needs tests) | ✅ yes lighter flow (research optional) |
38
- | Architectural refactor | ✅ yes full flow (research: low depth) |
39
- | Simple Q&A, one-liner fix, casual talk, docs-only | no |
40
- | Non-software tasks (LinkedIn, research-only, writing) | no |
35
+ | Work type | ASF? | Scale | Flow |
36
+ |---|---|---|---|
37
+ | New software project | ✅ | **large** | full flow |
38
+ | Significant feature | | **large** | full flow (research: medium) |
39
+ | Small feature | ✅ | **small** | automatic |
40
+ | Major bugfix (multi-file, behavior change, needs tests) | ✅ | **large** | lighter flow (research optional) |
41
+ | Minor bugfix (one area, no contract change) | | **small** | automatic |
42
+ | Architectural refactor | | **large** | full flow (research: low) |
43
+ | Small refactor (renames, restructure of one module) | ✅ | **small** | automatic |
44
+ | Simple Q&A, one-liner fix, casual talk, docs-only | ❌ | — | — |
45
+ | Non-software tasks (LinkedIn, research-only, writing) | ❌ | — | — |
46
+
47
+ **Scale rule — the core behavior difference:**
48
+
49
+ - **Large work** runs the full gated flow: intake questions → research → specs → adversarial → PLAN.md → **explicit approval** → implementation → verification.
50
+ - **Small work runs automatically**: no intake question barrage (at most ONE clarifying question, only if truly ambiguous), no research, no PLAN.md, no approval gate. State the intent in one or two sentences, capture specs, implement test-first, verify, deliver. Do not ask permission to start; do not stop for sign-off. If it turns out to be larger than expected mid-way, re-classify, say so, and switch to the full flow with approval.
51
+ - When in doubt about scale, **default to small and start working** — the user prefers action over questions. Re-classify upward if the work grows.
41
52
 
42
53
  If the user's request is ambiguous, **ask** before starting. State the classification explicitly:
43
- `ASF: <new-project|feature|major-bugfix|refactor> — starting Phase 1 (intake).`
54
+ `ASF: <new-project|feature|major-bugfix|refactor> <large|small> — starting Phase 1 (intake).`
44
55
 
45
56
  ---
46
57
 
47
58
  ## Phase 1 — Intake: ask until it's clear (gate)
48
59
 
60
+ > **Scale check — applies to LARGE work only.** For **small** work: skip the question bank. If the request is clear enough to act, state your understanding in one or two sentences and proceed immediately. Ask at most ONE clarifying question, and only when genuinely ambiguous.
61
+
49
62
  The factory **keeps asking until all is clear**. Never start planning or implementation on guesses.
50
63
 
51
64
  Minimum intake checklist (ask anything not yet known, one question at a time or a short batch):
@@ -60,12 +73,14 @@ Minimum intake checklist (ask anything not yet known, one question at a time or
60
73
 
61
74
  For each answer, **capture hard requirements immediately with `capture_spec`** (requirement, area, priority). Specs are the shared contract with pi-vigilant — it will re-verify them at the end.
62
75
 
63
- **Gate 1**: You may only leave intake when the user has confirmed the summary of intent (restate it back in 3–5 bullet points and ask "is this correct?").
76
+ **Gate 1** (large only): You may only leave intake when the user has confirmed the summary of intent (restate it back in 3–5 bullet points and ask "is this correct?"). Small work does not pass through this gate.
64
77
 
65
78
  ---
66
79
 
67
80
  ## Phase 2 — Research: SOTA and packages (adaptive depth)
68
81
 
82
+ > **Small work skips research entirely.** If implementation needs a library you don't know, a single quick search is enough — no research summary, no Gate 2.
83
+
69
84
  | Work type | Research depth |
70
85
  |---|---|
71
86
  | New project | **Mandatory, full** — SOTA approaches, frameworks, existing packages, reference implementations |
@@ -80,7 +95,7 @@ Research method (use `web_search` + `web_fetch`/`batch_web_fetch`):
80
95
  4. **Cite sources** in the research summary — every claim about a package/library gets a URL
81
96
  5. Summarize findings + a **recommendation** (which approach, which packages, with rationale)
82
97
 
83
- **Gate 2**: present the research summary + recommendation to the user. Ask: "proceed with this approach, or adjust?" Do not enter planning until the approach is agreed.
98
+ **Gate 2** (large only): present the research summary + recommendation to the user. Ask: "proceed with this approach, or adjust?" Do not enter planning until the approach is agreed.
84
99
 
85
100
  ---
86
101
 
@@ -94,12 +109,14 @@ Turn the intake answers + research into the authoritative spec set.
94
109
  4. Default priority is `must`; use `should` only when the user says "nice to have".
95
110
  5. Areas: functionality, ui-ux, performance, security, error-handling, testing, documentation, compatibility, constraints, format, data, deployment, other.
96
111
 
97
- **Gate 3**: show the full spec tree (`get_task_specs`) and get user sign-off: "specs correct — proceed to adversarial analysis?"
112
+ **Gate 3** (large only): show the full spec tree (`get_task_specs`) and get user sign-off: "specs correct — proceed to adversarial analysis?" Small work: capture specs silently, no sign-off needed.
98
113
 
99
114
  ---
100
115
 
101
116
  ## Phase 4 — Adversarial analysis (gate)
102
117
 
118
+ > **Small work:** skip the formal gate. Do a quick mental pass over edge cases and failure modes while implementing; if something real surfaces, fix it or capture a spec. No user checkpoint.
119
+
103
120
  Challenge the plan like a hostile reviewer before committing to it. For each spec and the overall design, ask and resolve:
104
121
 
105
122
  - **Edge cases** — empty input, zero users, max load, missing data, concurrency
@@ -112,12 +129,14 @@ Challenge the plan like a hostile reviewer before committing to it. For each spe
112
129
 
113
130
  For each finding: either capture a new spec, refine an existing one (supersede), or record the decision to accept the risk. **Ask the user about anything that changes scope.**
114
131
 
115
- **Gate 4**: summarize adversarial findings + resolutions, get user confirmation.
132
+ **Gate 4** (large only): summarize adversarial findings + resolutions, get user confirmation.
116
133
 
117
134
  ---
118
135
 
119
136
  ## Phase 5 — Plan + approval gate
120
137
 
138
+ > **Small work: SKIP this phase entirely.** No PLAN.md, no approval — go straight to Phase 6 (implementation).
139
+
121
140
  Write `PLAN.md` in the project root (repo root, or cwd if no repo). Structure:
122
141
 
123
142
  ```markdown
@@ -136,18 +155,28 @@ Write `PLAN.md` in the project root (repo root, or cwd if no repo). Structure:
136
155
 
137
156
  Keep the plan **implementation-ready**: any competent engineer (or agent) can execute the task list without re-deriving decisions.
138
157
 
139
- **Gate 5 — MANDATORY user approval**: present the plan and ask explicitly:
158
+ **Gate 5 — MANDATORY user approval (large only)**: present the plan and ask explicitly:
140
159
  > "Plan ready. Do you approve starting implementation? (yes / changes needed)"
141
160
 
142
- **Never start implementing before Gate 5 passes.** If the user says "go" without reading, still show the plan and confirm.
161
+ **Never start implementing before Gate 5 passes — for LARGE work.** If the user says "go" without reading, still show the plan and confirm. Small work never reaches this gate.
143
162
 
144
163
  ---
145
164
 
146
165
  ## Phase 6 — Implementation (test-first, disciplined)
147
166
 
167
+ > **Read `references/06b-testing-qa.md` before writing tests.** It is the mandatory QA
168
+ > standard, distilled from real shipped-broken failures. Non-negotiable highlights:
169
+ > **test the shipped artifact, not just the source** (inspect `npm pack` output);
170
+ > **assert the observable end state**, not intermediate files; **probe for silent
171
+ > failures** (a malformed manifest/frontmatter is skipped without any error);
172
+ > **read the actual error before editing**; **verify clean-room** (caches serve stale
173
+ > builds); **add a regression test for every bug fixed**.
174
+
148
175
  Execute the task list milestone by milestone. Discipline rules:
149
176
 
150
177
  1. **Test-first**: write/update tests before or with implementation; run them; only commit green.
178
+ Every bug fixed gets a **regression test** that fails on the old code. For conditional
179
+ behavior (skills, gates, auto-activation) test **triggers AND non-triggers**.
151
180
  2. **Codebase isolation**: work strictly inside the project's own codebase. Do NOT edit files in other repos, global config, or unrelated directories — **unless the user explicitly instructs otherwise**. If a change would touch another codebase, stop and ask.
152
181
  3. **No scope creep**: if something new is discovered that changes specs, capture it, ask the user, and update the plan before implementing.
153
182
  4. **Descriptive commits**: `git commit -m "type: specific description of what and why"` (e.g. `fix: verify specs before rotation`). No vague messages, no placeholders.
@@ -159,8 +188,17 @@ Execute the task list milestone by milestone. Discipline rules:
159
188
 
160
189
  ## Phase 7 — Verification & delivery (gate)
161
190
 
162
- 1. Run the full test suite; fix failures; re-run until green.
163
- 2. Run `get_task_specs` and verify **every spec** with `update_spec_status` + concrete evidence (test output, build result, code inspection). Unverifiable → `partial` + ask the user. Never self-certify.
191
+ Run the **Definition of Done checklist** in `references/06b-testing-qa.md` (Rule 10). Every box must hold.
192
+
193
+ 1. Run the full test suite (all of it, not a subset); fix failures; re-run until green.
194
+ 2. **Verify the artifact a user would actually get**: inspect the packaged file list
195
+ (`npm pack` → `tar tzf`), install/load it clean-room in a fresh dir with caches
196
+ cleared, confirm the installed version is the one just built, and confirm the
197
+ **observable end state** (the tool/skill/page actually appears and works) — not just
198
+ that files are in place. Any web surface must be exercised through `pi-aia-browser`.
199
+ 3. Run `get_task_specs` and verify **every spec** with `update_spec_status` + concrete evidence (test output, build result, code inspection). Unverifiable → `partial` + ask the user. Never self-certify.
200
+ 4. **Report honestly**: never claim a check you didn't run; state explicitly anything
201
+ skipped or inconclusive, and distinguish "tests pass" from "works for the user".
164
202
  3. If the project is a library/package that the user publishes (npm, GitHub release): **offer** to run the release (see `references/07-release.md`): version bump, CHANGELOG, git tag, push. **Publishing is always the user's decision** — never publish without explicit approval. Optionally offer to set up a CI/CD pipeline for publishing.
165
203
  4. Present a completion summary: what was built, specs met, tests passing, how to use it.
166
204
 
@@ -176,6 +214,15 @@ Execute the task list milestone by milestone. Discipline rules:
176
214
  - ❌ Vague commits or CHANGELOG placeholders
177
215
  - ❌ Declaring done while specs are still `open`
178
216
  - ❌ Publishing anything without the user's explicit go-ahead
217
+ - ❌ Shipping a package without inspecting the packaged file list (`npm pack`)
218
+ - ❌ Treating "no error" as "it worked" — malformed config is skipped **silently**
219
+ - ❌ Verifying against a cached/stale install, or with an old duplicate still present
220
+ - ❌ Guessing at a fix before reading the actual error message
221
+ - ❌ Fixing a bug without adding a regression test
222
+ - ❌ Claiming something was verified when it was assumed
223
+ - ❌ Asking a barrage of intake questions for small work — small runs automatically
224
+ - ❌ Writing PLAN.md / demanding approval for small work — that's the large-work gate only
225
+ - ❌ Waiting for sign-off when the work is small; when in doubt, default to small and start
179
226
 
180
227
  ## References
181
228
 
@@ -184,4 +231,5 @@ Execute the task list milestone by milestone. Discipline rules:
184
231
  - `references/04-adversarial.md` — adversarial checklist per area
185
232
  - `references/05-plan.md` — PLAN.md template with examples
186
233
  - `references/06-implementation.md` — coding discipline details
234
+ - `references/06b-testing-qa.md` — **mandatory testing & QA standard** (11 rules + definition of done)
187
235
  - `references/07-release.md` — release workflow (versioning, CHANGELOG, tags, npm, CI/CD)
@@ -1,5 +1,9 @@
1
1
  # Phase 1 — Intake: Question Bank
2
2
 
3
+ > **Scale note: this bank is for LARGE work.** Small work (small features, minor
4
+ > bugfixes, small refactors) skips the questions — state understanding in 1–2
5
+ > sentences and start. At most ONE clarifying question, only if genuinely ambiguous.
6
+
3
7
  Keep asking until the user confirms. One question at a time is fine; short batches (3–5) are faster. Do not proceed on guesses.
4
8
 
5
9
  ## Starter questions
@@ -32,3 +36,5 @@ Every concrete requirement the user states → `capture_spec` immediately, befor
32
36
  ## Intake gate
33
37
 
34
38
  Restate intent in 3–5 bullets, then ask: **"Is this correct?"** Only proceed on an explicit yes.
39
+
40
+ > Large work only. Small work has no intake gate.
@@ -1,5 +1,9 @@
1
1
  # Phase 4 — Adversarial Analysis Checklist
2
2
 
3
+ > **Scale note: the full checklist and gate apply to LARGE work.** Small work does
4
+ > a quick mental pass on edge cases and failure modes while implementing — no
5
+ > formal review, no user checkpoint.
6
+
3
7
  Challenge every spec and design decision like a hostile reviewer. For each item, determine: capture a new spec / supersede an existing one / accept the risk (recorded).
4
8
 
5
9
  ## Per-spec questions
@@ -1,5 +1,8 @@
1
1
  # Phase 5 — PLAN.md Template
2
2
 
3
+ > **Scale note: this phase is for LARGE work only.** Small work skips PLAN.md and
4
+ > the approval gate entirely — implement directly.
5
+
3
6
  Write `PLAN.md` in the project root. It must be executable by any competent engineer without re-deriving decisions.
4
7
 
5
8
  ```markdown
@@ -54,7 +57,7 @@ From adversarial analysis. Each risk: likelihood, impact, mitigation, owner.
54
57
  Explicitly cut items (so nobody re-adds them).
55
58
  ```
56
59
 
57
- ## Approval gate (MANDATORY)
60
+ ## Approval gate (MANDATORY — large work only)
58
61
 
59
62
  Present the plan and ask:
60
63
 
@@ -0,0 +1,146 @@
1
+ # Testing & QA Standard (MANDATORY)
2
+
3
+ These rules are distilled from real failures in production sessions (pi-vigilant,
4
+ pi-aia-asf, pi-aia-browser, conversense, betamaxx). Each rule exists because
5
+ skipping it **shipped a broken artifact**. They are not optional.
6
+
7
+ ---
8
+
9
+ ## Rule 1 — Test the ARTIFACT you ship, not the source you wrote
10
+
11
+ Source passing ≠ shipped thing working. The packaging layer is a real failure surface.
12
+
13
+ > **Real failure:** `pi-aia-browser` 0.1.0. All source tests passed. But `package.json`
14
+ > declared `"postinstall": "node scripts/install-browser.mjs"` while the `files`
15
+ > allowlist omitted `scripts/`. The published tarball had no such file → every
16
+ > `npm install` aborted with `MODULE_NOT_FOUND`. The package was **100% broken for
17
+ > every user** while every source test was green.
18
+
19
+ Required before declaring a package done:
20
+
21
+ ```bash
22
+ npm pack # or the equivalent build
23
+ tar tzf <pkg>-<ver>.tgz # inspect the ACTUAL file list
24
+ ```
25
+
26
+ - Verify every file the manifest/scripts reference is present in the list.
27
+ - Extract to a clean temp dir and load/run it from there.
28
+ - For anything installable: install it **from the registry/tarball**, not the repo.
29
+
30
+ ## Rule 2 — Assert the OBSERVABLE END STATE, not intermediate artifacts
31
+
32
+ "Files are in the right place" and "config is correct" do not prove the feature works.
33
+
34
+ > **Real failure:** the `aia-asf` skill. Files shipped correctly, `pi.skills` manifest
35
+ > correct, description under the length limit — all intermediate checks passed. But the
36
+ > YAML description contained an unquoted colon (`The flow is: classify...`), so the
37
+ > frontmatter failed to parse and pi **silently skipped the skill**. It was invisible to
38
+ > the agent even with an explicit `--skill` path.
39
+
40
+ Ask: *what would the user observe?* Then assert exactly that.
41
+
42
+ | Weak (intermediate) | Strong (observable) |
43
+ |---|---|
44
+ | SKILL.md exists, manifest lists it | Agent reports the skill as available |
45
+ | Extension file present | Tool appears in the tool list and executes |
46
+ | Server process running | Real request returns correct response |
47
+ | Config contains the key | Behavior driven by the key actually changes |
48
+
49
+ ## Rule 3 — Probe for SILENT failures
50
+
51
+ The worst bugs raise no error. Loaders skip malformed input; caches serve stale data.
52
+
53
+ - After any config/manifest/frontmatter change, **verify it parsed** (parse it yourself).
54
+ - Never treat "no error" as "it worked" — demand positive confirmation.
55
+ - Validate machine-read files with a real parser, not by eyeballing:
56
+
57
+ ```bash
58
+ python3 -c "import yaml,sys; yaml.safe_load(open(sys.argv[1]).read())" file.yaml
59
+ node -e "JSON.parse(require('fs').readFileSync('f.json','utf8'))"
60
+ ```
61
+
62
+ ## Rule 4 — Read the ACTUAL error before changing anything
63
+
64
+ > **Real failure:** on the `MODULE_NOT_FOUND` install error the first fix was a *guess*
65
+ > at the `files` array. It happened to be right, but the reinstall still failed and the
66
+ > real signal — `Cannot find module '.../scripts/install-browser.mjs'` plus a stale npm
67
+ > cache — was sitting in the log the whole time.
68
+
69
+ 1. Find and read the real error (log file, stderr, exit code).
70
+ 2. State the root cause in one sentence.
71
+ 3. Only then edit.
72
+
73
+ Never fix by pattern-matching on symptoms. Never retry unchanged and hope.
74
+
75
+ ## Rule 5 — Clean-room verification (defeat caches and local state)
76
+
77
+ Your machine lies: caches, stale installs, leftover globals, symlinks.
78
+
79
+ ```bash
80
+ npm cache clean --force
81
+ cd $(mktemp -d) && npm install <pkg>@<version> # fresh dir, explicit version
82
+ ```
83
+
84
+ - Verify the **installed version** is the one you just published.
85
+ - Remove/disable old copies first — a stale duplicate can serve your test and fake a pass.
86
+ - Confirm *which* copy answered (distinct log path, version string, marker).
87
+
88
+ > **Real failure:** a stale npm cache kept serving the broken 0.1.0 after 0.1.1 was
89
+ > published; the install kept failing with an error already fixed.
90
+
91
+ ## Rule 6 — Every fixed bug gets a REGRESSION test
92
+
93
+ A bug fixed without a test will return. For each fix, add an assertion that fails on
94
+ the old code and passes on the new one, and keep it in the permanent suite.
95
+
96
+ ## Rule 7 — Test triggers AND non-triggers
97
+
98
+ For anything conditional (skills, auto-activation, gates, hooks), correctness is
99
+ two-sided. Half a test suite hides half the bugs.
100
+
101
+ - **Triggers**: every case that must activate, activates.
102
+ - **Non-triggers**: every case that must NOT activate, stays silent (Q&A, one-liners,
103
+ casual talk, unrelated domains).
104
+ - **Boundaries**: the ambiguous cases — assert it asks rather than guesses.
105
+
106
+ ## Rule 8 — Test state machines for deadlock and bad transitions
107
+
108
+ > **Real failure:** pi-vigilant gated a write on "all specs resolved", but the cooldown
109
+ > suppressed that very write → permanent deadlock. Found only by simulating the full
110
+ > multi-turn sequence.
111
+
112
+ - Drive the real sequence of transitions, not one isolated call.
113
+ - Check terminal states are reachable, and no state can block its own exit.
114
+ - Test repeat/idempotent invocations and out-of-order calls.
115
+
116
+ ## Rule 9 — Browser testing is mandatory for any web surface
117
+
118
+ API/curl checks do not replicate what a human sees. Via `pi-aia-browser`:
119
+
120
+ 1. `browser_init`, `browser_navigate` to the running app
121
+ 2. Walk each key user journey with real clicks/typing
122
+ 3. Assert rendered DOM content (`browser_dom`), not just HTTP 200
123
+ 4. Check console errors via `browser_js`
124
+ 5. `browser_screenshot` for the record; check mobile + desktop viewports
125
+
126
+ A 200 response with a blank or broken page is a **failure**.
127
+
128
+ ## Rule 10 — Definition of done (all must hold)
129
+
130
+ - [ ] Typecheck/build passes
131
+ - [ ] Full test suite green (not a subset)
132
+ - [ ] Regression test added for every bug fixed this cycle
133
+ - [ ] Triggers **and** non-triggers tested for conditional behavior
134
+ - [ ] Shipped artifact inspected (`npm pack` file list) and installed clean-room
135
+ - [ ] Observable end state verified as a user would experience it
136
+ - [ ] Web surfaces exercised through a real browser
137
+ - [ ] Every MUST spec `met` with concrete evidence (`update_spec_status`)
138
+ - [ ] Unverifiable specs → `partial` + asked the user (never self-certified)
139
+
140
+ ## Rule 11 — Report honestly
141
+
142
+ - Never claim a test passed that you did not run.
143
+ - Never say "verified" for something inferred or assumed.
144
+ - If a check was skipped or inconclusive, **say so explicitly** and say why.
145
+ - Distinguish "tests pass" from "feature works for the user" — Rule 2.
146
+ - If you discover you shipped something broken, say it plainly and fix it first.