@massa-ai/cursor-plugin 1.35.0 → 1.35.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 (37) hide show
  1. package/.cursor-plugin/plugin.json +1 -1
  2. package/package.json +1 -1
  3. package/skills/massa-ai/references/agent-orchestration.md +4 -0
  4. package/skills/massa-ai/references/artifact-persistence.md +46 -0
  5. package/skills/massa-ai/references/audit-report-io.md +50 -0
  6. package/skills/massa-ai/references/brownfield-mapping.md +22 -0
  7. package/skills/massa-ai/references/codebase-investigation.md +1 -1
  8. package/skills/massa-ai/references/discrimination-sensor.md +42 -0
  9. package/skills/massa-ai/references/implementation-delivery.md +8 -3
  10. package/skills/massa-ai/references/knowledge-verification-chain.md +25 -0
  11. package/skills/massa-ai/references/maestro/cloud.md +2 -0
  12. package/skills/massa-ai/references/maestro/fact-ledger.md +2 -0
  13. package/skills/massa-ai/references/maestro/patterns.md +7 -1
  14. package/skills/massa-ai/references/mobile-figma-matcher/core.md +13 -0
  15. package/skills/massa-ai/references/spec-driven/artifact-store.md +2 -32
  16. package/skills/massa-ai/references/spec-driven/design.md +1 -1
  17. package/skills/massa-ai/references/spec-driven/validate.md +9 -31
  18. package/skills/massa-ai/references/verification-ladder.md +16 -0
  19. package/skills/massa-ai/scripts/check_fix_closure.ts +335 -0
  20. package/skills/massa-ai/scripts/check_specs_delivered.ts +61 -15
  21. package/skills/massa-ai/scripts/validate_audit_report.ts +2 -1
  22. package/skills/massa-ai/workflows/architecture/architecture-fix.md +29 -19
  23. package/skills/massa-ai/workflows/bugs/bugs-fix.md +27 -16
  24. package/skills/massa-ai/workflows/code-quality/code-quality-fix.md +34 -21
  25. package/skills/massa-ai/workflows/debug.md +42 -15
  26. package/skills/massa-ai/workflows/exploration.md +1 -16
  27. package/skills/massa-ai/workflows/feature.md +24 -4
  28. package/skills/massa-ai/workflows/general.md +26 -4
  29. package/skills/massa-ai/workflows/implementation/implementation-fix.md +23 -16
  30. package/skills/massa-ai/workflows/maestro/maestro-fix.md +23 -4
  31. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-fix.md +49 -16
  32. package/skills/massa-ai/workflows/refactor.md +32 -3
  33. package/skills/massa-ai/workflows/requirements/requirements-fix.md +29 -17
  34. package/skills/massa-ai/workflows/security/security-fix.md +28 -17
  35. package/skills/massa-ai/workflows/spec-driven.md +4 -21
  36. package/skills/massa-ai/workflows/tests/tests-fix.md +31 -17
  37. package/skills/massa-ai/references/spec-driven/brownfield-mapping.md +0 -16
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "massa-ai",
3
- "version": "1.35.0",
3
+ "version": "1.35.1",
4
4
  "description": "massa-ai — semantic code search, memory, and context compression for Cursor"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massa-ai/cursor-plugin",
3
- "version": "1.35.0",
3
+ "version": "1.35.1",
4
4
  "description": "massa-ai plugin for Cursor — semantic code search, memory, and context compression",
