devrites 4.1.0 → 4.2.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 (84) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/docs/engine/commands.md +65 -6
  4. package/engine/go.mod +1 -1
  5. package/engine/internal/gate/gate.go +154 -46
  6. package/engine/internal/gate/gate_test.go +290 -2
  7. package/engine/internal/gate/readiness_binding.go +66 -100
  8. package/engine/internal/gate/readiness_binding_test.go +126 -3
  9. package/engine/internal/lib/resolve.go +6 -6
  10. package/engine/internal/state/cmd/workflowmanifest/main.go +32 -3
  11. package/engine/internal/state/feature.go +1 -100
  12. package/engine/internal/state/observation.go +584 -0
  13. package/engine/internal/state/observation_open_other.go +9 -0
  14. package/engine/internal/state/observation_open_unix.go +12 -0
  15. package/engine/internal/state/observation_test.go +960 -0
  16. package/engine/internal/state/observation_unix_test.go +68 -0
  17. package/engine/internal/state/schema.go +60 -160
  18. package/engine/internal/state/state_test.go +489 -101
  19. package/engine/internal/state/status.go +67 -48
  20. package/engine/tests/adr_0004_required_by_phase_test.go +16 -13
  21. package/engine/tests/adr_0011_define_plan_test.go +14 -12
  22. package/engine/tests/gate_test.go +403 -28
  23. package/engine/tests/workspace_observation_migration_test.go +1065 -0
  24. package/pack/.claude/skills/devrites-debug-recovery/SKILL.md +1 -10
  25. package/pack/.claude/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md +30 -0
  26. package/pack/.claude/skills/devrites-lib/reference/standards/afk-hitl.md +2 -9
  27. package/pack/.claude/skills/devrites-lib/reference/standards/one-shot-actions.md +1 -6
  28. package/pack/.claude/skills/devrites-lib/reference/standards/workflow-artifacts.md +411 -102
  29. package/pack/.claude/skills/rite-autocomplete/SKILL.md +98 -146
  30. package/pack/.claude/skills/rite-autocomplete/reference/decision-policy.md +11 -5
  31. package/pack/.claude/skills/rite-autocomplete/reference/loop.md +96 -134
  32. package/pack/.claude/skills/rite-autocomplete/reference/stop-conditions.md +92 -131
  33. package/pack/.claude/skills/rite-build/SKILL.md +51 -79
  34. package/pack/.claude/skills/rite-build/reference/phase-contract.md +3 -17
  35. package/pack/.claude/skills/rite-plan/SKILL.md +17 -17
  36. package/pack/.claude/skills/rite-plan/reference/anti-patterns.md +11 -1
  37. package/pack/.claude/skills/rite-plan/reference/replan-and-repair.md +10 -3
  38. package/pack/.claude/skills/rite-prove/SKILL.md +95 -153
  39. package/pack/.claude/skills/rite-vet/SKILL.md +121 -174
  40. package/pack/.claude/skills/rite-vet/reference/anti-patterns.md +14 -2
  41. package/pack/.claude/skills/rite-vet/reference/artifacts.md +10 -6
  42. package/pack/.claude/skills/rite-vet/reference/depth.md +10 -3
  43. package/pack/.claude/skills/rite-vet/reference/review-axes.md +12 -4
  44. package/pack/generated/claude/skills/devrites-debug-recovery/SKILL.md +1 -10
  45. package/pack/generated/claude/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md +30 -0
  46. package/pack/generated/claude/skills/devrites-lib/reference/standards/afk-hitl.md +2 -9
  47. package/pack/generated/claude/skills/devrites-lib/reference/standards/one-shot-actions.md +1 -6
  48. package/pack/generated/claude/skills/devrites-lib/reference/standards/workflow-artifacts.md +411 -102
  49. package/pack/generated/claude/skills/rite-autocomplete/SKILL.md +98 -146
  50. package/pack/generated/claude/skills/rite-autocomplete/reference/decision-policy.md +11 -5
  51. package/pack/generated/claude/skills/rite-autocomplete/reference/loop.md +96 -134
  52. package/pack/generated/claude/skills/rite-autocomplete/reference/stop-conditions.md +92 -131
  53. package/pack/generated/claude/skills/rite-build/SKILL.md +51 -79
  54. package/pack/generated/claude/skills/rite-build/reference/phase-contract.md +3 -17
  55. package/pack/generated/claude/skills/rite-plan/SKILL.md +17 -17
  56. package/pack/generated/claude/skills/rite-plan/reference/anti-patterns.md +11 -1
  57. package/pack/generated/claude/skills/rite-plan/reference/replan-and-repair.md +10 -3
  58. package/pack/generated/claude/skills/rite-prove/SKILL.md +95 -153
  59. package/pack/generated/claude/skills/rite-vet/SKILL.md +121 -174
  60. package/pack/generated/claude/skills/rite-vet/reference/anti-patterns.md +14 -2
  61. package/pack/generated/claude/skills/rite-vet/reference/artifacts.md +10 -6
  62. package/pack/generated/claude/skills/rite-vet/reference/depth.md +10 -3
  63. package/pack/generated/claude/skills/rite-vet/reference/review-axes.md +12 -4
  64. package/pack/generated/codex/skills/devrites-debug-recovery/SKILL.md +1 -10
  65. package/pack/generated/codex/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md +30 -0
  66. package/pack/generated/codex/skills/devrites-lib/reference/standards/afk-hitl.md +2 -9
  67. package/pack/generated/codex/skills/devrites-lib/reference/standards/one-shot-actions.md +1 -6
  68. package/pack/generated/codex/skills/devrites-lib/reference/standards/workflow-artifacts.md +411 -102
  69. package/pack/generated/codex/skills/rite-autocomplete/SKILL.md +98 -146
  70. package/pack/generated/codex/skills/rite-autocomplete/reference/decision-policy.md +11 -5
  71. package/pack/generated/codex/skills/rite-autocomplete/reference/loop.md +96 -134
  72. package/pack/generated/codex/skills/rite-autocomplete/reference/stop-conditions.md +92 -131
  73. package/pack/generated/codex/skills/rite-build/SKILL.md +51 -79
  74. package/pack/generated/codex/skills/rite-build/reference/phase-contract.md +3 -17
  75. package/pack/generated/codex/skills/rite-plan/SKILL.md +17 -17
  76. package/pack/generated/codex/skills/rite-plan/reference/anti-patterns.md +11 -1
  77. package/pack/generated/codex/skills/rite-plan/reference/replan-and-repair.md +10 -3
  78. package/pack/generated/codex/skills/rite-prove/SKILL.md +95 -153
  79. package/pack/generated/codex/skills/rite-vet/SKILL.md +121 -174
  80. package/pack/generated/codex/skills/rite-vet/reference/anti-patterns.md +14 -2
  81. package/pack/generated/codex/skills/rite-vet/reference/artifacts.md +10 -6
  82. package/pack/generated/codex/skills/rite-vet/reference/depth.md +10 -3
  83. package/pack/generated/codex/skills/rite-vet/reference/review-axes.md +12 -4
  84. package/package.json +1 -1
