@arbiterforge/ca-pi 0.18.4 → 0.19.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 (74) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/plugins/ca-pi/CHANGELOG.md +54 -0
  4. package/plugins/ca-pi/COMMANDS.md +2 -2
  5. package/plugins/ca-pi/SKILLS.md +5 -5
  6. package/plugins/ca-pi/SPRINT.md +43 -230
  7. package/plugins/ca-pi/agents/backend-author.md +5 -5
  8. package/plugins/ca-pi/agents/checkpoint-aggregator.md +7 -0
  9. package/plugins/ca-pi/agents/frontend-author.md +5 -5
  10. package/plugins/ca-pi/agents/infra-author.md +6 -7
  11. package/plugins/ca-pi/agents/scout.md +25 -24
  12. package/plugins/ca-pi/arbiter.md +6 -4
  13. package/plugins/ca-pi/generated/command-catalog.json +5 -5
  14. package/plugins/ca-pi/helpers/artifacts/ca-artifact-darwin-amd64 +0 -0
  15. package/plugins/ca-pi/helpers/artifacts/ca-artifact-darwin-arm64 +0 -0
  16. package/plugins/ca-pi/helpers/artifacts/ca-artifact-linux-amd64 +0 -0
  17. package/plugins/ca-pi/helpers/artifacts/ca-artifact-linux-arm64 +0 -0
  18. package/plugins/ca-pi/helpers/artifacts/ca-artifact-windows-amd64.exe +0 -0
  19. package/plugins/ca-pi/helpers/artifacts/ca-artifact-windows-arm64.exe +0 -0
  20. package/plugins/ca-pi/helpers/artifacts/release.json +37 -37
  21. package/plugins/ca-pi/hooks/_approvallib.py +41 -0
  22. package/plugins/ca-pi/hooks/_artifactlib.py +61 -115
  23. package/plugins/ca-pi/hooks/_artifactpromptlib.py +12 -12
  24. package/plugins/ca-pi/hooks/_bashguardlib.py +66 -4
  25. package/plugins/ca-pi/hooks/_contextselectlib.py +38 -35
  26. package/plugins/ca-pi/hooks/_contextwriterlib.py +114 -0
  27. package/plugins/ca-pi/hooks/_host.py +1 -1
  28. package/plugins/ca-pi/hooks/_prerequisitelib.py +35 -0
  29. package/plugins/ca-pi/hooks/_provenancelib.py +107 -1
  30. package/plugins/ca-pi/hooks/_readinjectlib.py +21 -7
  31. package/plugins/ca-pi/hooks/_reconciliationlib.py +167 -2
  32. package/plugins/ca-pi/hooks/_releaselib.py +6 -6
  33. package/plugins/ca-pi/hooks/_sprintapprovallib.py +52 -2
  34. package/plugins/ca-pi/hooks/artifact-reconcile.py +13 -4
  35. package/plugins/ca-pi/hooks/hostapi.py +1 -1
  36. package/plugins/ca-pi/hooks/init-codearbiter.py +34 -5
  37. package/plugins/ca-pi/includes/artifacts-attestation.md +434 -0
  38. package/plugins/ca-pi/includes/artifacts.md +133 -492
  39. package/plugins/ca-pi/includes/author-tdd-workflow.md +32 -21
  40. package/plugins/ca-pi/includes/fresh-verification.md +14 -12
  41. package/plugins/ca-pi/includes/harvest.md +3 -3
  42. package/plugins/ca-pi/includes/reference-map.md +1 -1
  43. package/plugins/ca-pi/includes/routing-table.md +3 -3
  44. package/plugins/ca-pi/includes/sprint-authority.md +6 -1
  45. package/plugins/ca-pi/includes/verification-boundary.md +11 -2
  46. package/plugins/ca-pi/package.json +1 -1
  47. package/plugins/ca-pi/routines/INDEX.md +8 -8
  48. package/plugins/ca-pi/routines/brainstorming/SKILL.md +65 -202
  49. package/plugins/ca-pi/routines/commit-gate/SKILL.md +60 -25
  50. package/plugins/ca-pi/routines/context-check/SKILL.md +89 -53
  51. package/plugins/ca-pi/routines/context-creation/SKILL.md +114 -220
  52. package/plugins/ca-pi/routines/decompose/SKILL.md +139 -167
  53. package/plugins/ca-pi/routines/executing-plans/SKILL.md +38 -136
  54. package/plugins/ca-pi/routines/finishing-a-development-branch/SKILL.md +45 -55
  55. package/plugins/ca-pi/routines/refactor/SKILL.md +27 -12
  56. package/plugins/ca-pi/routines/release/SKILL.md +1 -1
  57. package/plugins/ca-pi/routines/subagent-driven-development/SKILL.md +80 -230
  58. package/plugins/ca-pi/routines/tdd/SKILL.md +115 -228
  59. package/plugins/ca-pi/routines/writing-plans/SKILL.md +104 -174
  60. package/plugins/ca-pi/skills/ca-audit/SKILL.md +2 -2
  61. package/plugins/ca-pi/skills/ca-checkpoint/SKILL.md +1 -1
  62. package/plugins/ca-pi/skills/ca-commit/SKILL.md +60 -25
  63. package/plugins/ca-pi/skills/ca-context-check/SKILL.md +89 -53
  64. package/plugins/ca-pi/skills/ca-create-context/SKILL.md +114 -220
  65. package/plugins/ca-pi/skills/ca-decompose/SKILL.md +139 -167
  66. package/plugins/ca-pi/skills/ca-feature/SKILL.md +21 -38
  67. package/plugins/ca-pi/skills/ca-fix/SKILL.md +15 -9
  68. package/plugins/ca-pi/skills/ca-init/SKILL.md +18 -40
  69. package/plugins/ca-pi/skills/ca-pr/SKILL.md +45 -55
  70. package/plugins/ca-pi/skills/ca-refactor/SKILL.md +27 -12
  71. package/plugins/ca-pi/skills/ca-release/SKILL.md +1 -1
  72. package/plugins/ca-pi/skills/ca-review/SKILL.md +5 -8
  73. package/plugins/ca-pi/skills/ca-sprint/SKILL.md +11 -25
  74. package/plugins/ca-pi/skills/ca-status/SKILL.md +15 -6