5
5
  "files": [
6
6
  "agents",
@@ -79,6 +79,10 @@ Plan Challenge `plan-critic` is a standing policy exception to the normal dispat
79
79
 
80
80
  For all other roles, preserve the normal delegation gates above.
81
81
 
82
+ ## Independent Verification Exception (fix workflows + Standard+ light-workflow tiers)
83
+
84
+ The Independent Verification Mandate in `references/verification-ladder.md` is a second standing policy exception, parallel to the Plan Challenge one: when a `*-fix` workflow closes a finding, or a light workflow (`debug`, `feature`, `general`, `refactor`) completes Standard+ work, always attempt the `massa-ai-verification-agent` dispatch when subagent tooling is available and platform policy permits spawning — it does not need to satisfy the ordinary dispatch triggers (file count, module count, explicit user delegation). Base packet-quality requirements still apply, and the mandate's own tier gates, security-fix unconditional rule, and fresh-eyes fallback live in that ladder section, not here.
85
+
82
86
  ## Name Resolution
83
87
 
84
88
  Charters live at `skills/agents/<role>/SKILL.md`. Hosts register every charter
@@ -0,0 +1,46 @@
1
+ # Artifact Persistence
2
+
3
+ Use before any workflow reads or writes durable `.specs/` artifacts. This file owns the canonical-store mechanics shared by every workflow family. Logical paths stay per-workflow-owned: spec-driven's table lives in `references/spec-driven/artifact-store.md`; other workflows declare their own paths inline (e.g. `.specs/debug/<slug>/REPORT.md`, `.specs/refactors/<slug>/{CHARACTERIZATION,PLAN,SENSOR}.md`, `.specs/quick/NNN-slug/`, `.specs/project/onboarding/{CONCERNS,TESTING}.md`).
4
+
5
+ ## Canonical Store
6
+
7
+ - Canonical state lives in `.specs/` files tracked in the repository, not massa-ai records, semantic memories, chat summaries, or root aliases.
8
+ - Current repository source remains authoritative for implementation/code evidence.
9
+ - `search`, `recall`, and durable memories may discover context, decisions, or reusable patterns, but must never reconstruct canonical artifact state.
10
+ - If `.specs/` is unavailable or not writable, **block** the workflow's durable-state mutation and record the blocker; do not fall back to memory or chat as a substitute store.
11
+
12
+ ## STATE Precedence Chain
13
+
14
+ Artifact reads resolve conflicts in this strict order (first match wins): fresh user instruction > approved `.specs/` artifact > STATE/HANDOFF > massa-ai memory. massa-ai memory and external summaries are discovery, not authority. In a repository with no `.specs/project/STATE.md`/`.specs/HANDOFF.md`, the chain simply has fewer links — the ordering is unchanged.
15
+
16
+ ## Quick Artifact Templates
17
+
18
+ Quick-sized tasks persist under `.specs/quick/NNN-slug/` — `NNN` zero-padded and sequential per project, `slug` the short kebab-case intent. Exactly two files:
19
+
20
+ **`.specs/quick/NNN-slug/TASK.md`:**
21
+
22
+ ```markdown
23
+ # Quick NNN: <one-line intent>
24
+
25
+ ## Acceptance
26
+ - <single testable criterion — the gate the Execute step must pass>
27
+ ```
28
+
29
+ **`.specs/quick/NNN-slug/SUMMARY.md`:**
30
+
31
+ ```markdown
32
+ # Quick NNN: <one-line intent>
33
+
34
+ ## Result
35
+ - Status: Complete | Blocked | Partial
36
+ - Files changed: <list or "none">
37
+ - Gate: <command + pass/fail evidence>
38
+ - SPEC_DEVIATION: <none | what diverged and why>
39
+ ```
40
+
41
+ Quick artifacts are canonical `.specs/` state — same precedence chain, same section-scoped write rules; they are not a second store. Deterministic backing: `bun skills/massa-ai/scripts/check_specs_delivered.ts <slug> --kind quick`.
42
+
43
+ ## Failure Handling
44
+
45
+ - `.specs/` directory missing or not writable: block the workflow's durable-state mutation; do not fall back to memory or chat.
46
+ - Required artifact missing: create it only through an approved first write; otherwise block and ask for direction.
@@ -75,6 +75,8 @@ In Plan Mode, do not write report files. Return the proposed canonical path and
75
75
 
76
76
  In Default mode, write the canonical report unless acting as a child lens returning compact findings to implementation audit.
77
77
 
78
+ The same rule covers Fix Closure Reports: in Plan Mode, return the proposed closure path and complete closure content instead of writing the file.
79
+
78
80
  ## Single-Lens Report Contract
79
81
 
80
82
  ```md
@@ -530,11 +532,58 @@ Implementation reports must preserve the exact parent scope packet and source-qu
530
532
 
531
533
  When implementation-audit uses SonarQube MCP, preserve the MCP availability result, project key or skipped-check reason, quality gate status when available, tool names used, and summarized issue/security-hotspot/measure evidence in Scope And Evidence. Sonar-derived findings are executable only after they are normalized to existing source-qualified IDs for Architecture, Correctness/Bugs, Code Quality, Security, or Tests; unmapped SonarQube output remains evidence only and does not enter Execution Handoff.
532
534
 
535
+ ## Fix Closure Report Contract
536
+
537
+ Every `*-fix` workflow persists its closure evidence as a Fix Closure Report, a sibling of the audit report it closes:
538
+
539
+ ```text
540
+ audits/<family>/<YYYY-MM-DD <family>-fix-closure>.md
541
+ ```
542
+
543
+ `<family>` is the source report's directory (`architecture`, `bugs`, `code-quality`, `security`, `requirements`, `tests`, `maestro`, `mobile-figma`, `implementation`). Same local-date and same-day suffix rules as audit reports. Closure reports are output artifacts, **never** audit-report input: any filename containing `-fix-closure` is excluded from latest-report selection.
544
+
545
+ Required header lines (same metadata style as audit reports):
546
+
547
+ ```md
548
+ # <Family> Fix Closure
549
+
550
+ Date: <YYYY-MM-DD>
551
+ Workflow: <family>-fix
552
+ ProjectId: <projectId>
553
+ WorkflowSessionId: <workflowSessionId>
554
+ Source Report: <exact path of the audit report consumed>
555
+ Finding Selector: <all | explicit finding IDs>
556
+ ```
557
+
558
+ Then a `## Closure Matrix` with one row per selected finding:
559
+
560
+ ```md
561
+ ## Closure Matrix
562
+
563
+ | Finding ID | Status | Changed Files | Command/Artifact | Result | Skipped Reason | Discrimination Sensor | Independent Verifier | Ladder Level | Validation Assets Protected | Residual Risk | Next Step |
564
+ |---|---|---|---|---|---|---|---|---|---|---|---|
565
+ ```
566
+
567
+ Row rules:
568
+
569
+ - **Finding ID**: verbatim from the source report (`PREFIX-N`, or `Area/PREFIX-N` for implementation reports).
570
+ - **Status**: `fixed | blocked | deferred | skipped` — terminal statuses only; a selected finding with no row is an incomplete closure.
571
+ - **Command/Artifact** and **Result**: the deterministic evidence per the Mandatory Verification Fix Gate. A `fixed` row must carry a real command/artifact and result — never an unfilled `<placeholder>`, `TBD`, or empty cell.
572
+ - **Skipped Reason**: `none` or one allowed skipped-check reason.
573
+ - **Discrimination Sensor**: killed/survived summary per `references/discrimination-sensor.md`, or `not available — <reason>`.
574
+ - **Independent Verifier**: verdict plus dispatch-or-fallback record per the verification-ladder Independent Verification Mandate.
575
+ - **Next Step**: required for `blocked` and `deferred` rows.
576
+
577
+ Family-specific extras (extra columns, parsed by header name, appended after the standard set): requirements adds `Linked .specs/ Requirement ID`; maestro and mobile-figma add `JUnit Report`, `Artifact Directory`, and `Device/Platform`.
578
+
579
+ Deterministic backing (run it, do not eyeball it): `bun skills/massa-ai/scripts/check_fix_closure.ts <closure.md> --family <family>` — a non-zero exit blocks Propose and the Evidence Gate. If no code-execution tool is available, run the same checks by reading the artifact (graceful degradation preserved).
580
+
533
581
  ## Execution Report Input
534
582
 
535
583
  Execution workflows read a saved markdown report before changing code. Establish:
536
584
 
537
585
  - Report selector: exact path, `latest`, or omitted.
586
+ - Delivery authorization is scoped **per execution run** (the report + finding selector named at Execute start), not per finding — one go-ahead covers every selected finding's local commits through PR creation. Force-push, deploy, and merge stay separately gated per `references/implementation-delivery.md` Stage 3/7.
538
587
  - Target focus: module, flow, files/globs, branch comparison, commit range, PR target, symbol/class/function, feature/screen, modified files, or explicit whole-repository target.
539
588
  - Finding selector: optional workflow IDs or source-qualified implementation IDs.
540
589
 
@@ -542,6 +591,7 @@ If a path is supplied, use it and validate it against any stated focus. For `lat
542
591
 
543
592
  Select the latest matching report by:
544
593
 
594
+ 0. Exclude any filename containing `-fix-closure` — closure reports are outputs, not audit reports.
545
595
  1. Highest `YYYY-MM-DD` parsed from matching filenames.
546
596
  2. Most recent mtime as tie-breaker.
547
597
  3. Lexicographically last path if still tied.
@@ -0,0 +1,22 @@
1
+ # Brownfield Onboarding — 7-Doc Codebase Mapping
2
+
3
+ Use when the target codebase has not yet been mapped (brownfield, new repo,
4
+ or cold project). The map is the shared factual ground for requirements,
5
+ design, task derivation, and gate-command discovery; each doc feeds a
6
+ downstream phase or verification step.
7
+
8
+ | Doc | Derives | Feeds |
9
+ | --- | --- | --- |
10
+ | `STACK.md` | languages, runtimes, frameworks, key libraries | Design constraints, verification commands |
11
+ | `ARCHITECTURE.md` | layers, modules, boundaries, data flow | Design, risk surface |
12
+ | `CONVENTIONS.md` | naming, file layout, commit/test conventions | Tasks, Execute |
13
+ | `STRUCTURE.md` | directory map, where new code goes | Tasks, file placement |
14
+ | `TESTING.md` | test runner, how to run gates, coverage tooling | Gate Check Commands, verification recipe |
15
+ | `INTEGRATIONS.md` | external services, APIs, contracts, auth | Discuss, risk escalation |
16
+ | `CONCERNS.md` | known risks, tech debt, migration landmines, security/privacy hotspots | Risk-domain escalation, validation focus |
17
+
18
+ ## Minimum Bar
19
+
20
+ Derive at least **`CONCERNS.md`** (risk surface — drives risk-domain escalation and validation focus) and **`TESTING.md`** (gate derivation — the exact commands the workflow's verification gate will run). When time or access is constrained, these two are non-negotiable; the other five are derived as the work needs them. Confirm the map against current source, not memory or external summaries.
21
+
22
+ Output path: spec-driven work records the map under `.specs/features/<slug>/`; every other workflow records it under `.specs/project/onboarding/` (`CONCERNS.md`, `TESTING.md`).
@@ -40,7 +40,7 @@ Prefer sources in this order:
40
40
  than exact source.
41
41
  7. Local `.notebook/INDEX.md` only if the project already uses `.notebook/`.
42
42
  8. Focused shell search/read fallback when massa-ai is unavailable, stale, incomplete, or unindexed.
43
- 9. Official docs or web search only when current external API behavior matters.
43
+ 9. External sources only when current external library/API behavior matters — and then strictly through the ordered chain in `references/knowledge-verification-chain.md` (project docs → Context7 MCP → web search → flag-as-uncertain, unavailable steps recorded as skipped sensors).
44
44
 
45
45
  Project maps, search results, and optimized context are leads until confirmed
46
46
  against source files read in the current session or returned with current
@@ -0,0 +1,42 @@
1
+ # Discrimination Sensor
2
+
3
+ Use when a workflow must prove its validation can actually detect wrong behavior — the empirical guarantee that tests discriminate, not merely pass. The sensor injects behavior-level faults in an isolated scratch state and confirms the covering tests kill them. The real working tree is never modified.
4
+
5
+ ## Mutation Target
6
+
7
+ The mutation target is always **the code under the claim being verified** — a correctness requirement, not a style choice:
8
+
9
+ | Claim being verified | What to mutate |
10
+ |---|---|
11
+ | New behavior matches spec/ACs (spec-driven, feature) | The new code introduced by the change |
12
+ | Behavior preservation (refactor, code-quality) | The *moved or transformed* code — the pre-existing behavior the characterization tests must protect, not new code |
13
+ | A guard blocks the exploit (security) | The specific guard just added — invert it and confirm the negative test kills it |
14
+ | A new or repaired test catches its bug (tests family) | The new/repaired test's subject code |
15
+
16
+ ## How It Works
17
+
18
+ 1. **Prepare an isolated scratch.** Never mutate the real worktree. Choose one:
19
+ - Preferred: a temporary git worktree (`git worktree add <scratch-path> HEAD`), mutate and run tests there, then `git worktree remove --force <scratch-path>`. Name the scratch `<worktree>-sensor-<finding-id>` (or `<worktree>-sensor-<slug>`) so it never collides with the delivery worktree.
20
+ - Fallback (no git / worktree unavailable): copy only the affected file(s) to a temp directory, mutate the copies, point the test runner at those copies (or restore originals from the copies' backups), then delete the temp directory.
21
+ - **Forbidden:** `git stash` / `git stash pop`. A stash records state *before* the mutation; popping it does not reverse a mutation applied afterward, and on a clean tree `git stash` creates no entry at all — so the fault is left in the real worktree.
22
+ 2. **Capture a baseline.** Record `git status --porcelain` (or equivalent) of the real worktree *before* any sensor work. It must be unchanged after cleanup.
23
+ 3. **Inject a behavior-level fault** into the scratch copy of the target code. Choose a mutation proportional to the code's risk:
24
+ - Flip a boolean condition (`if (x)` → `if (!x)`, `>` → `>=`)
25
+ - Change a return value (return a wrong status code, wrong field, zero instead of a computed value)
26
+ - Off-by-one (shift a loop bound, change a slice index)
27
+ - Remove a required side effect (delete a method call that the spec requires)
28
+ 4. **Run the tests** that cover the mutated code (against the scratch), using the workflow's gate command.
29
+ 5. **Confirm the mutant is killed** (tests FAIL). Discard the scratch (remove worktree or delete temp copies).
30
+ 6. **Verify isolation.** Re-run `git status --porcelain` on the real worktree and confirm it matches the baseline from step 2. If it differs, STOP — restore the real tree before continuing, and treat the sensor run as invalid.
31
+ 7. **If a mutant survives** (tests still pass after the fault), the tests are not discriminating for that behavior. Consequence by workflow family: spec-driven/feature create a **fix task** to strengthen the assertion; fix workflows record the finding's closure row as **`blocked`** (unproven verification) and emit the `surviving_mutant` lessons signal.
32
+
33
+ ## Tiering (proportional, not optional)
34
+
35
+ | Context | Sensor depth |
36
+ | ------- | ------------ |
37
+ | Default | Lightweight fault-injection: 1–3 targeted behavior-level mutations, focused on the highest-risk target code |
38
+ | P0 / critical paths (payment, auth, data integrity) | Full mutation run: use language-appropriate mutation tooling if available (e.g., Stryker, mutmut, cargo-mutants, pitest); otherwise increase the number of manual fault-injection mutations to ≥5 covering all branches |
39
+
40
+ **Stack-agnostic:** the sensor targets behavior-level semantics (what the code does), not a specific tool. Any language, any framework.
41
+
42
+ **Report:** record killed/survived for each mutation attempt, plus the sensor depth used. If a safe reversible mutant cannot be made, record why and mark the claim `Blocked` unless equivalent existing deterministic mutation evidence proves discrimination.
@@ -61,9 +61,12 @@ worktree was never provisioned is an environment failure; say so rather than
61
61
  reporting it as a code failure.
62
62
 
63
63
  **Phased work — one branch per Phase/Wave.** When the work is phased (sourced
64
- from `workflows/ticket.md`, a spec-driven `tasks.md` with Phases/Waves, or a TDD
65
- PR-group table), create **one branch per Phase/Wave**, not one branch per task
66
- and not one branch for the whole feature. Name the branch with the phase's Jira
64
+ from `workflows/ticket.md`, a spec-driven `tasks.md` with Phases/Waves, a TDD
65
+ PR-group table, or a `references/pr-task-fix.md` PR-group split), create
66
+ **one branch per Phase/Wave**, not one branch per task
67
+ and not one branch for the whole feature. All Phases/PR groups of one feature
68
+ share that feature's single Stage 3 delivery authorization — one go-ahead
69
+ covers every group's commits, pushes, and PR creation. Name the branch with the phase's Jira
67
70
  Task key, e.g. `feat/<PHASE-KEY>-<slug>` (so `feat/SA-100-phase-1-search-split`
68
71
  for phase SA-100). The phase key comes from `workflows/ticket.md` or the user.
69
72
  Each Task inside the phase is then one atomic commit on that branch, prefixed
@@ -89,6 +92,8 @@ Between Push and Propose, all feature `.specs/` artifacts (`spec/context/design/
89
92
 
90
93
  **Nominal path: this stage should never fire.** The feature's own close-out task (the last task before delivery — see `workflows/spec-driven.md` step 7) commits `.specs/` updates **before** the first push, so stage 3.5's remediation is a defensive fallback for the rare case something slipped through, not the normal place `.specs/` gets committed. On failure: commit the missing `.specs/` updates (a `docs(specs):`-type commit is normal), push, re-run this stage. No commits may land between the close-out commit and PR creation.
91
94
 
95
+ **Kind variants.** `check_specs_delivered.ts` takes `--kind feature|quick|debug|refactor` (default `feature`, the behavior above): `quick` gates `.specs/quick/<slug>/` `TASK.md`+`SUMMARY.md`, `debug` gates `.specs/debug/<slug>/REPORT.md`, `refactor` gates `.specs/refactors/<slug>/CHARACTERIZATION.md` (plus `PLAN.md`/`SENSOR.md` when present) — none of the non-feature kinds require the project STATE files. The fix-family analogue of this stage is `bun skills/massa-ai/scripts/check_fix_closure.ts <closure.md> --family <family>` (Fix Closure Report Contract in `references/audit-report-io.md`). Neither gate fires for a workflow run with no durable artifact in scope.
96
+
92
97
  ### Stage 4 — propose carries the phase key prefix
93
98
 
94
99
  The PR/MR is created with `gh pr create --base <base> --title <t> --body <b>`.
@@ -0,0 +1,25 @@
1
+ # Knowledge Verification Chain
2
+
3
+ Use when researching, designing, or making any technical decision whose answer depends on external library/API behavior, unfamiliar patterns, or facts not already verified in this session. Follow this chain in strict order. Never skip steps.
4
+
5
+ ```
6
+ Step 1: Codebase → existing code, conventions, patterns already in use
7
+ Step 2: Project docs (leads, not truth) → README, docs/, inline comments, and, when present, .specs/project/STATE.md (Decisions) — verify against current source before relying
8
+ Step 3: Context7 MCP → resolve library ID, then query for current API/patterns
9
+ Step 4: Web search → official docs, reputable sources, community patterns
10
+ Step 5: Flag as uncertain → "I'm not certain about X — here's my reasoning, but verify"
11
+ ```
12
+
13
+ - If a chain step's tool is unavailable (Context7 MCP not registered, no web
14
+ access), record it as a skipped sensor with its reason and continue to the next
15
+ step. An unavailable step is skipped, never silently treated as answered.
16
+ - Never skip to Step 5 if Steps 1-4 are available.
17
+ - Step 5 is always flagged uncertain — never presented as fact.
18
+ - Never assume or fabricate. If no answer is found, say "I don't know" or "I couldn't find documentation for this". Uncertainty is always preferable to fabrication; invented APIs/patterns cause cascading failures across design → tasks → implementation.
19
+
20
+ Step 2 reads whatever project documentation the target repository actually has; a consumer running without `.specs/` (a Quick-mode refactor, a cold repository) simply has fewer Step 2 sources, not a skipped step.
21
+
22
+ ## Family Instantiations
23
+
24
+ - **Requirements family:** the audit report's cited Requirement Source may be treated as Step 0 — the authoritative anchor the rest of the chain verifies implementation facts against. Step 0 answers *what was required*; Steps 1-5 still govern *how the code behaves*.
25
+ - **Maestro:** `references/maestro/fact-ledger.md`'s Authority Order is the Maestro instantiation of this chain (official-doc → live-help → repo-convention → excluded/unverified). Do not layer the generic chain on top of it.
@@ -65,3 +65,5 @@ Official Cloud limit: 15-minute soft execution limit per test execution. After t
65
65
  ## Cloud Boundary
