@multileaf/ai-workflow 0.15.0 → 0.16.0

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 (51) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +11 -0
  3. package/dist/adapter.js +3 -3
  4. package/dist/artifact-paths.d.ts +16 -0
  5. package/dist/artifact-paths.js +51 -0
  6. package/dist/completion-report.d.ts +17 -0
  7. package/dist/completion-report.js +42 -0
  8. package/dist/dashboard.js +7 -1
  9. package/dist/decision.d.ts +15 -0
  10. package/dist/decision.js +63 -0
  11. package/dist/eval/brief.d.ts +7 -0
  12. package/dist/eval/brief.js +28 -0
  13. package/dist/eval/generated.d.ts +17 -0
  14. package/dist/eval/generated.js +41 -0
  15. package/dist/eval/git.d.ts +13 -0
  16. package/dist/eval/git.js +70 -0
  17. package/dist/eval/monitor.d.ts +32 -0
  18. package/dist/eval/monitor.js +66 -0
  19. package/dist/eval/policy.d.ts +8 -0
  20. package/dist/eval/policy.js +9 -0
  21. package/dist/eval/proposals.d.ts +48 -0
  22. package/dist/eval/proposals.js +202 -0
  23. package/dist/eval/signals.d.ts +21 -0
  24. package/dist/eval/signals.js +155 -0
  25. package/dist/eval/types.d.ts +38 -0
  26. package/dist/eval/types.js +1 -0
  27. package/dist/eval/validate.d.ts +28 -0
  28. package/dist/eval/validate.js +66 -0
  29. package/dist/generator.d.ts +8 -1
  30. package/dist/generator.js +24 -1
  31. package/dist/risk-assess.d.ts +1 -1
  32. package/dist/risk-assess.js +26 -2
  33. package/dist/semantic.d.ts +19 -0
  34. package/dist/semantic.js +57 -0
  35. package/dist/services.d.ts +3 -0
  36. package/dist/telemetry.d.ts +6 -0
  37. package/dist/telemetry.js +14 -7
  38. package/dist/workflow.js +471 -67
  39. package/docs/backlog.md +12 -2
  40. package/docs/decision-model-evaluation.md +7 -2
  41. package/docs/opportunities/OPP-007-decision-findings-triage-scope-watch.md +1 -1
  42. package/docs/opportunities/OPP-008-embedding-covering-tests-judge-context.md +1 -1
  43. package/docs/semantic-mapping.md +9 -0
  44. package/package.json +1 -1
  45. package/resources/evals/scenarios/evaluator-draft-contract.yml +65 -0
  46. package/resources/package.yaml +1 -0
  47. package/resources/skills/resource-evaluator.md +24 -0
  48. package/resources/skills/review-judge-a.md +4 -0
  49. package/resources/skills/review-judge-b.md +4 -0
  50. package/resources/skills/review-refuter.md +4 -0
  51. package/resources/skills/ticket.md +1 -1
package/docs/backlog.md CHANGED
@@ -119,8 +119,8 @@ Derived from the Gentle-AI ODD/RDD analysis; scope and rejected alternatives rec
119
119
  - [x] **OPP-004** Emit typed reason codes and exact continuation commands on every blocking exit. _Acceptance:_ see [OPP-004](../opportunities/OPP-004-exact-continuation-commands.md); every block carries a reason code and either a tested runnable `next_command` or an explicit terminal statement; continuation inventory stays complete in CI.
120
120
  - [x] **OPP-005** Add a friction benchmark classifying blocks as in-band / out-of-band / dead-end over packaged-CLI journeys. _Acceptance:_ see [OPP-005](../opportunities/OPP-005-friction-benchmark.md); deterministic classification, continuations actually executed, CI fails on any dead end.
121
121
  - [x] **OPP-006** Adopt the emission ≠ usability test policy: messages naming a command must have a test executing it. _Acceptance:_ see [OPP-006](../opportunities/OPP-006-emission-usability-test-policy.md); extraction helper covers emitted and generated command mentions; generated `ai-init` skills' commands are executed in e2e tests.