@@ -20,23 +20,22 @@ Read these, or STOP and surface the gap — never guess a command:
20
20
  - `<project-root>/.codearbiter/tech-stack.md` — test, lint, and secrets-scan invocations. Stop if missing; do not guess.
21
21
  - `<plugin-root>/includes/verification-boundary.md` — the required split between focused local proof and exhaustive exact-head hosted CI.
22
22
  - A git repository must be present and `git status` available.
23
- - The `tdd` skill must have cleared all six phases for any new or modified feature code in the staged set. If `tdd` is incomplete, STOP and surface the gap.
24
- - The discovered authoritative spec/plan pair, when this commit belongs to a
25
- `/feature` or `/sprint` pipeline. For HTML, load
26
- `<plugin-root>/includes/artifacts.md`; use the engine `identity` and `eligible`
27
- results, and treat the exact spec and plan identities plus the acceptance
28
- receipts bound in engine state as the commit proof. Require
29
- `all_accepted_and_current: true` before this gate can commit completed plan
30
- work. The gate must not parse rendered HTML and must not consult a shadow
31
- Markdown ledger. Displayed state, checkboxes, hashes, or caller-supplied
32
- labels cannot substitute for current engine acceptance.
33
-
34
- For that HTML pair, invoke the installed bridge's
35
- `_preflight_current_acceptance` with the exact `_resolve_workflow_pair` result,
36
- the repository-bound client, and the spec/plan IDs returned by the engine. Use
37
- its returned identities and receipts as the proof for this gate. A refusal is a
38
- BLOCK before staging or committing; never construct an equivalent proof from
39
- caller metadata.
23
+ - Read the scoped obligations and observed evidence under `<plugin-root>/routines/tdd/SKILL.md`. Confirmed fixes require regression RED/GREEN; features require current criterion-focused checks; refactors require passing characterization/parity evidence. Apply the relevant coverage and lint requirements. Resolve missing evidence for the staged change using its selected verification approach.
24
+ - The discovered authoritative spec/plan pair, when relevant to this commit. For HTML,
25
+ load `<plugin-root>/includes/artifacts.md` and read the exact spec/plan
26
+ identity, task progress and criteria through typed operations. `eligible`
27
+ gives scheduling advice, **not** authority, verification or a reason to forbid
28
+ committing already-authorized work. `REVIEW` and `DONE` describe work
29
+ progress, not independent checks.
30
+
31
+ A plan may contain unfinished or unverified tasks: list these accurately in
32
+ the commit report and do not claim the whole feature is verified. This gate's
33
+ actual authorization, selected staged diff, applicable test results, secrets,
34
+ security and migration controls still apply. Do not call
35
+ `_preflight_current_acceptance` for ordinary commits or manufacture acceptance
36
+ receipts to replace real test output. A caller requiring an explicit
37
+ receipt-backed *proof claim* may use that separate validator, but it does not
38
+ grant permission to commit.
40
39
 