66
66
 
67
67
  Use Cloud for hosted device execution, device matrix coverage, PR checks, and Cloud-only platform settings. Keep local CLI checks, static YAML checks, and repository validation as separate evidence.
68
+
69
+ Authorization boundary: Cloud execution, binary upload, and `maestro test --analyze` are externally-visible operations — each needs its own explicit go-ahead, separate from the Execute authorization. Local `maestro test` against a local device/emulator stays inside the Execute authorization.
@@ -11,6 +11,8 @@ Use before making Maestro claims. Defines source authority, fact tags, local tra
11
11
 
12
12
  If sources conflict, prefer `official-doc` for product behavior and `live-help` for installed CLI syntax. Mention version drift when `live-help` differs from docs.
13
13
 
14
+ This Authority Order is the Maestro instantiation of `references/knowledge-verification-chain.md` — `live-help` supersedes generic lookup for installed CLI facts; do not layer the generic chain on top of it.
15
+
14
16
  ## Fact Tag Rules
15
17
 
16
18
  Every normative statement in Maestro workflows, reports, or implementation notes must carry a source class in the agent's working notes:
@@ -71,10 +71,16 @@ If cleanup cannot be guaranteed, isolate test data and record residual risk.
71
71
  - changed files
72
72
  - command/artifact evidence
