@awak-app/simy-cli 0.5.15 → 0.5.17

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 (45) hide show
  1. package/README.md +78 -15
  2. package/package.json +2 -2
  3. package/src/agent.js +33 -1
  4. package/src/cli-contract.js +1 -1
  5. package/src/codex-plugins/simy/.codex-plugin/plugin.json +5 -6
  6. package/src/codex-plugins/simy/hooks/README.md +17 -0
  7. package/src/codex-plugins/simy/hooks/connection-reminder.mjs +184 -0
  8. package/src/codex-plugins/simy/hooks/hooks.json +27 -0
  9. package/src/connection-discovery.js +49 -0
  10. package/src/console/app.js +2 -2
  11. package/src/orchestrator/audit.js +47 -5
  12. package/src/orchestrator/budget.js +1 -1
  13. package/src/orchestrator/checklist-continuation.js +21 -0
  14. package/src/orchestrator/completion-contract.js +1 -1
  15. package/src/orchestrator/contract.js +2 -0
  16. package/src/{codex-plugins/simy/skills/agentic-delivery-loop/SKILL.md → orchestrator/delivery/WORKFLOW.md} +121 -13
  17. package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/acceptance-evidence.md +27 -3
  18. package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/change-boundary-matrix.md +1 -1
  19. package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/delivery-levels.md +78 -27
  20. package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/minimum-completion.md +3 -3
  21. package/src/orchestrator/delivery/references/pr-closure.md +203 -0
  22. package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/state-and-receipts.md +4 -1
  23. package/src/orchestrator/delivery/references/ux-specification.md +98 -0
  24. package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/scripts/production-contract.mjs +1 -1
  25. package/src/orchestrator/delivery-level.js +19 -0
  26. package/src/orchestrator/evidence.js +64 -5
  27. package/src/orchestrator/independent-audit.js +18 -0
  28. package/src/orchestrator/index.js +7 -0
  29. package/src/orchestrator/instruction.js +32 -3
  30. package/src/orchestrator/loop.js +4 -1
  31. package/src/orchestrator/minimum-completion.js +2 -2
  32. package/src/orchestrator/pr-closure.js +26 -0
  33. package/src/orchestrator/pr-preparation.js +420 -0
  34. package/src/orchestrator/presentation.js +2 -2
  35. package/src/orchestrator/result.js +8 -2
  36. package/src/orchestrator/ux-specification.js +20 -0
  37. package/src/runner.js +104 -1
  38. package/src/sqm/agent-skill.js +39 -7
  39. package/src/codex-plugins/simy/skills/agentic-delivery-loop/agents/openai.yaml +0 -5
  40. /package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/chrome-user-verification.md +0 -0
  41. /package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/cross-repository-control.md +0 -0
  42. /package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/local-sqm-evidence.md +0 -0
  43. /package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/references/shared-system-specifications.md +0 -0
  44. /package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/scripts/check-acceptance.mjs +0 -0
  45. /package/src/{codex-plugins/simy/skills/agentic-delivery-loop → orchestrator/delivery}/scripts/check-minimum-completion.mjs +0 -0