41
40
  ## Phase 1 — Permission · gate: BLOCK
42
41
 
@@ -75,20 +74,24 @@ Gate: the staged set is type-homogeneous with a single type and scope.
75
74
  Read the test, lint, and secrets-scan commands from `tech-stack.md`, then apply
76
75
  `<plugin-root>/includes/verification-boundary.md`:
77
76
 
78
- - Run the impact-bounded local tests that directly cover the staged paths and obligations. Any failure blocks. Repository-wide and cross-platform suites belong to exact-head hosted CI before merge, not this commit gate.
79
- - Run lint, and the type-check if the project is statically typed. Zero errors.
77
+ - Establish impact-bounded local test results that directly cover the staged paths and obligations. Reuse inspected results while their relevant source, inputs and command match; run missing or affected checks. Any unresolved failure blocks. Repository-wide and cross-platform suites belong to exact-head hosted CI before merge.
78
+ - Establish current lint results, and type-check results if the project is statically typed. Reuse applicable observed results under the same source/input rule. Zero errors.
80
79
  - Run the secrets scan on ALL staged files, regardless of commit type. Any finding blocks.
81
80
  - **Security gates (mandatory routing):** if the staged diff touches crypto/TLS or secret patterns, route it through `crypto-compliance` (`<plugin-root>/routines/crypto-compliance/SKILL.md`) and/or `secret-handling` (`<plugin-root>/routines/secret-handling/SKILL.md`) — they scan against `security-controls.md` and, on pass, record the diff-bound marker `.codearbiter/.markers/security-gate-passed` (via `hooks/security-pass.py`). This is not optional: the PreToolUse commit hook **H-09b/H-10b blocks the commit** until that gate pass is recorded AND covers every sensitive line being committed.