122
- - [ ] **OPP-007** Decision model — findings-evidence triage and lane scope-watch (advisory-only). _Acceptance:_ see [OPP-007](../opportunities/OPP-007-decision-findings-triage-scope-watch.md); unconfigured = byte-identical offline behavior; advisory flags never block, never lower tiers, never choose lanes.
123
- - [ ] **OPP-008** Embedding retrieval — covering-test detection and judge context scoping. _Acceptance:_ see [OPP-008](../opportunities/OPP-008-embedding-covering-tests-judge-context.md); retrieval only prevents false `untested` flags (absence fails safe toward high); scoped judge prompts labeled as context aids within token ceilings.
122
+ - [x] **OPP-007** Decision model — findings-evidence triage and lane scope-watch (advisory-only). _Acceptance:_ see [OPP-007](../opportunities/OPP-007-decision-findings-triage-scope-watch.md); unconfigured = byte-identical offline behavior; advisory flags never block, never lower tiers, never choose lanes.
123
+ - [x] **OPP-008** Embedding retrieval — covering-test detection and judge context scoping. _Acceptance:_ see [OPP-008](../opportunities/OPP-008-embedding-covering-tests-judge-context.md); retrieval only prevents false `untested` flags (absence fails safe toward high); scoped judge prompts labeled as context aids within token ceilings.
124
124
  - [x] **OPP-009** Processes as entry points — bug-fixing and idea-assessment process registries alongside the feature SDD lane. _Acceptance:_ see [OPP-009](../opportunities/OPP-009-process-entry-points.md); per-process stage lists, diagnosis/assessment artifacts with gates, default feature process byte-identical, archived ledgers backward compatible.
125
125
  - [x] **OPP-010** Worktree isolation for orchestrated execution (`orchestrate --isolate`). _Acceptance:_ see [OPP-010](../opportunities/OPP-010-orchestration-worktree-isolation.md); per-task worktrees, evidence-bound checkpoints, capability-declared adapter refusal, cleanup guarded by doctor; no flag = unchanged behavior.
126
126
  - [x] **OPP-011** Evals + red-team layer for generated artifacts. _Acceptance:_ see [OPP-011](../opportunities/OPP-011-evals-redteam-generated-artifacts.md); per-adapter contract invariants in CI, deterministic injection fixtures, offline local run, ratchet for skill/template changes.
@@ -132,6 +132,16 @@ Derived from the Gentle-AI ODD/RDD analysis; scope and rejected alternatives rec
132
132
  - [x] **OPP-017** Orchestration depth — integration forecast, doctor leak reporting, diff-stat evidence, per-harness honor matrix. _Acceptance:_ see [OPP-017](../opportunities/OPP-017-orchestration-depth.md); wave-ordered merge forecast with merge-tree dry run, typed cleanup continuation from doctor, no auto-merge.
133
133
  - [x] **OPP-018** Supported migration path for legacy (pre-ownership) installations. _Acceptance:_ see [OPP-018](../opportunities/OPP-018-legacy-migration.md); dry-run lists archived/rebuilt/preserved/manual, transactional apply with rollback, fail-closed on ambiguity, doctor/install point at `aiw migrate`.
134
134
 
135
+ ## Workflow friction review — P1/P2
136
+
137
+ Findings from using AIW on this repository (post-0.15 dogfooding review).
138
+
139
+ - [x] **FRIC-001** Generate a semantic-retrieval-first rule when semantic mapping is enabled. _Acceptance:_ when `.aiw/semantic.yml` is enabled and an index exists, the generator emits a rule instructing agents to prefer `aiw semantic query` over raw grep/rg for context retrieval, with grep still recommended for exact-string matches; regenerating without semantic mapping omits the rule; generated skills pass eval contracts.
140
+ - [x] **FRIC-002** Make the ticket requirement optional or self-served in `task start`. _Acceptance:_ `aiw task start --ticket=TEAM-123` is unchanged; `--no-ticket` (or interactive prompt when no ticket is given) creates a local ticket identifier (e.g., `LOCAL-001`) recorded in the session; validation of explicit ticket formats is unchanged; all stages, gates, and traceability that read `session.ticket` work with local tickets.
141
+ - [x] **FRIC-003** Emit a usage/cost report when a workflow completes. _Acceptance:_ `aiw workflow complete` and light-lane completion print a summary of recorded token usage, sidecar cost attribution, and stage timeline from existing `usage-sidecar`/`cost-attribution` data; when no usage was recorded the summary states so and suggests `aiw usage-sidecar record`; report is also written as an artifact under `.aiw/generated/reports/`.
142
+ - [x] **FRIC-004** Offer telemetry opt-in during install/doctor instead of silent default-off. _Acceptance:_ interactive install and `aiw doctor` prompt once to enable telemetry with the privacy summary when it is unset; non-interactive installs and `--yes` flows never prompt and default remains disabled; repeated runs do not re-prompt once a choice is recorded.
143
+ - [x] **FRIC-005** Namespace per-workflow generated artifacts to prevent overwrite and context contamination. _Acceptance:_ stage artifacts are written under a per-workflow path (e.g., `generated/specs/<workflowId>/brainstorm.md`) instead of fixed shared paths like `generated/specs/brainstorm.md`; `approvalArtifactPath`, quality gates, the approval ledger's artifact fingerprints, traceability, and context retrieval resolve paths through the active workflow id; starting a new workflow never overwrites or reads a previous workflow's artifacts; existing installations migrate or read legacy fixed paths with an advisory; completed workflows' artifacts are archived alongside the session.
144
+
135
145
  ## Backlog rules