@@ -0,0 +1,203 @@
1
+ # PR closure: SIMY Web / CLI procedure
2
+
3
+ This procedure is loaded by the Web/CLI executor and independent auditor through
4
+ `src/orchestrator/pr-closure.js`. It is not a local Codex skill or a GitHub hook.
5
+ It adds a closure safety gate to the existing delivery workflow, not a new remote
6
+ mutation tool, permission or terminal state. Closing a PR never proves delivery.
7
+
8
+ Flow: scope/authority -> original requirements and exact revisions -> before/after
9
+ table -> real outcome verification -> independent review -> decision -> freshness
10
+ and authority recheck -> authorized close -> remote read-back and durable receipt.
11
+ When blocked, stop the close, not independent authorized investigation. Reuse the
12
+ run's attempt/time/cost limits; do not repeat unchanged failed checks indefinitely.
13
+
14
+ ## 1. Define the scope and reason
15
+
16
+ Record repository/PR, purpose, beneficiary, source requirements and non-goals.
17
+ Distinguish merged, duplicate/fully superseded, transfer to unfinished work, and
18
+ intentional cancellation/retirement. An already merged PR needs its actual merge
19
+ identity verified, not a manual unmerged close. Merge is not deployment.
20
+
21
+ An audit/table request is read-only. Record close and comment-posting authority
22
+ separately; a factual same-PR comment must be covered by explicit authorization
23
+ or governing policy. Otherwise prepare an unposted draft. Do not infer authority
24
+ to merge successors, deploy, delete branches or reopen an already closed PR.
25
+ An existing clear authorization need not be requested twice; a newly discovered
26
+ loss of functionality requires an informed decision on that consequence.
27
+
28
+ ## 2. Freeze requirements and comparison identities
29
+
30
+ Use original requests, acceptance criteria and approved decisions as the oracle,
31
+ not the closing comment or candidate's own tests alone. Reuse stable acceptance
32
+ IDs from the delivery charter. Independently reconcile the original sources with
33
+ the ID list so an omitted requirement cannot disappear before validation.
34
+
35
+ Record full old PR head and merge-base SHAs, current target base, successor and
36
+ companion heads, exact integrated candidate, PR/merge state, build/runtime identity,
37
+ flags, permissions/tenant, environment and observation time. Track deployed state
38
+ separately; never infer it from a branch. Preserve a recoverable reference to
39
+ unmerged source before cleanup. An SHA without retrievable objects is not backup.
40
+
41
+ Keep requested, intended-in-code, observed-in-runtime, absent and unknown distinct.
42
+ An unavailable old environment does not prove a feature never existed. Old missing
43
+ code does not waive an explicit requirement, and labels do not prove old guarantees.
44
+
45
+ ## 3. Persist the before/after table
46
+
47
+ Use [UX behavioral completeness](ux-specification.md) for both sides of the
48
+ comparison. A concise table cell must link to the complete interaction contract;
49
+ do not reduce the comparison to feature labels or omit divergent branches.
50
+
51
+ Use the existing [acceptance evidence](acceptance-evidence.md) and stable IDs.
52
+ Keep separate bound results for each context and link the comparison to them;
53
+ do not overwrite base-only results with combined or live results. Persist outside
54
+ chat and retain failed/pending rows. Minimum comparison columns:
55
+
56
+ | ID / requirement source | Persona, condition, required outcome | Old PR intended / observed | Current base alone | Base + successors | Deployed target | Decision, gap, owner, remediation PR | Evidence |
57
+ | --- | --- | --- | --- | --- | --- | --- | --- |
58
+ | Stable criterion | Trigger, real entry, action, result, next action | Exact revision, evidence level | Exact revision, evidence level | Exact integrated identity | Observed identity or unknown | Retained / approved change / transferred / missing / unknown | Source locations, raw results, artifact hashes, times |
59
+
60
+ For each affected journey cover real navigation, discoverability, first use and
61
+ empty data, flags/roles/ownership; transferred input/context, confirmation, state
62
+ changes, actual execution, usable output and next action; persistence, reload and
63
+ session return, history/sync, privacy and data migration; loading, no-match,
64
+ permission denial, error, cancellation and retry/recovery. Include accessibility
65
+ and device variants when affected. Extra clicks or lost controls may be regressions
66
+ even if an API is unchanged.
67
+
68
+ For workflow products, separately account for existing-workflow reuse, composition,
69
+ conversational design of a saved workflow, immediate ad-hoc work without saving a
70
+ workflow, and background discovery/learning. Explicitly test the no-workflow or
71
+ no-match branch: can the user ask for help, preserve intent, clarify/design/execute
72
+ as required and obtain a usable result? A catalog recommender or background
73
+ learning is not proof of conversational/ad-hoc fallback. Classify each capability
74
+ against authoritative requirements; do not invent an old capability or silently
75
+ exclude one because old code lacked it.
76
+
77
+ Inventory every changed file, including deletions/renames, contracts, flags, tests
78
+ and affected consumers outside the diff. Map each to criteria or a justified
79
+ non-behavioral classification. Trace all requirements forward to proof, removed
80
+ behavior back to retained behavior or approved retirement, and added permissions,
81
+ data collection, automation, costs, defaults or steps back to authorized scope.
82
+ Identical blobs, ancestry and file counts prove accounting, not UX equivalence.
83
+
84
+ ### Yellow/red rows must become remediation PR work
85
+
86
+ Display unresolved partial/changed/unverified outcomes as yellow (🟡), and verified
87
+ missing/regressed outcomes as red (❌). Keep factual behavior, evidence sufficiency
88
+ and approved scope separate; uncertainty alone is not proof of a product defect.
89
+ For every yellow/red row, create a new remediation PR for the required repair or
90
+ verification within the active task's implementation/commit/push/PR authority.
91
+ Group rows only when they form one coherent behavior change; do not mechanically
92
+ create one PR per row or combine unrelated fixes. Use a Draft PR while unfinished.
93
+ Before creation, check existing remediation PRs: reuse an exact open match with
94
+ explicit criterion coverage rather than creating duplicate competing work. A broad
95
+ successor link does not count without that mapping.
96
+
97
+ Record criterion IDs, original PR, observed gap/evidence, required outcome, owner,
98
+ repository/base, tests/E2E and acceptance gates in each remediation PR. Add its real
99
+ URL and state to every covered table row; include dependencies and re-evaluation
100
+ triggers. Evidence-only yellow rows need the missing verification, not speculative
101
+ product changes. An unresolved product choice remains `needs_decision`; do not
102
+ choose a new specification just to open a PR. If implementation or publication is
103
+ unauthorized, blocked or outside the current budget, record a concrete PR plan and
104
+ the missing decision/authority, but do not claim a PR exists. A plan/issue alone
105
+ does not satisfy the requested PR handoff or justify `transfer_ready`.
106
+
107
+ Independent review must reconcile all yellow/red IDs with the actual remediation
108
+ PRs and explicitly named blockers before the original PR can be closed by transfer.
109
+ Creating a PR is not fixing the issue: keep the row non-green until its required
110
+ revision-bound checks pass. Approved changes/retirements may resolve a row only
111
+ with the product decision and applicable safety evidence; preserve its history.
112
+
113
+ ## 4. Verify the actual consumer and independent postconditions
114
+
115
+ Trace normal production entry -> caller -> UI/service -> backend -> persisted
116
+ result -> next user action. Verify actual imports, routes, permissions and flags.
117
+ A surviving component/API used only in fixtures is not a production experience.
118
+ Test the unchanged old candidate where feasible, base alone and exact integrated
119
+ candidate. Inspect the combined behavior, not just mergeability or individual CI.
120
+ Reuse valid bound evidence; do not inflate counts with unnecessary reruns.
121
+
122
+ For browser behavior, use [normal-user verification](chrome-user-verification.md)
123
+ on the complete production-like stack with authorized services and safe fixtures.
124
+ Capture meaningful visible states, errors and correlated technical postconditions
125
+ for the same input/run. Mocked/component E2E, direct API calls and static analysis
126
+ are supporting evidence, not substitutes. Only an exact-runtime live journey proves
127
+ live inheritance. Do not imply that local or merged verification is deployed proof.
128
+ For docs/CLI/library/API work use the actual artifact, command or downstream
129
+ consumer; record why browser checks are inapplicable. Unavailable checks are pending,
130
+ not inapplicable. Never make production writes solely to satisfy this procedure.
131
+
132
+ Preserve initial failures. Classify product, environment and oracle failures with
133
+ independent evidence. Changed assertions/fixtures create a different tested
134
+ candidate and require independent oracle review; do not credit their passes to
135
+ the unchanged original PR. A stale label alone does not explain a missing route.
136
+
137
+ ## 5. Independent review and decision
138
+
139
+ Before the close action, a separate reviewer receives original requirements,
140
+ candidate revisions, complete file inventory, table and raw artifacts, without
141
+ a prescribed verdict. Review omissions, reachability, fallback, integrated results,
142
+ unapproved scope and unfinished dependencies. Record identity-bound findings in
143
+ the existing independent-review receipt. A comment claiming a review occurred is
144
+ not review evidence. Repair only within authority; re-review changed inputs.
145
+ The normal post-execution CLI audit is not a substitute for review before closing.
146
+
147
+ Store these labels in the closure record, not in the delivery-state enum:
148
+
149
+ | Decision | Required evidence and permitted action |
150
+ | --- | --- |
151
+ | `close_ready` | All requirements accounted for, candidate evidence and independent review pass; no hidden loss or pending implementation. State separately whether base-only or live. Deployment may remain an explicit delivery obligation. |
152
+ | `transfer_ready` | Every pending outcome/risk has an accepted owner or authorized assignment, actual open remediation PR with criterion coverage, acceptance gate and re-evaluation trigger; explicit informed administrative-close authorization. No unmapped yellow/red row or unresolved handoff blocker. Not full inheritance/completed delivery. |
153
+ | `retirement_ready` | Explicit product decision retires named outcomes; necessary user-data/migration/safety obligations verified or safely assigned before close. Not equivalence. |
154
+ | `needs_decision` | Lost/changed outcome or trade-off lacks an authoritative human selection; present consequences/options and keep open. |
155
+ | `blocked` | Missing/stale evidence, review, authority, classification or handoff, or unsafe consequence prevents the proposed action/claim. |
156
+
157
+ Unknown/failed applicable rows cannot support `close_ready`. A deliberately
158
+ authorized transfer keeps them non-green and visible. Verify the successor exists,
159
+ is open and carries the actual pending criteria; a link alone is insufficient.
160
+ Do not invent an owner's acceptance. Transfer cannot waive mandatory security,
161
+ privacy, data-integrity or external-contract constraints. Retain the actual highest
162
+ proven delivery state, independently of the closure-task disposition.
163
+
164
+ ## 6. Freshness check, authorized action and read-back
165
+
166
+ Immediately before mutation refresh old head, target base, all successor heads and
167
+ states, integrated identity, checks/review inputs, flags/environment and authority.
168
+ Any changed bound input invalidates affected verification/review under
169
+ [state and receipts](state-and-receipts.md). Inspect and reverify before continuing;
170
+ checking only the old head is insufficient. Use conditional updates if available;
171
+ otherwise read immediately before/after, record residual races and stop on drift.
172
+
173
+ Prepare a factual explanation: reason, exact identities, comparison/evidence/review
174
+ links, approved changes, pending obligations/owners, deployment status and recovery
175
+ reference. Do not say nothing remains if work is unknown or unmerged. Missing close
176
+ authority blocks closing; missing posting authority retains a draft. If policy
177
+ requires a posted explanation, missing posting authority also blocks closing.
178
+
179
+ After an authorized close, read back state, close/merge timestamps and identities,
180
+ any authorized posted explanation, and successor status (open or demonstrably
181
+ resolved). Reconcile ambiguous responses before retrying to avoid duplicate
182
+ actions/comments. On unexpected concurrent changes, preserve evidence and report;
183
+ do not silently reopen or declare success. Audit previously closed PRs read-only,
184
+ separating the historical decision's evidence from today's state.
185
+
186
+ ## 7. Durable receipt and handoff
187
+
188
+ Add a `closure` section to the existing completion/handoff evidence record, reusing
189
+ its run/input digest, idempotency key and append-only rules. Record target/reason,
190
+ decision, comparison/context digests, criterion/file coverage, all non-green rows,
191
+ review and artifact references/hashes, human decisions and separate authorities,
192
+ pre/post state/timestamps, mutation identity, comment ID/URL or unposted draft,
193
+ pending owners/gates/triggers, yellow/red-ID-to-remediation-PR mappings and blocked
194
+ PR plans, and source recovery references. Record unperformed
195
+ actions as unperformed; reconcile retries with the same logical action identity.
196
+ This documented section is not a new automatically validated CLI schema.
197
+
198
+ Preserve the table, relevant raw proof, review and recoverable unmerged source in
199
+ an approved durable location before deleting temporary worktrees. Verify links
200
+ remain accessible and remove secrets/unrelated personal data. Never remove the
201
+ only evidence/source copy. Administrative closure can finish a scoped closure task,
202
+ not unfinished feature delivery. Promise ongoing monitoring only if authorized and
203
+ actually configured; otherwise hand off to the recorded owner/tracking item.
@@ -14,7 +14,10 @@ Persist one controller-owned snapshot with at least:
14
14
  - acceptance-source identities and digests, architecture boundaries, applicable