82
81
  - **Migration gate (mandatory routing):** if the staged set contains a database migration (Phase 3 flags it; the detection rule is `_hooklib.is_migration_path` — default migration globs, extendable/narrowable via a `migration-paths` block in `security-controls.md`), dispatch the `migration-reviewer` agent (`<plugin-root>/agents/migration-reviewer.md`). **On a genuine PASS only**, record the content-bound marker `.codearbiter/.markers/migration-gate-passed` by resolving the interpreter once by presence — `PY=python3; { command -v python3 >/dev/null 2>&1 && python3 --version >/dev/null 2>&1; } || PY=python` — never `python3 X || python X`, which reruns X on any nonzero exit (#577) — and running `"$PY" "<plugin-root>/hooks/migration-pass.py"`. This is not optional: the PreToolUse commit hook **H-14 blocks the commit** until the pass is recorded AND covers every migration file being committed (by content digest, no freshness window — an edit to a reviewed migration re-blocks). This closes the bare-`/commit` / small-lane gap from issue #77. On a BLOCK, do not record the pass.
83
82
  - **CI/deploy review (mandatory routing, no marker gate):** if the staged set touches a CI/CD workflow (`_hooklib.is_ci_path` — defaults extendable via a `ci-paths` block in `security-controls.md`) or a deployment/IaC manifest (`_hooklib.is_deploy_path` — `deploy-paths` block), dispatch the `security-reviewer` agent (`<plugin-root>/agents/security-reviewer.md`). This is the enforcement point the advisory `post-write-edit` reminders **H-15/H-16** point to, and it closes the bare-`/commit` / small-lane gap for CI/deploy (the `/review`, `/pr`, `/checkpoint`, and sprint lanes already dispatch it). Unlike crypto/secret/migration there is **no commit-block marker** — a CI workflow runs only once merged and IaC bites only on apply, so a BLOCK-level finding halts the commit via Phase 6 review, but routine CI/deploy edits are not gated per-commit. Act on the findings by severity; do not record a marker.
84
83
 
85
- Record each result (PASS / BLOCK) for the report.
84
+ Required specialized review may reuse an existing review of the same source,
85
+ requirements, findings and verification inputs. Dispatch only missing or affected
86
+ review work. Required security and migration markers must still cover the actual
87
+ staged content; a prior review does not waive their writers or hook checks.
88
+ Record each result (PASS / BLOCK), its source and whether it was reused or run.
86
89
 
87
90
  Gate: the applicable focused tests, lint/type-check, secrets scan, and specialized gates all PASS. Any failure halts the commit until fixed and re-run. This gate does not claim that exhaustive hosted CI has run; `finishing-a-development-branch` proves that separately before merge.
88
91
 
89
92
  ## Phase 5 — Behavioral proof · gate: BLOCK
90
93
 
91
- Apply the shared fresh-run discipline in `<plugin-root>/includes/fresh-verification.md`, with
94
+ Apply the current-evidence rules in `<plugin-root>/includes/fresh-verification.md`, with
92
95
  **the spec's acceptance criterion** as the target — prove the behavior against the spec, not against a
93
96
  self-report.
94
97
 
@@ -97,15 +100,47 @@ self-report.
97
100
  HTML, use the exact criterion and task records returned by symbol-scoped
98
101
  engine `read`; never scrape the rendered document. If none exists, derive the
99
102
  smallest command that exercises the claimed behavior.
100
- - Run it fresh in this phase, read its output and exit code, and confirm the observed behavior matches the spec's acceptance criteria. A mismatch, or an unverifiable claim, blocks.
103
+ - Inspect the applicable output and exit code and confirm the observed behavior matches the spec's acceptance criteria. Reuse the Phase 4 or implementation result when it already proves that criterion on unchanged relevant inputs. Run a separate proving command only when existing evidence is missing, affected or insufficient. A mismatch or unverifiable claim blocks.
101
104
 
102
105
  **Stakes:** a behavioral-proof mismatch means the change does not do what the spec claims — state what would ship broken if this passed ("the retry path never fires; a transient error would hang the caller"), not just "proof mismatch." That gap is exactly what a green-looking suite hides.
103
106
 
104
- Gate: the change is proven to do what it claimed by fresh evidence — command output and exit code read in this phase. A self-reported "it works" does not pass.
107
+ Gate: inspected current command output and exit code prove the claimed behavior. The phase change alone does not require another run. A self-reported "it works" does not pass.
105
108
 
106
109
  ## Phase 5.5 — Provenance auto-heal (conditional)
107
110
 
108
- Compute the heal worklist from the staged set via `_provenancelib.heal_worklist(staged_paths, provenance, current_hashes)` — the subset of staged paths that are `drift_trigger:true` provenance entries whose recorded hash has diverged or is absent. **Empty worklist → skip this phase entirely; most commits pay nothing** (cost guarantee: ordinary commits touching no provenance source do zero re-scout work).
111
+ Partition the loaded records by schema. Select only recorded content paths or
112
+ membership scopes/predicates intersecting staged sources. Commits touching no
113
+ recorded source do no re-scout work. An empty legacy worklist says nothing about v2.
114
+ Include deleted paths and both sides of renames in `staged_paths`, for example
115
+ with `git diff --cached --name-only --no-renames`.
116
+
117
+ **Managed v2 pairs:** acquire one bounded snapshot covering the selected documents'
118
+ recorded dependencies and target preimages. Call `assess_context_provenance` for
119
+ those document IDs with its action-boundary snapshot probe, then reuse that
120
+ snapshot and assessment in
121
+ `_provenancelib.v2_heal_worklist(staged_paths, provenance, snapshot, assessment)`.
122
+ Its `claims` identify the affected document, field, claim and staged source paths;
123
+ they select inspection work, not permission to write. These paths are staged triggers;
124
+ inspect the selected claims' complete recorded evidence before refreshing their fields,
125
+ including any changed unstaged dependency. Preserve uninspected claims and bindings.
126
+ Report `unknown` entries and defer that document's automatic
127
+ update; do not label it fresh or block independent commit work.
128
+
129
+ When inspected claims still hold, prepare an `update` of the selected owned fields
130
+ with unchanged content and current source evidence. When a claim changed, propose
131
+ the bounded content correction for Phase 6 review. Use the typed `context-preview`
132
+ and `context-apply` procedure in
133
+ `<plugin-root>/routines/context-check/SKILL.md`, retaining exact expected pair hashes,
134
+ the returned preview reference/digest and all unselected bytes. Reuse the existing
135
+ maintenance authorization; do not enter a second approval cycle. Native apply
136
+ rechecks the source and pair identities and writes both files together. Read back
137
+ the result. Never pass v2 records to `rebaseline` or write them directly. Stage the
138
+ resulting pair by explicit paths and secrets-scan every newly staged file.
139
+
140
+ **Legacy v1 records:** compute the heal worklist via
141
+ `_provenancelib.heal_worklist(staged_paths, provenance, current_hashes)` — staged
142
+ `drift_trigger:true` entries whose hash diverged or is absent. An empty v1 worklist
143
+ skips only this legacy branch.
109
144
 
110
145
  Non-empty worklist → call `_provenancelib.compute_drift(provenance, current_hashes)` to retain the document/source mapping. For each stale document in that drift report, get its record as `doc_provenance` and call `_provenancelib.changed_scope(doc_provenance, drift)`. Intersect that document's drifted paths with the worklist; skip a document when the intersection is empty. The hash map can omit unstaged paths, so a missing entry outside the worklist must not broaden this commit's re-scout. Confirm that every selected worklist path maps to at least one stale document after this filtering; if a record is malformed or the mapping is incomplete, STOP and report the gap rather than treating the path as fresh.
111
146
 
@@ -217,7 +252,7 @@ Gate: the commit lands and `git status` is clean. Unexpected uncommitted changes
217
252
  - MUST NOT run `git add -A`, `git add .`, or any wildcard staging.
218
253
  - MUST NOT commit while any test is failing, any lint error stands, or any secret is present.
219
254
  - MUST NOT turn exhaustive repository-wide or cross-platform CI into a local prerequisite when the shared `verification-boundary` assigns it to exact-head hosted CI.
220
- - MUST NOT accept a self-reported "it works" — prove the behavior against the spec with a fresh command run (Phase 5) before committing.
255
+ - MUST prove the behavior against the spec with inspected current evidence (Phase 5); a self-reported "it works" is insufficient.
221
256
  - MUST NOT skip, disable, or work around any automated gate.
222
257
  - MUST NOT commit a staged database migration without a recorded migration-review pass — the H-14 hook blocks it until `migration-reviewer` passes and `hooks/migration-pass.py` records the content-bound marker.
223
258
  - MUST NOT `--amend` after a pre-commit hook failure — create a new commit.
@@ -1,20 +1,19 @@
1
1
  ---
2
2
  name: context-check
3
- description: "Audit stale provenance-tracked docs on request. Report first; re-scout or re-baseline only for selected docs."
3
+ description: "Inspect context drift and refresh selected source-backed documents under existing authorization."
4
4
  argument-hint: "(none)"
5
5
  ---
6
6
 
7
7
  # context-check
8
8
 
9
- An optional, on-demand drift audit for bypass cases: a merge or an external
10
- edit drifted a tracked source file you are not about to commit, so commit-gate's
11
- Phase 5.5 auto-heal did not fire. This skill reports stale docs and lets you
12
- act on each one individually.
9
+ Inspect context drift or refresh selected source-backed documents. This includes
10
+ drift from a merge or external edit that commit-gate's Phase 5.5 auto-heal did
11
+ not cover, and an explicitly requested full refresh of initialized context.
13
12
 
14
13
  This skill is NOT in the daily loop. Commit-gate auto-heal (Phase 5.5,
15
- `heal_worklist`) owns the routine maintenance path. Invoke this only when drift
16
- was introduced outside a commit (e.g. a direct push, a merge you did not
17
- author, a manual file edit).
14
+ `heal_worklist` for v1 and `v2_heal_worklist` for managed pairs) owns routine
15
+ maintenance. Reuse existing selection and
16
+ authorization for requested refresh; an audit-only request remains read-only.
18
17
 
