@punks/cli 4.0.4 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BASELINE_CHANGELOG.md +29 -1
- package/dist/CHANGELOG.md +48 -0
- package/dist/baseline/scaffold-baseline/baseline.json +563 -5
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.d.mts +23 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.mjs +84 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.test.ts +79 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/lint-feedback.test.ts +60 -28
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.mjs +166 -3
- package/dist/baseline/scaffold-baseline/data/shared-agents.md +55 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/commands.md +4 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/post-command-flow.md +20 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/generic/handoff/SKILL.md +18 -5
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/SKILL.md +10 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/plan-schema.md +28 -8
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/planner-task-graph.md +7 -3
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-verification-skill/SKILL.md +66 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-verification-skill/references/upstream.md +20 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/SKILL.md +16 -41
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +14 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/lifecycle.md +47 -7
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +102 -134
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +77 -67
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel.md +19 -39
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/runtime-product-validation.md +27 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/swarm-planner/SKILL.md +27 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/update-verification-skill/SKILL.md +81 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/verify-behavior/SKILL.md +105 -65
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +17 -4
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/scripts/autoreview +102 -5
- package/dist/baseline/scaffold-baseline/skills/agnostic/subagents/swarm-planner/SKILL.md +27 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +11 -13
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/backlog.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/closeout.md +12 -4
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/debug.md +11 -5
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/docs-ingest.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/handback.md +6 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/implement.md +12 -7
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/plan.md +7 -1
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +61 -22
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +45 -91
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/spec.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/artifact-state.md +21 -9
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/context-continuity.md +109 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/failure-continuity.md +27 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/phase-handoff.md +32 -20
- package/dist/baseline/scaffold-baseline/skills/phases/docs-ingest-phase/SKILL.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/docs-ingest-phase/references/wiki-ingest.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/prepare-review.md +41 -8
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/retain-report.md +13 -4
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/router.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/run-review.md +24 -18
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/durable-report.md +40 -6
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/review-packet.md +72 -0
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/runtime-handoff.md +3 -0
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md +51 -42
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/scripts/review-contract.mjs +239 -4
- package/dist/baseline/scaffold-baseline.json +5 -5
- package/dist/baseline/scaffold-baseline.tgz +0 -0
- package/dist/data/scripts/harness-projection/authoring.d.mts +23 -0
- package/dist/data/scripts/harness-projection/authoring.mjs +84 -0
- package/dist/data/scripts/sync-subagents.mjs +129 -3
- package/dist/index.js +1413 -1396
- package/dist/skills/agnostic/cli/hi-cli/references/commands.md +4 -2
- package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +20 -2
- package/dist/skills/agnostic/generic/handoff/SKILL.md +18 -5
- package/dist/skills/agnostic/planning/create-plan/SKILL.md +10 -2
- package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +28 -8
- package/dist/skills/agnostic/planning/create-plan/references/planner-task-graph.md +7 -3
- package/dist/skills/agnostic/planning/create-verification-skill/SKILL.md +66 -0
- package/dist/skills/agnostic/planning/create-verification-skill/references/upstream.md +20 -0
- package/dist/skills/agnostic/planning/implement-spec/SKILL.md +16 -41
- package/dist/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +14 -0
- package/dist/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
- package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +47 -7
- package/dist/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +102 -134
- package/dist/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +77 -67
- package/dist/skills/agnostic/planning/implement-spec/references/parallel.md +19 -39
- package/dist/skills/agnostic/planning/implement-spec/references/runtime-product-validation.md +27 -0
- package/dist/skills/agnostic/planning/swarm-planner/SKILL.md +27 -2
- package/dist/skills/agnostic/planning/update-verification-skill/SKILL.md +81 -0
- package/dist/skills/agnostic/planning/verify-behavior/SKILL.md +105 -65
- package/dist/skills/agnostic/quality/autoreview/SKILL.md +17 -4
- package/dist/skills/agnostic/quality/autoreview/scripts/autoreview +102 -5
- package/dist/skills/agnostic/subagents/swarm-planner/SKILL.md +27 -2
- package/dist/skills/phases/delivery-phase/SKILL.md +11 -13
- package/dist/skills/phases/delivery-phase/phases/backlog.md +4 -0
- package/dist/skills/phases/delivery-phase/phases/closeout.md +12 -4
- package/dist/skills/phases/delivery-phase/phases/debug.md +11 -5
- package/dist/skills/phases/delivery-phase/phases/docs-ingest.md +4 -0
- package/dist/skills/phases/delivery-phase/phases/handback.md +6 -2
- package/dist/skills/phases/delivery-phase/phases/implement.md +12 -7
- package/dist/skills/phases/delivery-phase/phases/plan.md +7 -1
- package/dist/skills/phases/delivery-phase/phases/review.md +61 -22
- package/dist/skills/phases/delivery-phase/phases/router.md +45 -91
- package/dist/skills/phases/delivery-phase/phases/spec.md +4 -0
- package/dist/skills/phases/delivery-phase/references/artifact-state.md +21 -9
- package/dist/skills/phases/delivery-phase/references/context-continuity.md +109 -0
- package/dist/skills/phases/delivery-phase/references/failure-continuity.md +27 -0
- package/dist/skills/phases/delivery-phase/references/phase-handoff.md +32 -20
- package/dist/skills/phases/docs-ingest-phase/SKILL.md +4 -0
- package/dist/skills/phases/docs-ingest-phase/references/wiki-ingest.md +4 -0
- package/dist/skills/phases/review-phase/phases/prepare-review.md +40 -8
- package/dist/skills/phases/review-phase/phases/retain-report.md +13 -4
- package/dist/skills/phases/review-phase/phases/router.md +1 -1
- package/dist/skills/phases/review-phase/phases/run-review.md +24 -18
- package/dist/skills/phases/review-phase/references/durable-report.md +40 -6
- package/dist/skills/phases/review-phase/references/review-packet.md +72 -0
- package/dist/skills/phases/review-phase/references/runtime-handoff.md +3 -0
- package/dist/skills/phases/review-phase/references/state-graph.md +21 -12
- package/dist/skills/phases/review-phase/scripts/review-contract.mjs +137 -4
- package/package.json +4 -1
package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md
CHANGED
|
@@ -4,45 +4,45 @@ Review owns normalization, frozen inspection, report retention, routing output,
|
|
|
4
4
|
and termination. Delivery owns debugging, implementation, debt, docs, closeout,
|
|
5
5
|
and clean handoff.
|
|
6
6
|
|
|
7
|
-
| State | Event
|
|
8
|
-
| --------------------------------- |
|
|
9
|
-
| Current delivery state | Review considered
|
|
10
|
-
| Current delivery state | Review considered
|
|
11
|
-
| `review_due` | Authorized review invocation
|
|
12
|
-
| `review_due` | Explicit review invocation
|
|
13
|
-
| Current delivery state | Review considered
|
|
14
|
-
| `review_running` |
|
|
15
|
-
| `review_running` | Validation mutation detected
|
|
16
|
-
| `review_running` | Retryable infrastructure failure or partial run
|
|
17
|
-
| `review_running` | Non-retryable contract or infrastructure failure
|
|
18
|
-
| `report_retention_pending` | Retention verified
|
|
19
|
-
| `report_retention_pending` | Retention rejected
|
|
20
|
-
| `report_retention_pending` | Retention verified
|
|
21
|
-
| `report_retention_pending` | Idempotent retention recovery
|
|
22
|
-
| `report_retention_pending` | Same-run conflict
|
|
23
|
-
| `report_retention_pending` | Retained-pass validation rejected
|
|
24
|
-
| `report_retention_pending` | Retryable retention failure
|
|
25
|
-
| `report_retention_pending` | Non-retryable retention failure
|
|
26
|
-
| `report_retention_pending` | Freshness changed
|
|
27
|
-
| `review_routed` | Human steering route
|
|
28
|
-
| `review_routed` | Readonly return
|
|
29
|
-
| `review_routed` | Resume debug route
|
|
30
|
-
| `review_routed` | Resume implementation route
|
|
31
|
-
| `review_routed` | Resume debt follow-up
|
|
32
|
-
| `review_routed` | Mixed finding route
|
|
33
|
-
| `review_routed` | Mixed finding route
|
|
34
|
-
| `review_routed` | Single repair route
|
|
35
|
-
| `review_routed` | Single repair route
|
|
36
|
-
| `review_routed` | Finding route
|
|
37
|
-
| `debt_follow_up` | Debt captured
|
|
38
|
-
| `debt_follow_up` | Debt captured
|
|
39
|
-
| `debt_follow_up` | Debt captured
|
|
40
|
-
| `review_routed` | Documentation-only findings
|
|
41
|
-
| `review_routed` | Finding-free route
|
|
42
|
-
| `repair_active` or `debug_active` | Ordinary repair completes
|
|
43
|
-
| `repair_active` or `debug_active` |
|
|
44
|
-
| `focused_validation` | Focused validation fails
|
|
45
|
-
| `focused_validation` | Focused validation passes
|
|
7
|
+
| State | Event | Guard | Owner | Next state | Counter effect | Required evidence |
|
|
8
|
+
| --------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | --------------------------------- | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
|
|
9
|
+
| Current delivery state | Review considered | Unsupported target | Delivery caller | Return `review_failed` | None; zero handoff or status writes | Exact target failure; no report |
|
|
10
|
+
| Current delivery state | Review considered | Invalid accepted bounds | Delivery caller | Return `review_failed` | None; zero handoff or status writes | Exact bounds failure; no report |
|
|
11
|
+
| `review_due` | Authorized review invocation | Delivery; accepted bounds and target valid; preparation helper returns `review_due` for first pass, accepted-risk second pass, or exact human-authorized next ordinal | Delivery caller | `review_running` | Preallocate ordinal `review_count + 1`; no completed-pass change | Lineage, run id, ordinal, bounds identity/hash, normalized target |
|
|
12
|
+
| `review_due` | Explicit review invocation | Standalone; accepted bounds and target valid | Standalone caller | `review_running` | None | Lineage, run id, bounds identity/hash, normalized target |
|
|
13
|
+
| Current delivery state | Review considered | Delivery; in-memory accepted bounds and target valid; recovered `review_count >= 2`; no verified human direction for the next ordinal | Delivery caller | Return `review_budget_exhausted` | None; zero handoff or status writes | Exact current route, lineage, counters; no report or status mutation |
|
|
14
|
+
| `review_running` | Comprehensive primary, every assigned independent challenger and parent verification complete | One frozen snapshot; complete local report exists | `review-phase` | `report_retention_pending` | None; no completed-pass change | Complete report and fresh target/source hashes |
|
|
15
|
+
| `review_running` | Validation mutation detected | Frozen-target hash differs after validation | `review-phase` | `review_due` | None | Before/after hashes, command, mutation evidence; no report or pass |
|
|
16
|
+
| `review_running` | Retryable infrastructure failure or partial run | No immutable report | `review-phase` | `review_due` | None | Exact retryable evidence; unchanged counters |
|
|
17
|
+
| `review_running` | Non-retryable contract or infrastructure failure | No immutable report | `review-phase` | `review_failed` | None | Exact terminal evidence; no report; unchanged counters |
|
|
18
|
+
| `report_retention_pending` | Retention verified | Delivery; valid retained-pass predicate; current-protocol ordinal at most 2 or exact verified human direction; hashes fresh | Report writer | `review_routed` | Unique retained commit establishes authoritative ordinal; reconcile projection | Path, SHA-256, commit, retained ref, ordinal, run id |
|
|
19
|
+
| `report_retention_pending` | Retention rejected | Delivery; current-protocol ordinal is greater than 2 without exact verified human direction | Report writer | `review_budget_exhausted` | None | Exact ordinal rejection/current route; no authoritative pass |
|
|
20
|
+
| `report_retention_pending` | Retention verified | Standalone; valid retained-pass predicate; hashes fresh | Report writer | `review_routed` | None | Path, SHA-256, commit, retained ref |
|
|
21
|
+
| `report_retention_pending` | Idempotent retention recovery | Same lineage/run has identical valid path, report blob SHA-256, and commit | Report writer | `review_routed` | Reuse existing pass; project its ordinal at most once | Existing unique authority and containment evidence |
|
|
22
|
+
| `report_retention_pending` | Same-run conflict | Same lineage/run has two valid candidates with different path, blob, or commit | Report writer | `review_failed` | None | `same_run_conflict`, both authorities; no pass or counter change |
|
|
23
|
+
| `report_retention_pending` | Retained-pass validation rejected | Active candidate is malformed or has wrong derived identity, hash, paths, containment, or ordinal | Report writer | `review_failed` | None | Exact failed predicate; no pass or counter change |
|
|
24
|
+
| `report_retention_pending` | Retryable retention failure | Hashes fresh | Report writer | `report_retention_pending` | None | Exact retryable evidence; no authoritative pass |
|
|
25
|
+
| `report_retention_pending` | Non-retryable retention failure | Retry cannot succeed | Report writer | `review_failed` | None | Exact terminal evidence; no authoritative pass |
|
|
26
|
+
| `report_retention_pending` | Freshness changed | Target or source hash changed | `review-phase` | `review_due` | None | Stale local report; unchanged counters |
|
|
27
|
+
| `review_routed` | Human steering route | Derived primary route is `human_steering_required` | `review-phase` | `human_steering_required` | None | Retained report plus durable `$handback` outcome |
|
|
28
|
+
| `review_routed` | Readonly return | Standalone; primary route is not `human_steering_required` | Standalone caller | `review_complete` | None | Retained report output and route |
|
|
29
|
+
| `review_routed` | Resume debug route | Handoff already records run id, debug route, and `debug_active` | `delivery-phase` | `debug_active` | None | Existing atomic handoff; no guard fallthrough |
|
|
30
|
+
| `review_routed` | Resume implementation route | Handoff already records run id, implementation route, and `repair_active` | `delivery-phase` | `repair_active` | None | Existing atomic handoff; no guard fallthrough |
|
|
31
|
+
| `review_routed` | Resume debt follow-up | Handoff already records run id, retained report, stable finding IDs, and `debt_follow_up` | Delivery review handoff | `debt_follow_up` | None | Existing debt keys and artifact; no duplicate capture |
|
|
32
|
+
| `review_routed` | Mixed finding route | Runtime evidence exists; derived primary route is `debugging`; secondary architecture follow-up is true; run id unrecorded | `delivery-phase` | `debt_follow_up` | None | Explicit finding routes, stable findings, post-debt route `debugging` |
|
|
33
|
+
| `review_routed` | Mixed finding route | No runtime evidence; derived primary route is `implementation`; secondary architecture follow-up is true; run id unrecorded | `delivery-phase` | `debt_follow_up` | None | Explicit finding routes, stable findings, post-debt route `implementation` |
|
|
34
|
+
| `review_routed` | Single repair route | Runtime evidence exists; derived primary route is `debugging`; no debt follow-up; run id unrecorded | `delivery-phase` | `debug_active` | Atomic handoff opens corresponding repair | Explicit finding routes, stable findings, atomic handoff |
|
|
35
|
+
| `review_routed` | Single repair route | No runtime evidence; in-scope non-runtime blocker exists; derived primary route is `implementation`; no debt follow-up; run id unrecorded | `delivery-phase` | `repair_active` | Atomic handoff opens corresponding repair | Explicit finding routes, stable findings, atomic handoff |
|
|
36
|
+
| `review_routed` | Finding route | Derived primary route is `debt_follow_up` | `delivery-phase` | `debt_follow_up` | None | Explicit debt routes, stable findings, post-debt route `docs_ingest` or `closeout` |
|
|
37
|
+
| `debt_follow_up` | Debt captured | Every debt key is present; `post_debt_route` is `debugging` | Delivery review handoff | `debug_active` | Open repair after capture exactly once | Retained report commit/path, stable finding IDs, artifact path, captured keys |
|
|
38
|
+
| `debt_follow_up` | Debt captured | Every debt key is present; `post_debt_route` is `implementation` | Delivery review handoff | `repair_active` | Open repair after capture exactly once | Retained report commit/path, stable finding IDs, artifact path, captured keys |
|
|
39
|
+
| `debt_follow_up` | Debt captured | Every debt key is present; `post_debt_route` is `docs_ingest` or `closeout` | Delivery review handoff | `docs_ingest` or `closeout` | None | Retained report commit/path, stable finding IDs, artifact path, captured keys |
|
|
40
|
+
| `review_routed` | Documentation-only findings | Derived primary route is `docs_ingest` | `delivery-phase` | `docs_ingest` | None | Explicit docs routes and stable findings |
|
|
41
|
+
| `review_routed` | Finding-free route | Finding set is empty | `delivery-phase` | `closeout` | None | Report and derived closeout route |
|
|
42
|
+
| `repair_active` or `debug_active` | Ordinary accepted repair completes | Prior completed pass; no accepted high-risk trigger | `delivery-phase` | `focused_validation` | None | Focused checks and only invalidated Verification scenarios |
|
|
43
|
+
| `repair_active` or `debug_active` | Accepted high-risk repair completes | `review_count = 1`; architecture, security/authorization, public contract, runtime/deployment topology, or accepted scope changed | `delivery-phase` | `review_due` | None | Accepted risk trigger and source evidence; second pass only |
|
|
44
|
+
| `focused_validation` | Focused validation fails | Existing repair epoch remains open | `delivery-phase` | `repair_active` or `debug_active` | None; unchanged counters | Failed validation and recorded owning route |
|
|
45
|
+
| `focused_validation` | Focused validation passes | Accepted findings resolved and affected Verification current | `delivery-phase` | `clean_handoff` | None | Passing validation, final changes, prior retained-report link |
|
|
46
46
|
|
|
47
47
|
## Durable Budget
|
|
48
48
|
|
|
@@ -66,9 +66,18 @@ reuses recorded keys, adds only missing keys, and follows durable
|
|
|
66
66
|
`debugging` or `implementation`; primary debt records `docs_ingest` or
|
|
67
67
|
`closeout`. Capture completes before the recorded route opens.
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
Normal delivery runs one completed Full Code Review Pass after implementation,
|
|
70
|
+
applicable Verification, reconciliation and final acceptance. Ordinary accepted
|
|
71
|
+
repair gets Focused Repair Validation and only affected Verification reruns. A
|
|
72
|
+
second completed pass requires the accepted risk trigger above. Two completed
|
|
73
|
+
passes exhaust default allowance; further review requires explicit human
|
|
74
|
+
direction. Incomplete, interrupted or semantically invalidated attempts consume
|
|
75
|
+
no completed pass. Retention-only retry reuses the matching complete local report.
|
|
76
|
+
|
|
77
|
+
Valid legacy five-lens reports retain original immutable bytes and ordinals,
|
|
78
|
+
including three. Recovery preserves this authority without granting more default
|
|
79
|
+
passes. Historical numbered repair states normalize to the existing repair and
|
|
80
|
+
focused-validation route; their counters and report identities stay unchanged.
|
|
72
81
|
|
|
73
82
|
`human_steering_required` opens no repair. It remains terminal until the
|
|
74
83
|
`$handback` authority guard passes.
|
package/dist/baseline/scaffold-baseline/skills/phases/review-phase/scripts/review-contract.mjs
CHANGED
|
@@ -375,6 +375,8 @@ export const planDeliveryReviewGate = ({
|
|
|
375
375
|
acceptedBoundsValid,
|
|
376
376
|
targetSupported,
|
|
377
377
|
recoveredReviewCount,
|
|
378
|
+
acceptedRiskTrigger,
|
|
379
|
+
humanReviewDirection,
|
|
378
380
|
}) => {
|
|
379
381
|
if (!acceptedBoundsValid || !targetSupported) {
|
|
380
382
|
return { state: "review_failed", handoffWrites: [] };
|
|
@@ -382,13 +384,36 @@ export const planDeliveryReviewGate = ({
|
|
|
382
384
|
if (!Number.isSafeInteger(recoveredReviewCount) || recoveredReviewCount < 0) {
|
|
383
385
|
return { state: "review_failed", handoffWrites: [] };
|
|
384
386
|
}
|
|
385
|
-
if (
|
|
387
|
+
if (
|
|
388
|
+
recoveredReviewCount >= 2 &&
|
|
389
|
+
!(
|
|
390
|
+
exactKeys(humanReviewDirection, ["evidence", "authorized_ordinal"]) &&
|
|
391
|
+
nonemptyString(humanReviewDirection.evidence) &&
|
|
392
|
+
humanReviewDirection.authorized_ordinal === recoveredReviewCount + 1
|
|
393
|
+
)
|
|
394
|
+
) {
|
|
386
395
|
return {
|
|
387
396
|
state: "review_budget_exhausted",
|
|
388
397
|
priorState: currentState,
|
|
389
398
|
handoffWrites: [],
|
|
390
399
|
};
|
|
391
400
|
}
|
|
401
|
+
if (
|
|
402
|
+
recoveredReviewCount === 1 &&
|
|
403
|
+
!(
|
|
404
|
+
exactKeys(acceptedRiskTrigger, ["kind", "evidence"]) &&
|
|
405
|
+
[
|
|
406
|
+
"architecture",
|
|
407
|
+
"security",
|
|
408
|
+
"public_contract",
|
|
409
|
+
"runtime_topology",
|
|
410
|
+
"accepted_scope",
|
|
411
|
+
].includes(acceptedRiskTrigger.kind) &&
|
|
412
|
+
nonemptyString(acceptedRiskTrigger.evidence)
|
|
413
|
+
)
|
|
414
|
+
) {
|
|
415
|
+
return { state: "focused_validation", handoffWrites: [] };
|
|
416
|
+
}
|
|
392
417
|
return { state: "review_due", handoffWrites: ["review_due_context"] };
|
|
393
418
|
};
|
|
394
419
|
|
|
@@ -474,11 +499,153 @@ const validateTargetSchema = (target, mode, errors) => {
|
|
|
474
499
|
}
|
|
475
500
|
};
|
|
476
501
|
|
|
502
|
+
export const reviewPacketIdentity = (report) =>
|
|
503
|
+
hashRecord("review-packet", [
|
|
504
|
+
report.review_run_id,
|
|
505
|
+
report.accepted_bounds_hash,
|
|
506
|
+
report.snapshot_hash,
|
|
507
|
+
report.source_set_hash,
|
|
508
|
+
]);
|
|
509
|
+
|
|
510
|
+
const validateReviewEpoch = (report, errors) => {
|
|
511
|
+
const epoch = report.review_epoch;
|
|
512
|
+
if (
|
|
513
|
+
!exactKeys(
|
|
514
|
+
epoch,
|
|
515
|
+
epoch && Object.hasOwn(epoch, "human_direction")
|
|
516
|
+
? ["protocol", "packet_identity", "results", "adjudications", "human_direction"]
|
|
517
|
+
: ["protocol", "packet_identity", "results", "adjudications"],
|
|
518
|
+
) ||
|
|
519
|
+
epoch.protocol !== "primary-challenger-v1" ||
|
|
520
|
+
!Array.isArray(epoch.results) ||
|
|
521
|
+
!Array.isArray(epoch.adjudications)
|
|
522
|
+
) {
|
|
523
|
+
errors.push("malformed:review_epoch");
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
let packet;
|
|
527
|
+
try {
|
|
528
|
+
packet = reviewPacketIdentity(report);
|
|
529
|
+
} catch {
|
|
530
|
+
errors.push("malformed:packet_identity");
|
|
531
|
+
}
|
|
532
|
+
if (epoch.packet_identity !== packet) errors.push("mismatch:packet_identity");
|
|
533
|
+
const primary = new Set();
|
|
534
|
+
const primaryReviewers = new Set();
|
|
535
|
+
const challengers = new Set();
|
|
536
|
+
const resultKeys = new Set();
|
|
537
|
+
const candidateRefs = new Set();
|
|
538
|
+
for (const result of epoch.results) {
|
|
539
|
+
if (
|
|
540
|
+
!exactKeys(result, [
|
|
541
|
+
"reviewer_identity",
|
|
542
|
+
"role",
|
|
543
|
+
"coverage",
|
|
544
|
+
"packet_identity",
|
|
545
|
+
"outcome",
|
|
546
|
+
"candidates",
|
|
547
|
+
"unavailable_coverage",
|
|
548
|
+
"cause",
|
|
549
|
+
"follow_up",
|
|
550
|
+
]) ||
|
|
551
|
+
!nonemptyString(result.reviewer_identity) ||
|
|
552
|
+
!nonemptyString(result.coverage) ||
|
|
553
|
+
!["primary", "challenger"].includes(result.role) ||
|
|
554
|
+
result.packet_identity !== packet ||
|
|
555
|
+
!["clean", "findings", "incomplete"].includes(result.outcome) ||
|
|
556
|
+
!Array.isArray(result.candidates)
|
|
557
|
+
) {
|
|
558
|
+
errors.push("malformed:lens_result");
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
const key = JSON.stringify([result.reviewer_identity, result.coverage]);
|
|
562
|
+
if (resultKeys.has(key)) errors.push("duplicate:lens_result");
|
|
563
|
+
resultKeys.add(key);
|
|
564
|
+
if (result.role === "primary") {
|
|
565
|
+
if (!LENS_KEYS.includes(result.coverage) || primary.has(result.coverage))
|
|
566
|
+
errors.push("malformed:primary_coverage");
|
|
567
|
+
primary.add(result.coverage);
|
|
568
|
+
primaryReviewers.add(result.reviewer_identity);
|
|
569
|
+
} else challengers.add(result.reviewer_identity);
|
|
570
|
+
if (result.outcome === "incomplete") errors.push("incomplete:review_epoch");
|
|
571
|
+
else if (
|
|
572
|
+
!Array.isArray(result.unavailable_coverage) ||
|
|
573
|
+
result.unavailable_coverage.length !== 0 ||
|
|
574
|
+
result.cause !== null ||
|
|
575
|
+
result.follow_up !== null ||
|
|
576
|
+
(result.outcome === "findings") !== result.candidates.length > 0
|
|
577
|
+
)
|
|
578
|
+
errors.push("malformed:completed_coverage");
|
|
579
|
+
result.candidates.forEach((candidate, index) => {
|
|
580
|
+
candidateRefs.add(JSON.stringify([result.reviewer_identity, result.coverage, index]));
|
|
581
|
+
if (
|
|
582
|
+
!exactKeys(candidate, [
|
|
583
|
+
"location",
|
|
584
|
+
"evidence_pointer",
|
|
585
|
+
"impact",
|
|
586
|
+
"proposed_severity",
|
|
587
|
+
"proposed_return_route",
|
|
588
|
+
"uncertainty",
|
|
589
|
+
]) ||
|
|
590
|
+
![
|
|
591
|
+
candidate.location,
|
|
592
|
+
candidate.evidence_pointer,
|
|
593
|
+
candidate.impact,
|
|
594
|
+
candidate.uncertainty,
|
|
595
|
+
].every(nonemptyString) ||
|
|
596
|
+
!["critical", "high", "medium", "low"].includes(candidate.proposed_severity) ||
|
|
597
|
+
!FINDING_ROUTES.includes(candidate.proposed_return_route)
|
|
598
|
+
)
|
|
599
|
+
errors.push("malformed:review_candidate");
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
if (
|
|
603
|
+
primary.size !== LENS_KEYS.length ||
|
|
604
|
+
primaryReviewers.size !== 1 ||
|
|
605
|
+
challengers.size === 0 ||
|
|
606
|
+
[...challengers].some((id) => primaryReviewers.has(id))
|
|
607
|
+
)
|
|
608
|
+
errors.push("incomplete:independent_coverage");
|
|
609
|
+
const accounted = new Set();
|
|
610
|
+
const accepted = new Set();
|
|
611
|
+
for (const item of epoch.adjudications) {
|
|
612
|
+
if (
|
|
613
|
+
!exactKeys(item, ["candidate_refs", "finding_id", "evidence"]) ||
|
|
614
|
+
!Array.isArray(item.candidate_refs) ||
|
|
615
|
+
item.candidate_refs.length === 0 ||
|
|
616
|
+
!nonemptyString(item.evidence) ||
|
|
617
|
+
!(item.finding_id === null || nonemptyString(item.finding_id))
|
|
618
|
+
) {
|
|
619
|
+
errors.push("malformed:adjudication");
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
for (const ref of item.candidate_refs) {
|
|
623
|
+
if (!candidateRefs.has(ref) || accounted.has(ref))
|
|
624
|
+
errors.push("mismatch:candidate_accounting");
|
|
625
|
+
accounted.add(ref);
|
|
626
|
+
}
|
|
627
|
+
if (item.finding_id !== null) accepted.add(item.finding_id);
|
|
628
|
+
}
|
|
629
|
+
if (accounted.size !== candidateRefs.size) errors.push("incomplete:candidate_accounting");
|
|
630
|
+
const findings = new Set(
|
|
631
|
+
Array.isArray(report.findings) ? report.findings.map((finding) => finding.id) : [],
|
|
632
|
+
);
|
|
633
|
+
if (!isDeepStrictEqual(accepted, findings)) errors.push("mismatch:accepted_provenance");
|
|
634
|
+
};
|
|
635
|
+
|
|
477
636
|
const validateReportSemantics = (report, errors) => {
|
|
478
|
-
if (
|
|
637
|
+
if (
|
|
638
|
+
!exactKeys(
|
|
639
|
+
report,
|
|
640
|
+
Object.hasOwn(report, "review_epoch")
|
|
641
|
+
? [...requiredReportFields, "review_epoch"]
|
|
642
|
+
: requiredReportFields,
|
|
643
|
+
)
|
|
644
|
+
) {
|
|
479
645
|
errors.push("malformed:report_schema");
|
|
480
646
|
return;
|
|
481
647
|
}
|
|
648
|
+
if (Object.hasOwn(report, "review_epoch")) validateReviewEpoch(report, errors);
|
|
482
649
|
if (!exactKeys(report.lens_outcomes, LENS_KEYS)) {
|
|
483
650
|
errors.push("malformed:lens_keys");
|
|
484
651
|
} else {
|
|
@@ -635,6 +802,50 @@ const inspectRetainedPass = (candidate, expected) => {
|
|
|
635
802
|
return { valid: false, errors: [...errors, "malformed_report_blob"] };
|
|
636
803
|
}
|
|
637
804
|
validateReportSemantics(report, errors);
|
|
805
|
+
const hasReviewEpoch = Object.hasOwn(report, "review_epoch");
|
|
806
|
+
if (!hasReviewEpoch) {
|
|
807
|
+
const approvedLegacyReportCommitShas = expected.approvedLegacyReportCommitShas;
|
|
808
|
+
const hasLegacyCommitBinding =
|
|
809
|
+
Array.isArray(approvedLegacyReportCommitShas) &&
|
|
810
|
+
approvedLegacyReportCommitShas.length > 0 &&
|
|
811
|
+
sortedUniqueStrings(approvedLegacyReportCommitShas) &&
|
|
812
|
+
approvedLegacyReportCommitShas.every((sha) => COMMIT_SHA.test(sha)) &&
|
|
813
|
+
approvedLegacyReportCommitShas.includes(candidate.reportCommitSha);
|
|
814
|
+
if (!hasLegacyCommitBinding) {
|
|
815
|
+
errors.push("missing:legacy_report_commit_binding");
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
if (expected.reviewProtocol === "primary-challenger-v1") {
|
|
819
|
+
if (!hasReviewEpoch) errors.push("missing:review_epoch");
|
|
820
|
+
const assignments = expected.assignedCoverage;
|
|
821
|
+
const results = report.review_epoch?.results;
|
|
822
|
+
if (
|
|
823
|
+
!Array.isArray(assignments) ||
|
|
824
|
+
assignments.length === 0 ||
|
|
825
|
+
assignments.some(
|
|
826
|
+
(item) =>
|
|
827
|
+
!exactKeys(item, ["reviewer_identity", "role", "coverage"]) ||
|
|
828
|
+
!nonemptyString(item.reviewer_identity) ||
|
|
829
|
+
!["primary", "challenger"].includes(item.role) ||
|
|
830
|
+
!nonemptyString(item.coverage),
|
|
831
|
+
) ||
|
|
832
|
+
!Array.isArray(results) ||
|
|
833
|
+
results.some((item) => item === null || typeof item !== "object")
|
|
834
|
+
) {
|
|
835
|
+
errors.push("missing:assigned_coverage");
|
|
836
|
+
} else {
|
|
837
|
+
const assignmentKey = ({ reviewer_identity, role, coverage }) =>
|
|
838
|
+
JSON.stringify([reviewer_identity, role, coverage]);
|
|
839
|
+
if (
|
|
840
|
+
!isDeepStrictEqual(
|
|
841
|
+
sortUtf8(assignments.map(assignmentKey)),
|
|
842
|
+
sortUtf8(results.map(assignmentKey)),
|
|
843
|
+
)
|
|
844
|
+
) {
|
|
845
|
+
errors.push("mismatch:assigned_coverage");
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
638
849
|
validateTargetSchema(report.normalized_target, expected.mode, errors);
|
|
639
850
|
|
|
640
851
|
let currentTarget;
|
|
@@ -756,13 +967,37 @@ const inspectRetainedPass = (candidate, expected) => {
|
|
|
756
967
|
}
|
|
757
968
|
|
|
758
969
|
if (expected.mode === "delivery") {
|
|
970
|
+
const direction = report.review_epoch?.human_direction;
|
|
971
|
+
const directedOrdinal =
|
|
972
|
+
exactKeys(direction, ["evidence", "authorized_ordinal"]) &&
|
|
973
|
+
nonemptyString(direction.evidence) &&
|
|
974
|
+
direction.authorized_ordinal === ordinal &&
|
|
975
|
+
isDeepStrictEqual(direction, expected.humanReviewDirection);
|
|
976
|
+
if (direction !== undefined && !directedOrdinal) errors.push("invalid:human_review_direction");
|
|
977
|
+
const precedingRepairEvidence = expected.precedingRepairEvidence;
|
|
978
|
+
const hasPrecedingRepairEvidence =
|
|
979
|
+
precedingRepairEvidence !== null &&
|
|
980
|
+
typeof precedingRepairEvidence === "object" &&
|
|
981
|
+
exactKeys(precedingRepairEvidence, ["ordinal", "evidence"]) &&
|
|
982
|
+
Number.isSafeInteger(precedingRepairEvidence.ordinal) &&
|
|
983
|
+
precedingRepairEvidence.ordinal > 0 &&
|
|
984
|
+
nonemptyString(precedingRepairEvidence.evidence);
|
|
985
|
+
const expectedPrecedingRepairOrdinal = hasPrecedingRepairEvidence
|
|
986
|
+
? precedingRepairEvidence.ordinal
|
|
987
|
+
: null;
|
|
988
|
+
const validPrecedingRepair =
|
|
989
|
+
ordinal === 1
|
|
990
|
+
? expectedPrecedingRepairOrdinal === null
|
|
991
|
+
: expectedPrecedingRepairOrdinal === ordinal - 1 ||
|
|
992
|
+
(directedOrdinal && expectedPrecedingRepairOrdinal === null);
|
|
759
993
|
if (
|
|
760
994
|
report.delivery_goal_identity !== expected.deliveryGoalIdentity ||
|
|
761
995
|
report.review_ordinal !== ordinal ||
|
|
762
996
|
!Number.isSafeInteger(ordinal) ||
|
|
763
997
|
ordinal < 1 ||
|
|
764
|
-
ordinal > 3 ||
|
|
765
|
-
|
|
998
|
+
(ordinal > (Object.hasOwn(report, "review_epoch") ? 2 : 3) && !directedOrdinal) ||
|
|
999
|
+
!validPrecedingRepair ||
|
|
1000
|
+
report.preceding_repair_ordinal !== expectedPrecedingRepairOrdinal
|
|
766
1001
|
) {
|
|
767
1002
|
errors.push("invalid:delivery_identity_or_ordinal");
|
|
768
1003
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"channel": "stable",
|
|
4
|
-
"version": "2026.09.
|
|
5
|
-
"tag": "baseline/stable/2026.09.
|
|
6
|
-
"commit": "
|
|
4
|
+
"version": "2026.09.10-4e9ff339",
|
|
5
|
+
"tag": "baseline/stable/2026.09.10-4e9ff339",
|
|
6
|
+
"commit": "4e9ff3390e3a2d9d69d5b482793259d51ce85669",
|
|
7
7
|
"archive": "scaffold-baseline.tgz",
|
|
8
|
-
"archiveSha256": "
|
|
8
|
+
"archiveSha256": "75bbbb3f6825cfa5330442d1c9d18cc0e12b7789f3790de46def62214b2e43b0",
|
|
9
9
|
"compatibility": {
|
|
10
|
-
"cliVersionRange": ">=
|
|
10
|
+
"cliVersionRange": ">=5.0.1 <5.1.0"
|
|
11
11
|
}
|
|
12
12
|
}
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ContextPlan } from "@punks/scaffold/context-plan";
|
|
2
|
+
|
|
3
|
+
export interface ScopedAuthoringProof {
|
|
4
|
+
readonly scopeId: string;
|
|
5
|
+
readonly inputIdentity: string;
|
|
6
|
+
readonly status: "verified";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ScopedAuthoringAction {
|
|
10
|
+
readonly scopeId: string;
|
|
11
|
+
readonly inputIdentity: string;
|
|
12
|
+
readonly trigger: "compatibility-unknown" | "unverified" | "inputs-changed";
|
|
13
|
+
readonly allowedOutputs: readonly string[];
|
|
14
|
+
readonly allowedAgentIds: readonly string[];
|
|
15
|
+
readonly completionEvidence: "validated-authored-output-and-native-projection";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function scopeAuthoringIdentity(scope: ContextPlan["scopes"][number]): string;
|
|
19
|
+
export function readScopedAuthoringProofs(receipt: unknown): readonly ScopedAuthoringProof[];
|
|
20
|
+
export function assessScopedAuthoring(input: {
|
|
21
|
+
readonly contextPlan: ContextPlan;
|
|
22
|
+
readonly proofs: readonly ScopedAuthoringProof[];
|
|
23
|
+
}): readonly ScopedAuthoringAction[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
export const readScopedAuthoringProofs = (receipt) => {
|
|
4
|
+
const proofs = receipt?.scopedAuthoring;
|
|
5
|
+
if (!Array.isArray(proofs)) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
const scopes = new Set();
|
|
9
|
+
for (const proof of proofs) {
|
|
10
|
+
if (
|
|
11
|
+
proof === null ||
|
|
12
|
+
typeof proof !== "object" ||
|
|
13
|
+
typeof proof.scopeId !== "string" ||
|
|
14
|
+
proof.scopeId.length === 0 ||
|
|
15
|
+
typeof proof.inputIdentity !== "string" ||
|
|
16
|
+
!/^[a-f0-9]{64}$/u.test(proof.inputIdentity) ||
|
|
17
|
+
proof.status !== "verified" ||
|
|
18
|
+
scopes.has(proof.scopeId)
|
|
19
|
+
) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
scopes.add(proof.scopeId);
|
|
23
|
+
}
|
|
24
|
+
return proofs;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const scopeAuthoringIdentity = (scope) =>
|
|
28
|
+
JSON.stringify(
|
|
29
|
+
scope.authoring === undefined
|
|
30
|
+
? { compatibility: "unknown", scopeId: scope.id }
|
|
31
|
+
: {
|
|
32
|
+
contracts: [...scope.authoring.contracts]
|
|
33
|
+
.toSorted((left, right) => left.id.localeCompare(right.id))
|
|
34
|
+
.map(({ id, authoringRevision, activationRevision }) => ({
|
|
35
|
+
activationRevision,
|
|
36
|
+
authoringRevision,
|
|
37
|
+
id,
|
|
38
|
+
})),
|
|
39
|
+
kind: scope.authoring.kind,
|
|
40
|
+
missingContracts: [...new Set(scope.authoring.missingContracts)].toSorted(),
|
|
41
|
+
path: scope.authoring.path,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const assessScopedAuthoring = ({ contextPlan, proofs }) =>
|
|
46
|
+
contextPlan.scopes.flatMap((scope) => {
|
|
47
|
+
if (
|
|
48
|
+
scope.id === "shared" ||
|
|
49
|
+
scope.id === ".agents" ||
|
|
50
|
+
!scope.contributions.some(({ kind }) => kind === "scoped-prompt")
|
|
51
|
+
) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const inputIdentity = createHash("sha256").update(scopeAuthoringIdentity(scope)).digest("hex");
|
|
55
|
+
const proof = proofs.find((entry) => entry.scopeId === scope.id);
|
|
56
|
+
const compatible =
|
|
57
|
+
scope.authoring !== undefined && scope.authoring.missingContracts.length === 0;
|
|
58
|
+
if (compatible && proof?.status === "verified" && proof.inputIdentity === inputIdentity) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
let trigger;
|
|
62
|
+
if (compatible) {
|
|
63
|
+
trigger = proof === undefined ? "unverified" : "inputs-changed";
|
|
64
|
+
} else {
|
|
65
|
+
trigger = "compatibility-unknown";
|
|
66
|
+
}
|
|
67
|
+
const allowedAgentIds = scope.contributions
|
|
68
|
+
.filter(({ kind }) => kind === "subagent-template")
|
|
69
|
+
.map(({ identity }) => identity.id)
|
|
70
|
+
.toSorted();
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
allowedAgentIds,
|
|
74
|
+
allowedOutputs: [
|
|
75
|
+
scope.id === "root" ? "AGENTS.md" : `${scope.id}/AGENTS.md`,
|
|
76
|
+
...(allowedAgentIds.length === 0 ? [] : [".agents/subagents/manifest.mjs"]),
|
|
77
|
+
],
|
|
78
|
+
completionEvidence: "validated-authored-output-and-native-projection",
|
|
79
|
+
inputIdentity,
|
|
80
|
+
scopeId: scope.id,
|
|
81
|
+
trigger,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
});
|