73
73
  - skipped reason or `none`
74
- - JUnit/artifact paths
74
+ - JUnit/artifact paths — cite the **on-disk** JUnit report path and artifact directory the run actually produced, never a remembered or expected path
75
75
  - validation assets protected
76
76
  - residual risk
77
77
 
78
+ ## Discrimination Sensor (Flow Mutation)
79
+
80
+ The Maestro instantiation of `references/discrimination-sensor.md`: mutate a **scratch copy** of the flow under the claim being verified — perturb a selector (point it at a wrong element) or an assertion (invert or change its expected value) — and confirm the run fails. A run that still passes with a perturbed selector/assertion is not discriminating for that behavior.
81
+
82
+ Deviation from the generic tier table, stated on purpose: device-backed runs are expensive, so the sensor is a **single lightweight mutation only** — the ≥5-mutation P0 tier does not apply to Maestro flows. Record killed/survived and restore the scratch per the shared reference's isolation rules.
83
+
78
84
  ## Routing Boundaries
79
85
 
80
86
  - Product bugs, missing test IDs, app architecture changes, backend data setup changes, or unclear requirements route to parent workflows.
@@ -9,6 +9,7 @@ Use after `repository-detection.md` identifies one or more target surfaces. Defi
9
9
  - Figma MCP is mandatory design evidence. A screenshot or pasted description alone is not a design contract.