19
18
  <!-- catalog-compatibility-notice:start -->
20
19
  > Compatibility route. Prefer `/ca-status drift` for new explicit usage. The retained entry
@@ -27,9 +26,11 @@ author, a manual file edit).
27
26
  Use this owner for a requested provenance drift audit, `/ca-status drift`, or
28
27
  the explicit `/ca-context-check` compatibility entry. Explanation-only questions
29
28
  and ordinary status snapshots remain read-only answers, not repair requests.
30
- Report first. Write only after the user selects re-scout or re-baseline for that
31
- document; never change an unselected derived document. This owner neither stages
32
- nor commits. Routine commit-gate auto-heal is unchanged.
29
+ Report first for an audit-only request. A direct request to refresh selected
30
+ documents or the full project context supplies that selection; reuse the
31
+ existing authorization instead of asking again per document. Never change an
32
+ unselected derived document. This owner neither stages nor commits. Routine
33
+ commit-gate auto-heal is unchanged.
33
34
 
34
35
  An **initialized refresh** belongs to this existing owner after an explicit
35
36
  selection. It is separate from initial population: do not call the initialized
@@ -73,7 +74,7 @@ is unknown coverage, even when a neighboring v1 or v2 record is usable. Report
73
74
  the usable records and the unknowns separately; never turn an empty legacy