@@ -3,6 +3,14 @@
3
3
  `eng-review.md` records review; `test-plan.md` drives Build. Fold accepted findings
4
4
  into `plan.md`/`tasks.md`; prose alone never changes Build.
5
5
 
6
+ Authority: `.claude/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md`.
7
+
8
+ <!-- BEGIN RESLICE ROUTE-TO-ACTION -->
9
+ - `FOLD` → fold technical topology; invalidate Vet/readiness; affected Vet before Build.
10
+ - `GUARD_AND_REPAIR` → no planning writes; Spec Drift Guard → Clarify → Plan repair → affected Vet.
11
+ - `BLOCKED_INPUT` → no planning writes; exact diagnostic; recover input; reclassify.
12
+ <!-- END RESLICE ROUTE-TO-ACTION -->
13
+
6
14
  ## `eng-review.md`: the record
7
15
  Write/update `.devrites/work/<slug>/eng-review.md`; never clobber.
8
16
 
@@ -146,8 +154,7 @@ Conflicts: Lanes A and B both touch models/ — sequential or coordinate.
146
154
  ```
147
155
 
148
156
  ## Fold-back: the part the build follows
149
- Vet *is* the plan-hardening phase, so behavior-preserving refinements are written **directly**;
150
- acceptance/behavior changes route through the **Spec Drift Guard**.
157
+ Vet hardens the plan. Use the marked action before fold-back.
151
158
 
152
159
  - **Write directly into `plan.md` / `tasks.md`** (single canonical writer: you, not the reviewer):
153
160
  - `plan.md` §Scope boundaries ← "NOT in scope" items.
@@ -161,10 +168,7 @@ acceptance/behavior changes route through the **Spec Drift Guard**.
161
168
  failure-mode coverage, tightened slice scope, a split of a refactor+behavior slice into two.
162
169
  Adjust a slice's `Gate:` upward when vet reveals higher stakes (e.g. an unflagged migration).
163
170
  - Re-run the `plan.md` Readiness gate after edits; it must still pass.
164
- - **Route through the Spec Drift Guard** (record `drift.md` + a recorded decision, then `/rite-plan
165
- repair` for any structural reslice) for anything that **changes an acceptance criterion, product
166
- behavior, or the spec**, including a scope reduction that drops a criterion. A folded change with
167
- no recorded decision is the batch-dump failure.
171
+ - **Reslice:** marked action only; no local predicate.
168
172
  - **`decisions.md`:** one ADR per material call: `context · decision · why-not-the-alternative ·