10
10
  - Figma defines visible design intent and represented variants. Product behavior, navigation, data, analytics, error handling, and state transitions require a separate requirements source.
11
11
  - Accessibility, platform conventions, localization, safe areas/insets, minimum touch targets, Dynamic Type/font scale, and explicit product requirements outrank literal replication when supported by evidence. Record these as `CONSTRAINT DEVIATION`.
12
+ - Figma defines the target **value**; it never defines the platform-API **technique**. The `references/knowledge-verification-chain.md` chain answers "how do I express this on the platform"; a fresh Figma node re-read answers "what value must render". Never let a platform-API lookup redefine the design contract.
12
13
 
13
14
  ## Figma Evidence Packet
14
15
 
@@ -96,6 +97,18 @@ Evidence classes:
96
97
  - `inferential-visual`: labeled visual comparison without deterministic measurement.
97
98
  - `missing`: required evidence is unavailable or unsafe to obtain.
98
99
 
100
+ ### Discrimination Sensor for Visual Parity (what a mutation is)
101
+
102
+ The mobile-Figma instantiation of `references/discrimination-sensor.md` — mutations run only where a deterministic runtime sensor exists to kill them:
103
+
104
+ | Evidence class of the row | Mutation | Expectation |
105
+ |---|---|---|
106
+ | `deterministic-runtime` | Perturb the implementation's token/value in a scratch copy (wrong color token, ±2dp spacing, wrong font scale) | The runtime sensor (snapshot/screenshot/render test) FAILS — mutant killed |
107
+ | `deterministic-source` only | No runtime kill-check exists | Record `mutation: not available — no deterministic-runtime sensor for this row` |
108
+ | `inferential-visual` / `missing` | Never mutate | Record `mutation: not available — <evidence class>` |
109
+
110
+ A surviving token/value mutant means the render sensor does not discriminate for that property — the parity claim for that row is unproven.
111
+
99
112
  Statuses:
100
113
 
101
114
  - `MATCH`: sufficient evidence supports parity for the row and configuration.
@@ -4,14 +4,7 @@ Use before any spec-driven workflow reads or writes feature registry, progress,
4
4
 
5
5
  ## Source Of Truth
6
6
 
7
- - Canonical state lives in `.specs/` files tracked in the repository, not massa-ai records, semantic memories, or root aliases.
8
- - Current repository source remains authoritative for implementation/code evidence.
9
- - `search`, `recall`, and durable memories may discover context, decisions, or reusable patterns, but must never reconstruct canonical artifact state.
10
- - If `.specs/` is unavailable or not writable, block spec-driven state mutation and record the blocker.
11
-
12
- ## STATE Precedence Chain
13
-
14
- Artifact reads resolve conflicts in this strict order (first match wins): fresh user instruction > approved `.specs/` artifact > STATE/HANDOFF > massa-ai memory. massa-ai memory and external summaries are discovery, not authority. Canonical ownership and full section rules live in `references/spec-driven/memory.md`; this store mirrors the chain so reads and writes stay consistent.
7
+ The canonical-store principle, the STATE Precedence Chain, and the unwritable-→-block rule live in `references/artifact-persistence.md` — they apply to every workflow family, not just spec-driven. This store applies them to spec-driven's logical paths below. Canonical ownership and full section rules live in `references/spec-driven/memory.md`.
15
8
 
16
9
  ## Logical Paths
17
10
 
@@ -31,30 +24,7 @@ Use these logical paths:
31
24
 
32
25
  ## Quick Artifacts
33
26
 
34
- Quick-mode tasks (Quick mode guardrails in `workflows/spec-driven.md`) live under `.specs/quick/NNN-slug/`. `NNN` is zero-padded and sequential per project; `slug` is the short kebab-case intent. Each quick task has exactly two files:
35
-
36
- **`.specs/quick/NNN-slug/TASK.md`:**
37
-
38
- ```markdown
39
- # Quick NNN: <one-line intent>
40
-
41
- ## Acceptance
42
- - <single testable criterion — the gate the Execute step must pass>
43
- ```
44
-
45
- **`.specs/quick/NNN-slug/SUMMARY.md`:**
46
-
47
- ```markdown
48
- # Quick NNN: <one-line intent>
49
-
50
- ## Result
51
- - Status: Complete | Blocked | Partial
52
- - Files changed: <list or "none">
53
- - Gate: <command + pass/fail evidence>
54
- - SPEC_DEVIATION: <none | what diverged and why>
55
- ```
56
-
57
- Quick tasks are also listed in the STATE.md Quick Tasks table (see `references/spec-driven/memory.md`). When 5+ quick tasks accumulate in one area, promote to a feature: move the work under `.specs/features/<slug>/` and record the promotion in STATE. Quick artifacts are canonical `.specs/` state — same precedence chain, same section-scoped write rules; they are not a second store.
27
+ Quick-mode tasks (Quick mode guardrails in `workflows/spec-driven.md`) live under `.specs/quick/NNN-slug/` with the two-file templates in `references/artifact-persistence.md` (Quick Artifact Templates). Spec-driven specifics on top: quick tasks are also listed in the STATE.md Quick Tasks table (see `references/spec-driven/memory.md`), and when 5+ quick tasks accumulate in one area, promote to a feature — move the work under `.specs/features/<slug>/` and record the promotion in STATE.
58
28
 