74
75
  drift report into a fresh verdict for v2. `v2_current` acknowledges matching
75
76
  identities only. `semantic: unverified` and `verified_fresh: false` remain in
76
- force until the owning semantic review and writer receipt establish otherwise;
77
+ force: only actual evidence can support a narrower semantic claim;
77
78
  changing hashes or choosing re-baseline does not perform that review.
78
79
 
79
80
  Only if the relevant legacy drift report is empty and v2 coverage/identities
@@ -103,8 +104,7 @@ stale path. Do not offer an automatic write for an unbounded scope.
103
104
  ### Unsupported human content and owner reconciliation
104
105
 
105
106
  An unsupported human Markdown layout, ambiguous duplicate anchor, unparseable
106
- custom section, oversized document or absent managed ownership record is a
107
- write refusal for that document, not a reason to erase it or abandon safe
107
+ custom section or oversized document is a write refusal for that document, not a reason to erase it or abandon safe
108
108
  task-time reading. An unrelated unknown section in an otherwise supported
109
109
  document remains unowned and byte-identical during a supported field update.
110
110
  Preserve exact bytes and report the specific unsupported or unowned span.
@@ -116,36 +116,38 @@ project. Surface a real conflict without silently displacing either source.
116
116
 
117
117
  If the requested change would adopt or replace normative instructions, route
118
118
  the proposal to its actual owner and obtain that owner's actual approval before