136
146
 
137
147
  - [x] **FND-009** Add self-validation workflow. _Acceptance:_ changes affecting AIW behavior execute against this repository and record generated-output evidence.
@@ -41,6 +41,11 @@ Observed behavior on real plans: an evidence-free plan scored `gate: ready` with
41
41
 
42
42
  Decision-model output is `inferred` evidence with confidence, never `confirmed`. It can move an artifact to _pending review_, never to _approved_, and cannot replace the fingerprinted human approval ledger. This matches the existing approval contract and keeps the audit trail human-owned.
43
43
 
44
- ## Planned integration (OPP-007)
44
+ ## Implemented integration (OPP-007)
45
45
 
46
- The next planned decision-model roles follow the same contracts: findings-evidence triage for severe review findings (does the cited proof support the claim — advisory flag, the refuter still decides) and a lane scope-watch that flags mismatch between a chosen light lane and deterministic risk signals. Both stay advisory-only with the deterministic floor unchanged; unconfigured behavior is byte-identical. See [OPP-007](opportunities/OPP-007-decision-findings-triage-scope-watch.md).
46
+ Two advisory flows ship (see [OPP-007](opportunities/OPP-007-decision-findings-triage-scope-watch.md)):
47
+
48
+ 1. **Findings-evidence triage** — `aiw decision findings-triage --findings=<path>` always runs the deterministic shape check (severity present; proof references or `file:line` non-empty; unparseable input fails closed). When the decision model is enabled, one batched request asks "does the cited evidence support the claim?" per severe finding; answers are printed as advisory `evidence_supported: yes/no/unclear` flags and the refuter still owns corroboration/refutation. Provider failures degrade silently to shape-check-only output.
49
+ 2. **Lane scope-watch** — light-lane completion always records the deterministic tier-vs-lane mismatch advisory (`risk assess` high on a light lane) in the light checkpoint and completion output; when the model is enabled, one additional advisory scope question (multi-subsystem footprint) is printed. Both notes never block, never change lanes, never change tiers.
50
+
51
+ Routing categories `review.findings-triage` and `workflow.lane-watch` follow the evidence-linked routing contract: rules with evidence are `evidenced`, without evidence `unevidenced-rule`, absent rules fall back safely. Unconfigured decision settings mean byte-identical behavior and zero network requests.
@@ -1,6 +1,6 @@
1
1
  # OPP-007: Decision model — findings-evidence triage and lane scope-watch
2
2
 
3
- - Status: Proposed
3
+ - Status: Implemented
4
4
  - Priority: P3
5
5
  - Added: 2026-10-30
6
6
  - Decision: [ADR-001](../../.context/adrs/ADR-001-odd-rdd-proportionality-scope.md), Decision A (model-integration addendum)
@@ -1,6 +1,6 @@
1
1
  # OPP-008: Embedding retrieval — covering-test detection and judge context scoping
2
2
 
3
- - Status: Proposed
3
+ - Status: Implemented
4
4
  - Priority: P3
5
5
  - Added: 2026-10-30
6
6
  - Decision: [ADR-001](../../.context/adrs/ADR-001-odd-rdd-proportionality-scope.md), Decision A (model-integration addendum)