169
173
  what-would-change-it`.
170
174
  - **`assumptions.md`:** every "we'll probably need X" demoted to an explicit assumption-to-verify,
@@ -10,6 +10,14 @@ A four-section deep-dive on a one-file reversible plan is wasteful; rubber-stamp
10
10
  migration-touching plan is dangerous. Match the effort to the stakes, but **always** leave a
11
11
  recorded engineering verdict and a coverage plan.
12
12
 
13
+ Authority: `.claude/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md`.
14
+
15
+ <!-- BEGIN RESLICE ROUTE-TO-ACTION -->
16
+ - `FOLD` → fold technical topology; invalidate Vet/readiness; affected Vet before Build.
17
+ - `GUARD_AND_REPAIR` → no planning writes; Spec Drift Guard → Clarify → Plan repair → affected Vet.
18
+ - `BLOCKED_INPUT` → no planning writes; exact diagnostic; recover input; reclassify.
19
+ <!-- END RESLICE ROUTE-TO-ACTION -->
20
+
13
21
  ## Full pass when ANY trips
14
22
  - **Irreversible-risk contact:** the plan touches anything on the `afk-hitl.md` irreversible-risk
15
23
  list: destructive data migration, auth/authz boundary, public-API break, external-service
@@ -19,7 +27,7 @@ recorded engineering verdict and a coverage plan.
19
27
  `../../devrites-lib/reference/standards/tooling.md`) or an honest estimate) crosses
20
28
  module/service boundaries or has many dependents.
21
29
  - **Complexity:** `plan.md` touches **>8 files** or adds **>2 new services/modules/classes**.
22
- - **Multi-slice / multi-day**, or a new dependency / pattern / second design system.
30
+ - **Multi-slice / multi-day work**, new dependency/pattern/design system. Slice count alone never creates a human pause.
23
31
  - **The user asked**, or `--full`.
24
32
 
25
33
  Full pass = §0 scope challenge + all four axes (each walked finding-by-finding) + the failure-mode
@@ -46,8 +54,7 @@ triggers above, **never skipped**. Under the AFK gate ceiling:
46
54
  - **Auto-apply (no pause):** hardening findings: added test requirements, error-handling /
47
55
  failure-mode coverage, tightened scope, reuse-over-rebuild, dependency-order fixes
48
56
  (these never grow acceptance). Record the rationale in `decisions.md`.
49
- - **Blocking pause:** any finding that **grows scope, adds a slice, changes an acceptance
50
- criterion, or alters product behavior**.
57
+ - **Topology findings:** marked action; slice count alone never pauses.
51
58
  - **Always pause:** irreversible-risk findings, and any axis still below bar after the
52
59
  ≤3-iteration reviewer loop.
53
60
  - **Cross-model** is off by default; it runs only if `--cross-model` was explicitly armed.
@@ -3,6 +3,14 @@
3
3
  Run blocking §0, then the four axes and required outputs. Apply
4
4
  [`eng-lenses.md`](eng-lenses.md) throughout; calibrate every finding before presenting it.
5
5
 
6
+ Authority: `.claude/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md`.
7
+
8
+ <!-- BEGIN RESLICE ROUTE-TO-ACTION -->
9
+ - `FOLD` → fold technical topology; invalidate Vet/readiness; affected Vet before Build.
10
+ - `GUARD_AND_REPAIR` → no planning writes; Spec Drift Guard → Clarify → Plan repair → affected Vet.
11
+ - `BLOCKED_INPUT` → no planning writes; exact diagnostic; recover input; reclassify.
12
+ <!-- END RESLICE ROUTE-TO-ACTION -->
13
+
6
14
  ---
7
15
 
8
16
  ## §0. Scope challenge (blocking gate)
@@ -13,11 +21,11 @@ the settled spec requires.
13
21
  1. **What exists?** Find existing code/flows for each sub-problem (use the index per
14
22
  [`tooling.md`](../../devrites-lib/reference/standards/tooling.md)). Can the plan capture their outputs instead of building parallel work?
15
23
  Reuse → extend → build new; list missed reuse.
16
- 2. **Minimum diff.** Find the smallest acceptance-complete change. Flag non-blocking work;
17
- cutting acceptance requires Drift Guard.
24
+ 2. **Minimum diff.** Find the smallest contract-complete change. Flag non-blocking work;
25
+ use the marked action for topology cuts.
18
26
  3. **Complexity smell.** **>8 files** or **>2 new services/modules/classes** needs a justified
19
- complexity gate; otherwise harden to the smallest acceptance-preserving plan. Ask only if
20
- reduction changes acceptance or architecture policy.
27
+ complexity gate; otherwise harden to the smallest contract-complete plan. Use the
28
+ marked action for topology reduction.
21
29
  4. **Built-in check.** For each new pattern/infra/concurrency approach, dispatch
22
30
  `devrites-source-driven` to verify current framework/runtime support and cite it. Custom
23
31
  work where a built-in suffices is a scope-reduction finding.
@@ -64,16 +64,7 @@ has no clear next move.
64
64
  - Ambiguous retained evidence needs diagnostic amplification, not a guessed fix. If an in-scope
65
65
  seam can add a stable unique boundary ID, repair its finite map/collision/fault fixtures,
66
66
  narrow-Vet, then seek fresh action authority. Stop only when no safe amplification seam exists.
67
- - **Route by artifact ownership.** Product source/tests go to the exact bounded
68
- wright. Exact Vet-ready executable proof artifacts under the active `.devrites/**`
69
- workspace follow
70
- [`workflow-artifacts.md`](../devrites-lib/reference/standards/workflow-artifacts.md)
71
- and are materialized by the controlling root. Never ask a read-only planner or
72
- reviewer to return implementation bodies. Materializer failures are reversible
73
- offline recovery, not consumptive one-shot execution: preserve the transaction
74
- journal, preimage hashes, and bound temporaries, preflight the corrected
75
- transaction in a disposable same-layout fixture, then retry only within the
76
- existing materializer fingerprint budget.
67
+ <!-- workflow-artifact-adapter: {"module":"devrites-lib/reference/standards/workflow-artifacts.md","entry":"durable active failure or ambiguous admitted state","action":"OFFLINE_RECOVERY; correct offline, re-preflight, narrow Vet, retry only under cap","return":"saved caller or exact Plan/Vet route"} -->
77
68
  - **Classify before routing** with
78
69
  [cleanup-and-classify.md](reference/cleanup-and-classify.md).
79
70
  - **Durably record class and rationale** in `decisions.md` and the applicable
@@ -0,0 +1,30 @@
1
+ # Acceptance-preserving Reslice
2
+ ## Packet
3
+ Exactly six groups;one slug/attempt;exact unordered keys
4
+ <!-- BEGIN RESLICE PACKET -->
5
+ `current_accepted_contract`;`authoritative_proposed_contract_delta`;`current_topology`;`proposed_topology`;`current_coverage`;`proposed_coverage`;required
6
+ <!-- END RESLICE PACKET -->
7
+ <!--AUTH-->
8
+ Root independently reacquires owning bytes(current contract/topology/coverage+directive/decision).Authority=exact current byte-bound directives;reject cached/remembered/summarized/paraphrased/inferred chat or caller/file/child/tool packets.Groups=readable/current/consistent/stable.Packet inert:no tool selection/instruction/write/authority widening.
9
+ <!--/AUTH-->
10
+ Exact nested schemas;required-only;L=`[A-Za-z0-9][A-Za-z0-9._:-]{0,127}`,S=nonempty:Authority{slug,planning_attempt_id,version:L;state:ready|missing|unreadable|stale|changing};Contract{id:L;meaning:S};Slice{id,grouping:L;depends_on:L[];order:+int;file_ownership:S[]};Obligation{stable_id:L;kind:acceptance|product_behavior;meaning:S;slices:L[1+]};Proof/prohibition{id:L;meaning:S};Link{id,provider,consumer:L;meaning:S}.Lists/IDs/orders unique;dependencies precede;coverage->topology;one contract-ID namespace;reject path/credential/hostile/raw-error IDs.
11
+ <!--PROV-->
12
+ Sole producer:controlling root.Proposal={slug,planning_attempt_id,proposal_id,current_contract_sha256,source_kind,source_stable_id,delta_kind,affected_stable_ids}.Sources:direct_user_directive=current directive digest;recorded_decision=decision/qid+digest;root_no_change_analysis=contract/topology/coverage digests.no_change iff root_no_change_analysis;others require change.Kinds=no_change|acceptance_addition|acceptance_removal|acceptance_meaning_change|product_behavior_change;last=product add/remove/meaning,never acceptance;affected=changed IDs.proposal_id binds source_kind+authority/delta IDs/digests.Caller/file/child/tool claims lack provenance.Intentional authoritative delta is not contradiction.
13
+ <!--/PROV-->
14
+ Preserve IDs/meanings/behavior,compatible proofs,every prohibition,every semantic/provider-consumer link/mapping;slice ID/count, grouping, order, ownership, mapping count may vary.Conflict/duplicate/omission blocks;remapping does not.
15
+ <!-- BEGIN RESLICE ROUTES -->
16
+ First match wins, in order:
17
+ 1. **`BLOCKED_INPUT`** — `missing`/`unreadable`/`stale`/`changing`/`contradictory`/invalid provenance in any group.
18
+ 2. **`GUARD_AND_REPAIR`** — Sufficient groups+authoritative acceptance/product-behavior add/remove/meaning change.
19
+ 3. **`FOLD`** — Sufficient groups+unchanged acceptance/product behavior + complete equivalent coverage.
20
+ <!-- END RESLICE ROUTES -->
21
+ No fourth route/severity ladder. Slice count, file count, complexity, effort, and AFK budget never select the Reslice route; AFK execution limits remain independent.
22
+ `BLOCKED_INPUT`:no planning writes;fields/order.Malformed proposal provenance or controlling-root reacquired-binding mismatch:
23
+ <!-- BEGIN RESLICE DIAGNOSTIC -->
24
+ `route=BLOCKED_INPUT`;`input_group=authoritative_proposed_contract_delta`;`logical_artifact_or_stable_id=authoritative_proposed_contract_delta#item-1`;`problem_category=contradictory`;`expected_authority=controlling_root_reacquired_owning_bytes`;`recovery_owner=controlling_root`;`next_action=reacquire_authoritative_proposed_contract_delta_and_reclassify`.
25
+ <!-- END RESLICE DIAGNOSTIC -->
26
+ Diagnostic ID=canonical group+root-local bounded `item-N`;Never emit content/secrets/physical paths/raw errors/packet IDs/authority guesses.
27
+ <!-- BEGIN RESLICE GATES -->
28
+ `policy`;`principle-exception`;`irreversible-risk`;`safety`;`access`;`approval`;`public-contract`;`resource`.
29
+ <!-- END RESLICE GATES -->
30
+ Writes invalidate Vet/readiness.
@@ -284,16 +284,9 @@ changes, not a request for permission to retry.
284
284
  recorded no-progress corrections still has recovery budget, even when an older
285
285
  `state.md` says `Next step: none`. Resume it; do not treat session age or the
286
286
  prior action's spent authorization as exhaustion.
287
- - **Treat a newly supported writer route as progress once.** For exact Vet-ready
288
- workflow artifacts, apply `workflow-artifacts.md` when prior attempts only asked
289
- a read-only role or product wright for implementation and evidence records
290
- **no controlling-root materialization attempt**. Preserve the old attempts, but
291
- do not count them against the new root-materialization fingerprint. Record the
292
- migration; after a root attempt exists, normal fingerprint accounting applies:
293
- the first root failure is attempt one, not a new one-shot terminal, and the
294
- shared cap remains three no-progress corrections.
287
+ <!-- workflow-artifact-adapter: {"module":"devrites-lib/reference/standards/workflow-artifacts.md","entry":"unattended root reaches current admitted Workflow Artifact work","action":"invoke classifier; execute returned route without wright/slice charge","return":"saved lifecycle phase/action; no intermediate reply"} -->
295
288
  - **Classify exhaustion:** human-owned contract/risk/access gaps open their gate. Otherwise
296
- preserve reproduction/dead ends, set `Status: blocked` and `Next step: none — technical recovery exhausted for <causal fingerprint>; requires new evidence or changed failure conditions`.
289
+ preserve reproduction/dead ends, set `Status: blocked` and `Next step: none — technical recovery exhausted; requires new evidence or changed failure conditions`.
297
290
  Do not emit `$rite-plan unblock`, another phase command, a question, or
298
291
  `$rite-resolve`. Reinvocation with the unchanged fingerprint remains blocked
299
292
  and never resets the retry cap.
@@ -7,12 +7,7 @@ privileged/external state so a rerun is not equivalent, and actions whose cleanu
7
7
  can destroy the failure state needed for diagnosis. Successful cleanup does not
8
8
  make a consumptive action repeatable.
9
9
 
10
- Workflow-artifact materialization is reversible offline work when every admitted
11
- target has a bound preimage or absence marker, rollback is local to the active
12
- feature workspace, and no privileged/external real action executes. It is not a
13
- consumptive action and must not receive a one-shot authorization budget. Failures
14
- of its materializer, atomic replacement, rollback, or offline proof use the normal
15
- causal-fingerprint recovery cap in `afk-hitl.md`.
10
+ <!-- workflow-artifact-adapter: {"module":"devrites-lib/reference/standards/workflow-artifacts.md","entry":"workflow proof completes before any consumptive one-shot action","action":"PROVE_AND_RETURN; require fresh real-action authorization","return":"saved one-shot action boundary"} -->
16
11
 
17
12
  ## Pre-attempt gate
18
13