119
- any supported bounded update. An unsupported template needs explicit
120
- reconciliation or a qualified per-kind transition through the existing context
121
- writer. Its refusal never authorizes raw Write/Edit fallback or a regex rewrite.
119
+ any supported bounded update. Missing or legacy v1 provenance may use explicit native `adopt` with current
120
+ evidence and selected supported spans, preserving the old provenance preimage.
121
+ An unsupported template still needs reconciliation through its actual owner or
122
+ a supported writer transition. Its refusal never authorizes raw Write/Edit fallback or a regex rewrite.
122
123
  Task, question, audit, release and ADR files remain with their existing writers;
123
124
  do not normalize, recreate or edit their history during context refresh.
124
125
 
125
126
  ### Step 3 — Selected initialized refresh
126
127
 
127
- For each stale or bounded affected document, present supported re-scout,
128
- re-baseline and defer choices; wait for the user's selection. A user may instead
129
- explicitly select full refresh. Do not interpret
130
- `status drift`, the drift report itself or an ordinary status request as that
131
- selection. Record the selected documents and declared affected source paths
132
- before any scout or write. An incremental refresh re-scouts only the selected
133
- drifted paths and affected logical assignments. A full refresh declares all six
134
- logical assignments and all five content documents. Retain prior coverage as
135
- prior evidence; a scoped `join_scout_reports` result has `full_coverage: false`
136
- and must never be described as a newly completed full scan.
137
-
138
- **re-scout** — dispatch an incremental re-scout of the drifted paths for this
139
- doc, scoped to those paths only. Use the context-creation containment profile,
140
- run budget, `admit_scout_attempt` and `join_scout_reports` contract for exactly
141
- the declared affected assignments. A missing/failed report, changed snapshot,
142
- contradiction or unresolved task-dependent decision blocks the selected write.
143
- If the claims still hold, a valid selected owned-field metadata refresh may
144
- keep document bytes identical only when proposed v2 provenance actually
145
- changes. Missing selection and unchanged proposed provenance refuse; retain
146
- the stale pair and do not claim freshness in those cases. Any update still
147
- requires current source evidence, exact preview approval and receipt-only
148
- apply. Surface the proposed content and provenance pair for exact review.
128
+ Use the user's selected documents and affected scope. If only an audit was
129
+ requested, offer reinspection, re-baseline and defer choices before writing.
130
+ A request for full refresh already selects all five content documents and all
131
+ six logical categories; do not repeat that question. Record the selection and
132
+ source paths, then inspect only what those claims need. Keep the initialized
133
+ marker and prior history. Full inspection accounts for all six categories;
134
+ incremental inspection does not claim a new full scan.
135
+
136
+ **re-scout / reinspect** — use direct bounded inspection or optional scoped
137
+ agents for the selected claims. The context-creation evidence and gap rules
138
+ apply. When structured reports help, `join_scout_reports` tracks their declared
139
+ coverage; a scoped result has `full_coverage: false`. The helper is not a
140
+ permission or containment check. A missing report can be replaced by direct
141
+ inspection, but failed or uninspected work never becomes evidence of absence.
142
+ Recheck changed source snapshots and resolve contradictions before their
143
+ claims are written. Unrelated gaps do not hold independent selected work.
144
+
145
+ If claims still hold, a selected owned-field metadata refresh may keep document
146
+ bytes identical when current evidence changes the v2 provenance. Missing
147
+ selection and unchanged proposed provenance refuse rather than claim a refresh.
148
+ Surface the proposed content and provenance pair, inspect its source bindings,
149
+ and apply within the selected authorization. Review consequential or disputed
150
+ claims independently when useful; a matching digest does not verify semantics.
149
151
 
150
152
  **re-baseline** — the legacy v1 provenance choice may acknowledge a verified
151
153
  cosmetic change through its existing owner, where applicable. For an enrolled
@@ -155,22 +157,56 @@ If no field is selected or the proposed pair is a true no-op, retain the stale
155
157
  pair and defer that selection. Never directly write the v2 provenance or use
156
158
  the legacy `rebaseline` helper as a fallback for it.
157
159
 