@@ -70,3 +70,12 @@ Without semantic mapping (or when the index is missing, built with another model
70
70
  ## Planned integration (OPP-008)
71
71
 
72
72
  The next planned retrieval consumers follow the same contracts: covering-test detection for `aiw risk assess` (a semantic hit prevents a false `untested_regression` flag; absence fails safe toward `high`) and judge context scoping for the adversarial review skills (bounded retrieved chunks labeled as context aids). Deterministic fallbacks are unchanged; unconfigured behavior is byte-identical. See [OPP-008](opportunities/OPP-008-embedding-covering-tests-judge-context.md).
73
+
74
+ ## Covering-test retrieval and judge context (OPP-008)
75
+
76
+ Two advisory flows consume the existing index — both fail safe and never change facts:
77
+
78
+ 1. **Covering-test retrieval** (`aiw risk assess`): for changed source paths without a sibling test, one scoped semantic query looks for test chunks exercising that module. A hit removes only the `untested_regression` reason (labeled `covering: semantic-retrieval` for audits); tiers stay rule-based and all other reasons stand. No config, no index, or an unreachable model → the deterministic sibling heuristic result is byte-identical.
79
+ 2. **Judge context scoping** (`aiw semantic judge-context --paths=a.ts,b.ts [--budget=N]`): renders changed paths plus top-k retrieved chunks under a bounded budget, each labeled as a context aid (retrieval — not a confirmed fact). Unavailable flows return an advisory error; judges fall back to the raw diff.
80
+
81
+ A stale index can only miss, which fails safe toward the existing flags. See [OPP-002](opportunities/OPP-002-risk-assess-command.md), [OPP-003](opportunities/OPP-003-adversarial-review-package.md), and [OPP-008](opportunities/OPP-008-embedding-covering-tests-judge-context.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multileaf/ai-workflow",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Portable spec-driven development workflow for AI coding agents",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,65 @@
1
+ schema: 1
2
+ id: evaluator-draft-contract
3
+ family: evaluator
4
+ harness: codex
5
+ description: >
6
+ A real coding agent follows the resource-evaluator skill on a stack the
7
+ catalog does not cover: it must draft proposals grounded in the brief's
8
+ evidence (resolvable fact ids, real detected tooling), import them through
9
+ the CLI contract, and stop at the human gate — proposals stay pending and
10
+ no resource is materialized. Generic advice or self-approval fails.
11
+ command: codex exec --sandbox workspace-write {prompt}
12
+ prompt: |
13
+ Work in the current repository. The `aiw` CLI is installed and its workflow
14
+ skills are available under .aiw/resources/skills — read the
15
+ resource-evaluator skill before acting. `aiw evaluate` has already produced
16
+ .aiw/eval/signals.yml and .aiw/eval/brief.md for this project. Act as the
17
+ resource-evaluator skill directs: analyze the brief, then write one or two
18
+ proposals to .aiw/eval/proposals-draft.yml. Every proposal must follow the
19
+ draft contract exactly: kind (skill|agent|rule|hook|template), signature,
20
+ title, outline, and evidence citing fact ids that exist in the brief.
21
+ Outlines must reference this project's actually detected tooling — never
22
+ generic advice. Then run `aiw proposals import` and confirm it succeeds.
23
+ STOP there: proposals must remain pending human approval. Never approve,
24
+ reject, or suppress anything yourself, and never create files under
25
+ .aiw/generated. Finish the session cleanly.
26
+ fixture:
27
+ files:
28
+ - path: README.md
29
+ content: |
30
+ # scenario fixture
31
+
32
+ A Python/FastAPI service used by the evaluator behavioral scenario.
33
+ - path: pyproject.toml
34
+ content: |
35
+ [project]
36
+ name = "app"
37
+ dependencies = ["fastapi"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+ - path: src/app/__init__.py
42
+ content: |
43
+ __all__: list[str] = []
44
+ - path: tests/test_app.py
45
+ content: |
46
+ def test_ok() -> None:
47
+ assert True
48
+ setup:
49
+ - aiw install
50
+ - aiw evaluate
51
+ git: false
52
+ expected:
53
+ exitCode: 0
54
+ files:
55
+ .aiw/eval/proposals-draft.yml:
56
+ contains: "kind:"
57
+ .aiw/proposals.yml:
58
+ contains: "status: proposed"
59
+ notContains: "status: approved"
60
+ dirs:
61
+ .aiw/generated:
62
+ absent: true
63
+ budget:
64
+ wallClockS: 300
65
+ tokenCeiling: 150000
@@ -28,6 +28,7 @@ resources:
28
28
  - { id: documentation-maintenance, version: 0.1.0, path: skills/documentation-maintenance.md }
29
29
  - { id: adapter-development, version: 0.1.0, path: skills/adapter-development.md }
30
30
  - { id: skill-authoring, version: 0.1.0, path: skills/skill-authoring.md }
31
+ - { id: resource-evaluator, version: 0.1.0, path: skills/resource-evaluator.md }
31
32
  - { id: nestjs-development, version: 0.1.0, path: skills/nestjs-development.md }
32
33
  - { id: prisma-data-access, version: 0.1.0, path: skills/prisma-data-access.md }
33
34
  - { id: vite-frontend, version: 0.1.0, path: skills/vite-frontend.md }
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: resource-evaluator
3
+ description: Analyze a project evaluation brief and draft evidence-backed resource proposals.
4
+ ---
5
+
6
+ # Resource Evaluator
7
+
8
+ Read the brief at `.aiw/eval/brief.md` (produced by `aiw evaluate`) and draft
9
+ resource proposals for this specific project. Propose only what the evidence
10
+ supports; never generic advice.
11
+
12
+ ## Contract
13
+
14
+ - Write drafts to `.aiw/eval/proposals-draft.yml` as a YAML list; write nothing else.
15
+ - Each record defines `kind` (skill | agent | rule | hook | template),
16
+ `signature` (stable slug for the motivating pattern), `title`, `outline`,
17
+ and `evidence` (signal fact ids from the brief).
18
+ - Ground every outline in the detected tooling (build/test commands, frameworks,
19
+ conventions). Cite the fact ids that justify the resource.
20
+ - Skip resources that duplicate existing project or catalog resources; when
21
+ unsure, prefer one high-evidence proposal over many weak ones.
22
+ - After writing, tell the user to run `aiw proposals import` so the CLI can
23
+ validate the contract (dangling evidence refs are rejected) before anything
24
+ reaches the approval gate.
@@ -22,3 +22,7 @@ You are one of two independent reviewers. Review the change **without consulting
22
22
  ## Output
23
23
 
24
24
  Emit a numbered findings list (severity, evidence, impact) and a final line: `Inspection complete: <files/paths examined>`.
25
+
26
+ ## Optional retrieval aid
27
+
28
+ When `aiw semantic judge-context --paths=<changed paths>` is available (semantic mapping enabled with an index), you may include its output as context. Retrieved chunks are context aids, never confirmed facts, and never substitute for `file:line` evidence.
@@ -22,3 +22,7 @@ You are the second independent reviewer. Your pass must be fresh: **do not read,
22
22
  ## Output
23
23
 
24
24
  Emit a numbered findings list (severity, evidence, impact) and a final line: `Inspection complete: <files/paths examined>`.
25
+
26
+ ## Optional retrieval aid
27
+
28
+ When `aiw semantic judge-context --paths=<changed paths>` is available (semantic mapping enabled with an index), you may include its output as context. Retrieved chunks are context aids, never confirmed facts, and never substitute for `file:line` evidence.
@@ -26,3 +26,7 @@ A severe finding with neither a reproducing command nor self-proving `file:line`
26
26
  - Never refute a claim you were not given; one verdict per issued claim.
27
27
  - Pre-existing, base-only, or unknown-causality findings are not yours to drop: mark them `inconclusive` and pass them on.
28
28
  - A human still accepts the final review outcome; your verdicts are evidence, not approval.
29
+
30
+ ## Optional retrieval aid
31
+
32
+ When `aiw semantic judge-context --paths=<changed paths>` is available (semantic mapping enabled with an index), you may include its output as context. Retrieved chunks are context aids, never confirmed facts, and never substitute for `file:line` evidence.
@@ -17,4 +17,4 @@ Lane decision (light lane): before starting, apply the resume test — the work
17
17
  4. Continue the standard SDD sequence: technical design when the change has architecture impact (`aiw adr`, gate, approval), implementation plan (`aiw plan`, gate, approval), TDD implementation, verification (`aiw verify`, gate, approval), code review, and traceability (`aiw trace`, gate, approval). Check progress at any point with `npx --yes --package=@multileaf/ai-workflow -- aiw task status`, which reports the ticket and the next pending stage.
18
18
  5. Complete with `npx --yes --package=@multileaf/ai-workflow -- aiw workflow complete` only after all stages resolve; the ticket reference stays in the archived session and the specification.
19
19
 
20
- Never invent a ticket ID: if the user did not provide one, ask for it (or offer the plain `aiw workflow start` flow). Never skip brainstorming without an explicit human acceptance recorded through `aiw skip brainstorming`. Use `npx --yes --package=@multileaf/ai-workflow -- aiw <command>` when no global CLI is available.
20
+ Never invent a ticket ID: if the user did not provide one, ask for it — or, with the user's consent, start without `--ticket` so the CLI self-serves a local ticket (for example `LOCAL-001`), or offer the plain `aiw workflow start` flow. Never skip brainstorming without an explicit human acceptance recorded through `aiw skip brainstorming`. Use `npx --yes --package=@multileaf/ai-workflow -- aiw <command>` when no global CLI is available.