15
15
  rule decisions, human-decision receipt IDs, approved canonical sources and
16
16
  their precedence and fallback semantics, risk tier, requested/effective
17
- delivery levels, the safety ceiling reason, and chat-confirmation receipt;
17
+ delivery levels, numbering version, safety floor and reason, complete five-level
18
+ comparison with per-level hour estimates and assumptions, recommendation and
19
+ rationale, and chat-confirmation receipt; preserve legacy numbering and record
20
+ verified conversions separately rather than rewriting historical choices;
18
21
  - repository, base SHA, head SHA, companion SHAs, merge SHA, image digests, and
19
22
  deployed revision;
20
23
  - target environments, user journey, user/tenant fixture identities, and
@@ -0,0 +1,98 @@
1
+ # UX specification: behavioral completeness
2
+
3
+ Apply this standard to every UX description across the SIMY Web/CLI delivery loop:
4
+ requirements, As-Is/To-Be, design, implementation mapping, acceptance criteria,
5
+ verification records, reviews, release, before/after comparisons, closure and handoff.
6
+ The quality target is **behavioral completeness and verifiability**, not prose length.
7
+ Expand until no material user-observable behavior must be guessed; stop expanding
8
+ when additional text only repeats or introduces unsupported scope.
9
+
10
+ ## Unit of description and decomposition
11
+
12
+ An **observable interaction unit** describes one coherent transition from a stated
13
+ user context to an observable outcome, including the user's control and the system's
14
+ response. A feature name or a list of implementation components is not such a unit.
15
+ Reuse stable UX/acceptance IDs and link finer units to their parent criterion. Do not
16
+ create a second competing source of requirements or silently replace frozen IDs.
17
+
18
+ Split a unit when the actor, prerequisite, choice, observable state, postcondition
19
+ or recovery obligation differs materially. Also split independently falsifiable
20
+ claims so a partial failure cannot hide inside a broadly passing row. Retain an
21
+ end-to-end criterion joining the units: local completeness does not prove a usable
22
+ journey. Derive the necessary granularity from actual requirements and system
23
+ boundaries, never from a fixed number of screens, steps, rows or words.
24
+
25
+ ## Semantic obligations for every unit
26
+
27
+ Each obligation must have explicit content, a precise reference to shared content,
28
+ or an authoritative non-applicability reason. These are semantic requirements for
29
+ the canonical specification, not additional mandatory fields in the CLI JSON schema.
30
+
31
+ | Obligation | Required description |
32
+ | --- | --- |
33
+ | Actor and intent | Who acts or receives value, what they seek, and how the outcome serves that intent. |
34
+ | Context and preconditions | Relevant prior state, available information, authority and constraints that determine whether and how the experience is possible. |
35
+ | Trigger and reachability | What initiates the unit, how the actor reaches it, and which prerequisite or preceding unit supplies the entry state. |
36
+ | Perception and comprehension | Information and feedback available to the actor, its timing and meaning, and how it communicates current state, consequences and what can happen next. Do not assert a mental state as observed without evidence. |
37
+ | Action, choice and control | Permitted actions, required input, alternatives, decision ownership, confirmation and reversibility where applicable, with their consequences. |
38
+ | System response and transition | Response to each relevant action or event, observable intermediate and terminal states, and applicable timing, ordering and consistency constraints. |
39
+ | Usable outcome and postconditions | What the actor can actually use after the transition, affected state or effects, and the conditions that distinguish complete, partial and unsuccessful outcomes. |
40
+ | Continuation and handoff | Next permitted action or terminal boundary, destination/owner and context retained across the transition. A handoff must identify its receiving preconditions. |
41
+ | Alternatives, failure and recovery | Conditions producing materially different behavior, what the actor perceives, available recovery/control and retained or lost state. A terminal state must be intentional, not an unexplained dead end. |
42
+ | Acceptance oracle and provenance | Requirement source, observable pass/fail predicates, observation method and evidence identity for the same actor/context/revision. Distinguish planned verification from its observed result. |
43
+
44
+ Apply relevant usability, accessibility, privacy, authority and continuity constraints
45
+ to these obligations where they change the experience. Express qualitative requirements
46
+ as observable discriminators; use quantitative thresholds only when grounded in an
47
+ authoritative requirement or an explicitly approved decision. Unspecified values or
48
+ policy remain unknown; never invent them to make the description appear complete.
49
+
50
+ ## Completeness review criteria
51
+
52
+ Use these criteria together, not an average score. A complete description satisfies
53
+ every applicable criterion for its declared scope. A completed form is not proof.
54
+
55
+ | Criterion | Pass condition |
56
+ | --- | --- |
57
+ | Source coverage | Every in-scope user outcome and constraint from the independent acceptance sources maps to identified units; every specified behavior maps back to a source or recorded authorized decision. |
58
+ | Causal continuity | Entry and exit conditions connect across units without an unstated user step, system dependency or context transfer. The complete path reaches a usable outcome or an explicitly justified terminal state. |
59
+ | Branch closure | Each material alternative derived from requirements and actual boundaries has a condition, observable response, consequence and continuation or recovery. Conditions distinguish which response applies. |
60
+ | Control clarity | The actor can determine what they may do, what is automatic, who decides, and the consequences and available reversal of relevant actions. |
61
+ | Observability and falsifiability | An independent verifier can distinguish success, partial success and failure using the stated oracle and evidence method, without inventing expected behavior. |
62
+ | Cross-view consistency | Descriptions of the same intent agree on actors, prerequisites, transitions, authority, outcomes and recovery across all affected surfaces and specification views, or cite an approved difference. |
63
+ | Traceability and freshness | Stable IDs connect source, specification, implementation, checks, observations and unresolved obligations; referenced revisions and context match the claim. |
64
+ | Epistemic separation | Requirements, intentions, observations, assumptions and unknowns are separately identified; lack of evidence is not presented as absence, success or non-applicability. |
65
+
66
+ Perform an **independent reconstruction check**: a reader who did not author the
67
+ implementation must be able to derive the intended interaction and its acceptance
68
+ checks without supplying a material product decision. Review against original
69
+ sources as well as the described units, so omitted behavior cannot pass unnoticed.
70
+ Return gaps by criterion ID, missing obligation, consequence, authoritative question
71
+ or evidence needed, and dependent phase. Do not claim exhaustive coverage beyond
72
+ the declared scope and available sources; disclose unavailable sources and risks.
73
+
74
+ ## Application through the lifecycle
75
+
76
+ | Phase | Required use of the same contract |
77
+ | --- | --- |
78
+ | Discovery and charter | Record known As-Is observations separately from requested outcomes and unknowns; derive coverage and freeze intended behavior before solution-dependent decisions. |
79
+ | Design and implementation | Maintain the source-linked To-Be units and map their obligations to affected paths; inspect dependencies and consistency, without weakening the contract to fit candidate code. |
80
+ | Verification and review | Observe the complete applicable paths and independent postconditions in the same bound context; compare expected and observed behavior unit by unit and end to end. |
81
+ | Repair and scope change | Preserve failed results, record authorized requirement changes and invalidate only affected descriptions/evidence; re-review dependent units and their connected paths. |
82
+ | Release and operation | Identify the target runtime and applicable outcome/guardrail observations; distinguish expected exposure, observed behavior and unresolved operational obligations. |
83
+ | PR closure and handoff | Compare before/after using the same units, retain reachability and recovery detail, map unresolved obligations to authorized remediation work and preserve evidence and ownership. |
84
+
85
+ Persist complete descriptions in the canonical specification and reference their IDs
86
+ from matrices, PRs and receipts. Compact user-facing summaries may omit repetition,
87
+ not material behavior, uncertainty or the link to the full contract. Do not impose
88
+ long transcripts or duplicate the full specification in each progress update.
89
+
90
+ Unknowns are visible work, not a reason to fabricate detail. A material unresolved
91
+ requirement decision blocks dependent design/implementation; a missing runtime
92
+ observation blocks the affected verification or equivalence claim. Discovery and
93
+ independent authorized work may continue. Explicit assumptions retain their source,
94
+ risk and resolution condition; assumption-based behavior cannot be presented as
95
+ verified. Genuine non-applicability needs a reason/source before execution, not a
96
+ post-failure waiver. This is a workflow and independent-review standard; existing
97
+ validators check their documented evidence contracts, not these semantic criteria
98
+ automatically. Do not claim machine enforcement merely because this guide is loaded.
@@ -1,4 +1,4 @@
1
- // Shared by the CLI and the independently installed skill. Keep this module
1
+ // Shared by the CLI and the packaged evidence checker. Keep this module
2
2
  // self-contained so validation never depends on the repository checkout.
3
3
  const cleanString = value => typeof value === "string" ? value.trim() : "";
4
4
  const record = value => value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -0,0 +1,19 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { section } from "./shared.js";
3
+
4
+ export const DELIVERY_LEVELS_PATH = fileURLToPath(
5
+ new URL("./delivery/references/delivery-levels.md", import.meta.url),
6
+ );
7
+
8
+ export function buildDeliveryLevelInstruction({ auditor = false } = {}) {
9
+ return section("delivery_level_contract", [
10
+ `Read the Web/CLI delivery-level contract: ${DELIVERY_LEVELS_PATH}`,
11
+ "Use assurance-ascending-v2: 5 is maximum assurance, 4 protected, 3 balanced, 2 fast, 1 lightest. Higher numbers mean more assurance, not greater task priority. Apply the highest applicable risk/policy floor; never lower mandatory verification or expand authority.",
12
+ "Whenever recommending, confirming or changing a level, present ALL five levels in descending order 5, 4, 3, 2, 1, as a table or clearly separated prose. For EACH show content, verification/review scope, trade-off, task applicability, and task-specific duration in hours. Mark the recommendation and explain its task/risk rationale, even when the user already selected a level; acknowledge a valid selection without asking again. Mark unsafe levels unavailable with reasons; do not hide them.",
13
+ "Estimate numeric lower-to-upper execution and elapsed-hour ranges for the same task scope and endpoint, using observed boundaries, implementation, checks, review, setup, repair and dependency critical path. Separate execution from CI/queue/approval/external waiting; account for parallelism. State assumptions, evidence, uncertainty and confidence. Do not hardcode per-level durations or product examples. Unknown external wait stays explicitly unbounded, with a conditional numeric execution range; never invent a finite total. If execution cannot yet be estimated, show the missing input and discovery step for each affected row and keep the selection packet incomplete pending a defensible range. Explain overlaps or inversions; estimates are not guarantees or permission to skip work.",
14
+ "Record the comparison, estimate basis, recommendation/reason, requested/effective level, numbering version, risk floor and user selection reference in existing charter/decision evidence, not invented CLI API fields. Refresh on material changes. Preserve historical receipts: map verified legacy levels 1→5, 2→4, 3→3, 4→2, 5→1 without changing assurance; clarify ambiguous unversioned selections rather than guessing.",
15
+ auditor
16
+ ? "Remain read-only. Check the actual user-facing comparison and selection evidence, not only this instruction. Report missing levels, scope, estimates, rationale, unsafe effective levels, or ambiguous legacy numbering as findings. This is procedural guidance, not a new deterministic selection validator."
17
+ : "Before material implementation ensure a valid selection and complete comparison are available. Read-only discovery may continue while unresolved; do not substitute a recommendation-only message. This is procedural guidance, not a new deterministic selection validator.",
18
+ ].join("\n"));
19
+ }
@@ -1,11 +1,14 @@
1
1
  import { collectMinimumCompletion } from "./minimum-completion.js";
2
2
  import { execFile } from "node:child_process";
3
+ import { createHash } from "node:crypto";
4
+ import { lstat, readFile, realpath } from "node:fs/promises";
5
+ import path from "node:path";
3
6
  import { promisify } from "node:util";
4
7
 
5
8
  import { cleanString, stringArray } from "./shared.js";
6
9
 
7
10
  const execFileAsync = promisify(execFile);
8
- const SUCCESS_CONCLUSIONS = new Set(["SUCCESS", "NEUTRAL", "SKIPPED"]);
11
+ const SUCCESS_CONCLUSIONS = new Set(["SUCCESS", "NEUTRAL"]);
9
12
  const FAILURE_CONCLUSIONS = new Set([
10
13
  "ACTION_REQUIRED",
11
14
  "CANCELLED",
@@ -20,14 +23,25 @@ export async function collectPrEvidence({
20
23
  repositoryPath,
21
24
  runCommand = execFileAsync,
22
25
  }) {
26
+ const baseRefresh = await command(
27
+ runCommand,
28
+ "git",
29
+ ["fetch", "--no-tags", "origin", charter.base_branch],
30
+ repositoryPath,
31
+ );
23
32
  const local = await collectLocalGitEvidence({
24
33
  baseBranch: charter.base_branch,
25
34
  repositoryPath,
26
35
  runCommand,
27
36
  });
37
+ local.base_ref_refreshed = baseRefresh.ok;
38
+ local.base_ref_error = baseRefresh.ok ? null : baseRefresh.error;
28
39
  const github = await collectGitHubEvidence({ charter, attempt, repositoryPath, runCommand });
29
40
  const minimumCompletion = await collectMinimumCompletion({ charter, attempt, repositoryPath, local });
41
+ const prPreparationRefs = await verifyPrPreparationRefs({ attempt, repositoryPath, local, github });
30
42
  const latest = await collectLocalGitEvidence({ baseBranch: charter.base_branch, repositoryPath, runCommand });
43
+ latest.base_ref_refreshed = baseRefresh.ok;
44
+ latest.base_ref_error = baseRefresh.ok ? null : baseRefresh.error;
31
45
  if (!latest.available || latest.head_sha !== local.head_sha || !latest.working_tree_clean) {
32
46
  minimumCompletion.status = "evidence_incomplete";
33
47
  minimumCompletion.errors = ["Checkout changed while collecting minimum evidence; verify again."];
@@ -37,27 +51,69 @@ export async function collectPrEvidence({
37
51
  collected_at: new Date().toISOString(),
38
52
  local: latest,
39
53
  github,
54
+ pr_preparation_refs: prPreparationRefs,
55
+ };
56
+ }
57
+
58
+ async function verifyPrPreparationRefs({ attempt, repositoryPath, local, github }) {
59
+ const refs = [...new Set((attempt.pr_preparation || []).flatMap((row) => row.evidence_refs || []))];
60
+ return Promise.all(refs.map(async (ref) => {
61
+ const observed = observedEvidenceRef(ref, local, github);
62
+ if (observed !== null) return { ref, verified: observed, kind: "observed" };
63
+ try {
64
+ const root = await realpath(repositoryPath);
65
+ const target = await realpath(path.resolve(root, ref));
66
+ const relative = path.relative(root, target);
67
+ const details = await lstat(target);
68
+ const verified = !relative.startsWith("..") && !path.isAbsolute(relative) &&
69
+ details.isFile() && details.size <= 50 * 1024 * 1024;
70
+ const sha256 = verified
71
+ ? createHash("sha256").update(await readFile(target)).digest("hex")
72
+ : null;
73
+ return { ref, verified, kind: "local_file", sha256 };
74
+ } catch {
75
+ return { ref, verified: false, kind: "unverified" };
76
+ }
77
+ }));
78
+ }
79
+
80
+ function observedEvidenceRef(ref, local, github) {
81
+ const sources = {
82
+ "observed:local.head_sha": local.head_sha,
83
+ "observed:local.base_sha": local.base_sha,
84
+ "observed:local.base_is_ancestor": local.base_is_ancestor === true,
85
+ "observed:github.head_sha": github.head_sha,
86
+ "observed:github.base_sha": github.base_sha,
87
+ "observed:github.checks": Array.isArray(github.checks) && github.checks.length > 0,
40
88
  };
89
+ return Object.hasOwn(sources, ref) ? Boolean(sources[ref]) : null;
41
90
  }
42
91
 
43
92
  async function collectLocalGitEvidence({ baseBranch, repositoryPath, runCommand }) {
44
- const [head, branch, headline, status, changed] = await Promise.all([
93
+ const baseRef = `origin/${baseBranch}`;
94
+ const [head, branch, headline, status, changed, base, mergeBase, baseAncestor] = await Promise.all([
45
95
  command(runCommand, "git", ["rev-parse", "HEAD"], repositoryPath),
46
96
  command(runCommand, "git", ["branch", "--show-current"], repositoryPath),
47
97
  command(runCommand, "git", ["log", "-1", "--pretty=%s"], repositoryPath),
48
98
  command(runCommand, "git", ["status", "--porcelain"], repositoryPath),
49
99
  changedFiles(runCommand, baseBranch, repositoryPath),
100
+ command(runCommand, "git", ["rev-parse", baseRef], repositoryPath),
101
+ command(runCommand, "git", ["merge-base", baseRef, "HEAD"], repositoryPath),
102
+ command(runCommand, "git", ["merge-base", "--is-ancestor", baseRef, "HEAD"], repositoryPath),
50
103
  ]);
51
104
  const statusLines = lines(status.stdout);
52
105
  return {
53
- available: head.ok && branch.ok && headline.ok && status.ok && changed.ok,
106
+ available: head.ok && branch.ok && headline.ok && status.ok && changed.ok && base.ok && mergeBase.ok,
54
107
  head_sha: cleanString(head.stdout) || null,
55
108
  branch_name: cleanString(branch.stdout) || null,
56
109
  commit_headline: cleanString(headline.stdout) || null,
57
110
  working_tree_clean: status.ok && statusLines.length === 0,
58
111
  status_lines: statusLines,
59
112
  changed_files: lines(changed.stdout),
60
- errors: [head, branch, headline, status, changed]
113
+ base_sha: cleanString(base.stdout) || null,
114
+ merge_base_sha: cleanString(mergeBase.stdout) || null,
115
+ base_is_ancestor: baseAncestor.ok,
116
+ errors: [head, branch, headline, status, changed, base, mergeBase]
61
117
  .filter((item) => !item.ok)
62
118
  .map((item) => item.error),
63
119
  };
@@ -93,6 +149,7 @@ async function collectGitHubEvidence({ charter, attempt, repositoryPath, runComm
93
149
  "headRepository",
94
150
  "headRepositoryOwner",
95
151
  "baseRefName",
152
+ "baseRefOid",
96
153
  "reviews",
97
154
  "statusCheckRollup",
98
155
  ].join(",");
@@ -137,10 +194,11 @@ async function collectGitHubEvidence({ charter, attempt, repositoryPath, runComm
137
194
  ? `${cleanString(payload.headRepositoryOwner.login)}/${cleanString(payload.headRepository.name)}`
138
195
  : null,
139
196
  base_branch: cleanString(payload.baseRefName) || null,
197
+ base_sha: cleanString(payload.baseRefOid) || null,
140
198
  checks,
141
199
  checks_present: checks.length > 0,
142
200
  checks_passing:
143
- checks.length > 0 && checks.every((item) => item.state === "success"),
201
+ checks.length > 0 && checks.every((item) => ["success", "skipped"].includes(item.state)),
144
202
  required_checks_present: requiredChecks.every((name) => checkNames.has(name)),
145
203
  error: null,
146
204
  };
@@ -154,6 +212,7 @@ function normalizeChecks(value) {
154
212
  const conclusion = cleanString(item?.conclusion || item?.state).toUpperCase();
155
213
  let state = "pending";
156
214
  if (SUCCESS_CONCLUSIONS.has(conclusion)) state = "success";
215
+ if (conclusion === "SKIPPED") state = "skipped";
157
216
  if (FAILURE_CONCLUSIONS.has(conclusion)) state = "failure";
158
217
  if (status === "COMPLETED" && !conclusion) state = "failure";
159
218
  return { name, status: status || null, conclusion: conclusion || null, state };
@@ -1,10 +1,15 @@
1
1
  import { bullets, cleanString, section } from "./shared.js";
2
+ import { buildPrClosureInstruction } from "./pr-closure.js";
3
+ import { buildUxSpecificationInstruction } from "./ux-specification.js";
4
+ import { buildDeliveryLevelInstruction } from "./delivery-level.js";
5
+ import { buildChecklistContinuationInstruction } from "./checklist-continuation.js";
2
6
  import {
3
7
  COMPLETION_CONTRACT_VERSION,
4
8
  acceptanceCriterionRows,
5
9
  normalizeCriterionEvidence,
6
10
  normalizeVisualReview,
7
11
  } from "./completion-contract.js";
12
+ import { independentAuditEvidenceIdentity } from "./pr-preparation.js";
8
13
 
9
14
  export function buildIndependentAuditInstruction(charter, attempt) {
10
15
  const localEvidence = attempt.observed_evidence?.local || {};
@@ -18,6 +23,10 @@ export function buildIndependentAuditInstruction(charter, attempt) {
18
23
  : [];
19
24
 
20
25
  return [
26
+ buildUxSpecificationInstruction({ auditor: true }),
27
+ buildDeliveryLevelInstruction({ auditor: true }),
28
+ buildChecklistContinuationInstruction({ auditor: true }),
29
+ buildPrClosureInstruction({ auditor: true }),
21
30
  section(
22
31
  "role",
23
32
  "You are an independent PR auditor. You did not implement this change and must not edit files.",
@@ -47,9 +56,14 @@ export function buildIndependentAuditInstruction(charter, attempt) {
47
56
  `Executor criterion evidence: ${JSON.stringify(attempt.criterion_evidence || [])}`,
48
57
  `Minimum evidence matrix: ${attempt.observed_evidence?.minimum_completion?.evidence_path || "missing"}`,
49
58
  `Minimum evidence digest: ${attempt.observed_evidence?.minimum_completion?.matrix_sha256 || "missing"}`,
59
+ `Complete audit evidence identity: ${independentAuditEvidenceIdentity(attempt)}`,
50
60
  `Executor visual review: ${JSON.stringify(attempt.visual_review || {})}`,
61
+ `Executor PR preparation evidence: ${JSON.stringify(attempt.pr_preparation || [])}`,
62
+ `Executor skipped-check disclosures: ${JSON.stringify(attempt.skipped_checks || [])}`,
51
63
  `Observed local branch: ${localEvidence.branch_name || "unknown"}`,
52
64
  `Observed local HEAD: ${localEvidence.head_sha || "unknown"}`,
65
+ `Observed fetched base SHA: ${localEvidence.base_sha || "unknown"}`,
66
+ `Observed base ancestry: ${localEvidence.base_is_ancestor === true ? "integrated" : "not integrated or unknown"}`,
53
67
  `Observed changed files:\n${bullets(localEvidence.changed_files || [])}`,
54
68
  `Observed PR: ${githubEvidence.url || attempt.pr_url || "unknown"}`,
55
69
  `Observed passing GitHub checks:\n${bullets(passingChecks)}`,
@@ -63,6 +77,10 @@ export function buildIndependentAuditInstruction(charter, attempt) {
63
77
  "Inspect the final diff and related code directly from the repository.",
64
78
  "Look for unmet acceptance criteria, regressions, security issues, data and concurrency risks, missing tests, and unrelated changes.",
65
79
  "Treat executor claims as untrusted until supported by repository evidence.",
80
+ "Inspect every structured PR preparation row. Confirm required rows are bound to the current head and raw evidence; confirm not-applicable rows have a genuine boundary reason and authoritative source. Check exact companion/manifest revisions, scenario outcomes, cleanup residual count, telemetry redaction, locale/browser evidence, and residual-work disclosure where applicable.",
81
+ "For conditional safeguards, inspect the actual changed boundary: checklist rendering must resist H1-H6, leading-space, and trailing-hash lookalikes while keeping one official controller table; release work must derive its target from authoritative topology and define exact-revision observation; live verification must declare its write policy and prove residual test data zero; loop-state/rendering changes must preserve artifacts and recompute derived views across normal/checkpoint and supported paid resumes.",
82
+ "Confirm the remote base was freshly read, is an ancestor of the final head, and matches the PR base SHA. Treat DIRTY/BEHIND, stale companion SHAs, changed manifests, or conflict resolution without rerun evidence as blockers.",
83
+ "Inspect skipped GitHub checks independently. A documented skip may be legitimate, but it must not be represented as an executed full/live/E2E result.",
66
84
  "Compare the original request and frozen experience to the complete stable criterion-ID list and implementation mapping. Report forgotten features, dead controls, unsaved results and broken integration. Open the raw minimum evidence, verify its oracle and actual runtime observations; matching expected/actual JSON and hashes alone do not prove truth. Check reload/session return and persisted values/ownership when saving is required.",
67
85
  "For every stable criterion ID, return a criterion_results entry only after directly checking its cited proof and observed outcome.",
68
86
  "For production-relevant criteria, verify that each outcome and guardrail measure names its signal, independent source, observation window, threshold, decision, owner, and criterion ID.",
@@ -4,3 +4,10 @@ export { buildIndependentAuditInstruction } from "./independent-audit.js";
4
4
  export { recheckPrReadiness, runCodingLoop } from "./loop.js";
5
5
  export { mergeTokenUsage, parseStructuredMarker, parseStructuredResult } from "./result.js";
6
6
  export { buildRetryFingerprint, evaluateRetryCircuit } from "./retry.js";
7
+ export {
8
+ PR_PREPARATION_CHECKS,
9
+ defaultPrPreparationContract,
10
+ evaluatePrPreparation,
11
+ independentAuditEvidenceIdentity,
12
+ skippedChecksDisclosure,
13
+ } from "./pr-preparation.js";