158
- **full refresh** — only after explicit selection, use the same qualified
159
- containment and bounded join with `mode: full` and six complete logical reports.
160
- Synthesize all five content documents from the new evidence and reconcile gaps
161
- under the context-creation Phase 3–4 rules. Do not enter its Phase 6 lock.
160
+ **full refresh** — use bounded inspection across all six categories and
161
+ synthesize all five content documents from current evidence. Preserve unknowns
162
+ and reconcile material user decisions under context-creation Phase 3–4. Do not
163
+ enter its Phase 6 lock for an already initialized repository.
162
164
 
163
- For each selected document, submit its finite typed `update` preview through
165
+ For a selected whole-document refresh, prepare a UTF-8 draft inside the workspace
166
+ that retains user-owned content outside the requested change. The installed CLI
167
+ collects bounded source hashes and chooses create/adopt/update from the current
168
+ pair. Substitute the actual inspected repository-relative source paths; repeat
169
+ `--source` for each supporting file. For example:
170
+
171
+ ```text
172
+ python "<plugin-root>/hooks/init-codearbiter.py" --root "<project-root>" --context-draft "context-code-map-draft.md" --document code-map --source "src/main.py"
173
+ ```
174
+
175
+ This retains an internal preview but does not change the content document or
176
+ provenance. Inspect the returned diff, then apply the exact returned reference
177
+ and digest:
178
+
179
+ ```text
180
+ python "<plugin-root>/hooks/init-codearbiter.py" --root "<project-root>" --context-apply "<preview_ref>" --preview-sha256 "<preview_sha256>"
181
+ ```
182
+
183
+ The source list must support the draft; it is not an automatic semantic review.
184
+ The convenience path records `semantic_review: unreviewed`. Use typed field
185
+ previews below when only specific managed fields are selected.
186
+
187
+ For each selected document, send the typed preview through
164
188
  `python "<plugin-root>/hooks/init-codearbiter.py" --root <exact-root> --context-request <request-file>`.
165
- The installed qualified context writer checks the existing document/provenance
166
- pair, current source evidence, field ownership and protected target set. Review
167
- the exact proposed pair and obtain its own native `approve-context` reply; apply
168
- only its receipt through the same `--context-request` bridge. Read back the
169
- committed pair and confirm the standalone `<!--INITIALIZED-->` marker remains
170
- for `CONTEXT.md`. The writer's five content targets exclude task, question and
171
- audit history. Never edit those owners as a side effect, hand-write a provenance
172
- record, bypass a refusal, stage or commit here. If the installed writer or
173
- qualified scout profile is unavailable, report that boundary and retain state.
189
+ The request uses `operation: preview` and a `preview` object. Native
190
+ `context-preview` supports `create` for a genuinely absent document, explicit
191
+ `adopt` for supported missing/v1 provenance, and `update` for a managed v2 pair.
192
+ Supply the exact expected document/provenance hashes, selected fields, typed
193
+ content and source evidence. Keep request files inside the workspace.
194
+
195
+ Inspect the returned diff and preserved content. Apply with `operation: apply`,
196
+ `preview_ref` and `preview_sha256` through the same bridge;
197
+ native `context-apply` rechecks the preview and current identities under its
198
+ lock and writes the selected document/provenance pair together. No approval
199
+ receipt, actor ticket or qualified scout profile is a prerequisite for ordinary
200
+ already-authorized refresh. This is compare-and-swap protection, not a second
201
+ permission system. A stale preview requires reinspection, never an overwrite.
202
+ After a lost response, inspect the transaction and retry its identical request
203
+ and operation ID or use native recovery; do not start a duplicate write.
204
+
205
+ Read back the committed pair and confirm `<!--INITIALIZED-->` remains for
206
+ `CONTEXT.md`. Keep unowned spans byte-identical and retain legacy provenance
207
+ history. Task, question, audit, release and ADR history stay with their actual
208
+ writers. Never hand-write a provenance record or bypass a refused unsupported
209
+ shape. A missing safe writer stops that write, not authorized task-time reads.
174
210
 
175
211
  **defer** — do nothing for this doc now. The drift line will reappear at the
176
212
  next SessionStart. Use when the change is in-progress and the doc update should