59
29
  ## Reading Artifacts
60
30
 
@@ -41,7 +41,7 @@ Silently ignoring an active decision is not an option — it creates invisible i
41
41
 
42
42
  If the feature involves unfamiliar technology, patterns, or integrations, research before designing. Document findings briefly in the design doc or as inline notes. This prevents incorrect assumptions from propagating into tasks.
43
43
 
44
- Follow the **Knowledge Verification Chain** (see SKILL.md) in strict order:
44
+ Follow the **Knowledge Verification Chain** (see `references/knowledge-verification-chain.md`) in strict order:
45
45
 
46
46
  ```
47
47
  Codebase → Project docs (leads, not truth) → Context7 MCP → Web search → Flag as uncertain
@@ -17,7 +17,7 @@ Use for the mandatory final Execute validation gate. This is not a separate phas
17
17
  - Runs the **spec-anchored outcome check** and the **discrimination sensor** (both described below)
18
18
  - Writes `.specs/features/<slug>/validation.md` with the full evidence report
19
19
  - Returns a compact verdict + ranked gap list to the orchestrator in chat
20
- - Gaps become **fix tasks** routed back to an implementer; re-verification follows with a maximum of **3 fixre-verify iterations** before escalating to the user
20
+ - Gaps become **fix tasks** routed back to an implementer; re-verification follows, bounded by the Bounded FixRe-verify Loop in `references/verification-ladder.md`
21
21
 
22
22
  3. **Interactive UAT (for user-facing features only):** The feature has complex user-facing behavior where human judgment matters (UI flows, interaction patterns, visual design). For backend-only, harness-only, or infrastructure work, automated checks are sufficient — record `UAT: not applicable` with reason.
23
23
 
@@ -96,35 +96,14 @@ Run the Build-level gate check from the **Gate Check Commands** section in tasks
96
96
 
97
97
  ### 5. Discrimination Sensor (MANDATORY — always runs after gate check passes)
98
98
 
99
- The sensor provides the empirical guarantee that the tests can actually detect regressions. It runs in a scratch/throwaway state the real working tree is never modified.
99
+ The sensor provides the empirical guarantee that the tests can actually detect regressions. Run the full mechanics from `references/discrimination-sensor.md` — scratch git-worktree isolation (never `git stash`), porcelain baseline before/after, behavior-level mutation forms, and the lightweight/P0 tier table.
100
100
 
101
- **How it works:**
101
+ Spec-driven specifics on top of that shared mechanic:
102
102
 
103
- 1. **Prepare an isolated scratch.** Never mutate the real worktree. Choose one:
104
- - Preferred: a temporary git worktree (`git worktree add <scratch-path> HEAD`), mutate and run tests there, then `git worktree remove --force <scratch-path>`.
105
- - Fallback (no git / worktree unavailable): copy only the affected file(s) to a temp directory, mutate the copies, point the test runner at those copies (or restore originals from the copies' backups), then delete the temp directory.
106
- - **Forbidden:** `git stash` / `git stash pop`. A stash records state *before* the mutation; popping it does not reverse a mutation applied afterward, and on a clean tree `git stash` creates no entry at all — so the fault is left in the real worktree.
107
- 2. **Capture a baseline.** Record `git status --porcelain` (or equivalent) of the real worktree *before* any sensor work. It must be unchanged after cleanup.
108
- 3. **Inject a behavior-level fault** into the scratch copy of the new code introduced by this feature. Choose a mutation proportional to the code's risk:
109
- - Flip a boolean condition (`if (x)` → `if (!x)`, `>` → `>=`)
110
- - Change a return value (return a wrong status code, wrong field, zero instead of a computed value)
111
- - Off-by-one (shift a loop bound, change a slice index)
112
- - Remove a required side effect (delete a method call that the spec requires)
113
- 4. **Run the tests** that cover the mutated code (against the scratch). Use the Quick or Full gate command from tasks.md.
114
- 5. **Confirm the mutant is killed** (tests FAIL). Discard the scratch (remove worktree or delete temp copies).
115
- 6. **Verify isolation.** Re-run `git status --porcelain` on the real worktree and confirm it matches the baseline from step 2. If it differs, STOP — restore the real tree before continuing, and treat the sensor run as invalid.
116
- 7. **If a mutant survives** (tests still pass after the fault), the tests are not discriminating for that behavior — add a fix task to strengthen the assertion.
117
-
118
- **Tiering (proportional, not optional):**
119
-
120
- | Context | Sensor depth |
121
- | ------- | ------------ |
122
- | Default (all features) | Lightweight fault-injection: 1–3 targeted behavior-level mutations per feature, focused on the highest-risk new code |
123
- | P0 / critical paths (payment, auth, data integrity) | Full mutation run: use language-appropriate mutation tooling if available (e.g., Stryker, mutmut, cargo-mutants, pitest); otherwise increase the number of manual fault-injection mutations to ≥5 covering all branches |
124
-
125
- **Stack-agnostic:** The sensor targets behavior-level semantics (what the code does), not a specific tool. Any language, any framework.
126
-
127
- **Report:** Record killed/survived for each mutation attempt. Surviving mutants → create fix tasks before marking the feature done.
103
+ - The mutation target is the **new code introduced by this feature** (the "code under the claim" for a spec-driven change).
104
+ - Use the Quick or Full gate command from tasks.md as the sensor's test run.
105
+ - **Surviving mutants create fix tasks** to strengthen the assertion before marking the feature done.
106
+ - Record killed/survived per mutation in the validation report's Discrimination Sensor table below.
128
107
 
129
108
  If a safe reversible mutant cannot be made, record why and mark `Blocked` unless equivalent existing mutation evidence proves discrimination.
130
109
 
@@ -195,7 +174,7 @@ For each issue found during UAT or from the Verifier:
195
174
 
196
175
  Fix tasks follow the same format as regular tasks and can be executed with the implement phase (see [references/spec-driven/execute.md](execute.md)).
197
176
 
198
- **Guardrail:** Maximum 3 diagnostic iterations per issue. If root cause isn't found after 3 attempts, flag for human investigation. The same 3-iteration bound applies to the Verifier's fix→re-verify cycle: if gaps persist after 3 rounds, escalate to the user rather than continuing to loop.
177
+ **Guardrail:** Maximum 3 diagnostic iterations per issue. If root cause isn't found after 3 attempts, flag for human investigation. The Verifier's fix→re-verify cycle is separately bounded by the Bounded Fix→Re-verify Loop in `references/verification-ladder.md`.
199
178
 
200
179
  ### 9. Write Validation Report File + Return Chat Summary (MANDATORY)
201
180
 
@@ -239,8 +218,7 @@ Derive the flags from this validation's own evidence: `--result` from the Verdic
239
218
  ## Fix Loop
240
219
 
241
220
  - Return `Needs Fix` findings to Execute as fix tasks.
242
- - Cap the loop at 3 verification iterations.
243
- - After 3 unsuccessful iterations, mark `Blocked` with remaining findings and exact next step.
221
+ - Cap: 3 verification iterations, per the Bounded Fix→Re-verify Loop in `references/verification-ladder.md`; at the cap, mark `Blocked` with remaining findings and exact next step.
244
222
 
245
223
  ---
246
224
 
@@ -46,6 +46,22 @@ Every `*-fix` workflow must execute this gate for each selected finding or coher
46
46
  - Reinspect validation assets after changes and record that tests, specs, fixtures, snapshots, benchmarks, public contracts, and generated baselines were not weakened unless the user explicitly requested that validation-asset change.
47
47
  - Closure evidence must include command/artifact, result, skipped reason or `none`, highest Verification Ladder level reached, validation assets protected, and residual risk.
48
48
 
49
+ ### Independent Verification Mandate (author ≠ verifier)
50
+
51
+ - At **Standard+ or Spec-driven size, or for any high/critical-severity finding**, dispatching `massa-ai-verification-agent` is **mandatory** before closure — the author must not be the sole verifier of their own work. At Quick size, the subagent hop may be skipped, but the check itself is never skipped: run a standalone fresh-eyes re-check (re-read the finding/ACs, changed files, tests, and diff from scratch) against the same output contract.
52
+ - **Exception — `security-fix` dispatches the verifier unconditionally** for every finding closed `fixed`, at every tier.
53
+ - Fallback discipline: when the subagent is unavailable (not registered, spawning forbidden), run the standalone fresh-eyes re-check from scratch and record the skipped-delegation reason in closure evidence.
54
+ - Reviewer + verifier both dispatching at Standard+ is intentional cost, mirroring spec-driven's always-on pair — not accidental duplication.
55
+
56
+ ### Discrimination Sensor
57
+
58
+ At the same tiers as the mandate above (and unconditionally for security-fix `fixed` closures at Standard+/critical), run the sensor from `references/discrimination-sensor.md` against the code under the claim being verified. A surviving mutant means the verification cannot discriminate: the claim is not proven.
59
+
60
+ ### Bounded Fix→Re-verify Loop
61
+
62
+ - The fix → re-verify cycle is capped at **3 verification iterations** per finding or feature. After 3 unsuccessful iterations, stop with `Blocked` (fix workflows: closure row `blocked`), preserve the evidence collected, and ask the user for direction.
63
+ - This is a *verification-cycle* counter, independent of two other counters: the *edit-attempt* breaker ("two consecutive failed fixes on one symptom → load `references/root-cause-scripts.md`") fires *inside* a single iteration and neither consumes nor resets it; and `references/implementation-delivery.md` Stage 6's CI-repair cap is a third, post-push loop with its own count.
64
+
49
65
  ## Ladder
50
66
 
51
67
  Use the cheapest sufficient evidence first: