@attalabs/vinaya 0.31.0 → 0.33.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.
- package/README.md +2 -3
- package/aeg-root/contracts/principal-operator.md +18 -5
- package/aeg-root/roles/developer/reference.md +3 -3
- package/aeg-root/roles/operator.md +69 -16
- package/aeg-root/roles/planner/reference.md +1 -1
- package/aeg-root/roles/tranche-archivist.md +1 -0
- package/aeg-root/skills/aeg-context-packets/SKILL.md +1 -1
- package/aeg-root/skills/aeg-context-packets/examples/operator-start.md +1 -1
- package/aeg-root/templates/pr-report-template.md +7 -2
- package/dist/checks/bin/check-body-bare-digits.js +340 -101
- package/dist/checks/bin/check-branch-topology.js +184 -105
- package/dist/checks/bin/check-brief-shape.js +333 -94
- package/dist/checks/bin/check-changeset-coverage.js +1028 -248
- package/dist/checks/bin/check-ci-shard-coverage.js +82 -0
- package/dist/checks/bin/check-closes-n.js +184 -105
- package/dist/checks/bin/check-coherence.js +345 -145
- package/dist/checks/bin/check-dead-branch-push.js +179 -59
- package/dist/checks/bin/check-dispatch-readiness.js +350 -150
- package/dist/checks/bin/check-doc-coverage-push.js +1011 -231
- package/dist/checks/bin/check-doc-coverage.js +1015 -235
- package/dist/checks/bin/check-doctrine-no-procedures.js +333 -94
- package/dist/checks/bin/check-doctrine-portability.js +1013 -233
- package/dist/checks/bin/check-evidence-fresh.js +1010 -222
- package/dist/checks/bin/check-exec-bits.js +1009 -229
- package/dist/checks/bin/check-first-push-dispatch.js +343 -145
- package/dist/checks/bin/check-issue-assignment.js +186 -107
- package/dist/checks/bin/check-issue-milestone-attach.js +176 -56
- package/dist/checks/bin/check-issue-objectives-numbering.js +176 -56
- package/dist/checks/bin/check-issue-parts-coverage.js +176 -56
- package/dist/checks/bin/check-issue-surface-globs.js +363 -143
- package/dist/checks/bin/check-issue-title-grammar.js +176 -56
- package/dist/checks/bin/check-issue-tranche-label.js +176 -56
- package/dist/checks/bin/check-main-branch-refusal.js +176 -56
- package/dist/checks/bin/check-no-disk-state.js +176 -56
- package/dist/checks/bin/check-pr-premise-reassert.js +333 -92
- package/dist/checks/bin/check-pr-report-density.js +176 -56
- package/dist/checks/bin/check-principal-test-plan-wait.js +176 -54
- package/dist/checks/bin/check-quoted-command.js +999 -217
- package/dist/checks/bin/check-reader-resolvable-prose.js +1011 -229
- package/dist/checks/bin/check-registry-gates.js +186 -56
- package/dist/checks/bin/check-retired-vocabulary.js +997 -215
- package/dist/checks/bin/check-review-gate.js +403 -203
- package/dist/checks/bin/check-single-plan-pr.js +176 -56
- package/dist/checks/bin/check-surface-scope.js +184 -105
- package/dist/checks/bin/check-test-plan.js +176 -54
- package/dist/checks/bin/check-token-collection-wired.js +182 -57
- package/dist/checks/bin/check-token-report.js +178 -58
- package/dist/checks/bin/check-workspace-escape.js +1011 -229
- package/dist/index.js +5971 -3489
- package/dist/lib/pre-push-cache-test-run.js +4431 -0
- package/dist/lib/pre-push-select-tests.js +799 -110
- package/package.json +3 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/actions.ts +10 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/archive-task.ts +42 -17
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/baseline-capture.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/branch-topology-gate.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +554 -95
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +264 -44
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/claude-code-transcript.ts +9 -9
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +211 -30
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/consumer-enumeration.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +75 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +961 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +212 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/outcomes.ts +135 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +394 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-audit.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-guard.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/derive-section7.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +514 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +110 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +123 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +240 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/diagram-model.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/direct-main-push.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +65 -22
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +238 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-owners.ts +14 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/docs-coherence.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/legacy-anchors.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/node-route.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/surfaced-manifest.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-no-procedures.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ensure-label.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/first-push-dispatch-gate.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +14 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +379 -11
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +3 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +1450 -33
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/local-anchor-coverage.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +119 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +75 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/redact.ts +87 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +801 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +373 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/metering-io-guard.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/milestone-validation.ts +2 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/no-disk-state.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +288 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-token-report.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-tranche.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +30 -16
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-tier.ts +17 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/premise-check.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/quoted-command.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +267 -19
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +91 -24
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-scaffold.ts +6 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/report-tokens.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +239 -110
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +384 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +184 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +65 -18
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +76 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/single-plan-pr.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/state-machine-model.ts +40 -27
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/symbol-collisions.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +38 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +488 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +7 -9
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-section.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/types.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +314 -56
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +2 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/workspace-escape.ts +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__1agj1ww._.js → [externals]__0cki-x_._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +6 -6
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0r7e54g._.js → [root-of-the-server]__18paley._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1r47dr7._.js → _08onyya._.js} +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +5 -5
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 1ce2dj27_cgbj.js} +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 22s44f5k3ecmj.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/34hhdtbp20krb.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0hstap0._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2t_rfsztmwu6y.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3ua4rm5f-a9k6.js +0 -1
- /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_ssgManifest.js +0 -0
package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dev-review-loop's policy half —
|
|
3
|
+
* `assessRound`, the loop spec's state machine (Linear "Tech spec —
|
|
4
|
+
* Developer Review Loop", rev 4, §5, §10.4, §13, §16) reduced to one pure
|
|
5
|
+
* function. No `fs`, no `fetch`, no `process.env`, no subprocess, no vendor
|
|
6
|
+
* name, no prompt.
|
|
7
|
+
*
|
|
8
|
+
* A round is up to two calls: a `gate` observation (the mechanical check for
|
|
9
|
+
* the round's new head, carrying the developer's confidence from round 2
|
|
10
|
+
* on), then, once the gate passes and confidence clears, a `verdicts`
|
|
11
|
+
* observation. A Principal ruling (2026-09-04, amended 2026-09-06):
|
|
12
|
+
*
|
|
13
|
+
* - Round 1 never asks for confidence.
|
|
14
|
+
* - From round 2 on, a `gate` observation's confidence gates whether
|
|
15
|
+
* reviewers are dispatched at all this round: absent asks again once, then
|
|
16
|
+
* pauses; below 50 sends the developer back for one extra turn (spent
|
|
17
|
+
* once, ever) without ever dispatching reviewers, then pauses on a second
|
|
18
|
+
* below-50; 50 or over dispatches reviewers.
|
|
19
|
+
* - A `verdicts` observation with any `NOT MET` objective is
|
|
20
|
+
* `changes_requested` regardless of findings.
|
|
21
|
+
* - The three exits are decided here and nowhere else: an id previously
|
|
22
|
+
* `resolved` reported again (`stop_condition_met` `condition: 'reappearance'`),
|
|
23
|
+
* a confidence collapse per the rule above (`condition: 'confidence'`), and
|
|
24
|
+
* rounds over 3 (`condition: 'max_rounds'`) — distinct `condition` values a
|
|
25
|
+
* 2026-09-06 amendment adds to `stop_condition_met.condition` so a reader
|
|
26
|
+
* tells a confidence collapse and a finding reappearance apart from each
|
|
27
|
+
* other and from the round cap. A fourth exit once lived here too — two
|
|
28
|
+
* consecutive rounds resolving no id (`condition: 'no_progress'`) — but it
|
|
29
|
+
* read a resolved-id signal no reviewer observation ever fills (every
|
|
30
|
+
* `state` comes back `null`), so it paused loops that had made real
|
|
31
|
+
* progress; it is removed. The `no_progress` condition and pause reason
|
|
32
|
+
* survive only for the driver's own attach-redelivery pause and for
|
|
33
|
+
* already-written journals, never as an assessment exit here.
|
|
34
|
+
*
|
|
35
|
+
* Reuse, not a second counter: the id-state map for each round is built by
|
|
36
|
+
* calling `groupRounds` (`../review-status`) with synthetic same-key
|
|
37
|
+
* `VerdictComment`s — the exact "first non-null state wins" merge this
|
|
38
|
+
* module needs for combining a round's reviewer and security findings, with
|
|
39
|
+
* no forked copy of that rule. The reappearance comparison itself is new:
|
|
40
|
+
* `groupRounds` merges one round's ids, it does not compare across rounds,
|
|
41
|
+
* and `review-status.ts`'s own reappearance/zero-deaths triggers serve a
|
|
42
|
+
* different consumer — this module owns the exit predicates (O2: "decided
|
|
43
|
+
* there and nowhere else"), built on the reused map.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
import { groupRounds, type Round, type VerdictComment } from '../review-status'
|
|
47
|
+
import {
|
|
48
|
+
SEVERITY_COLUMNS,
|
|
49
|
+
type Confidence,
|
|
50
|
+
type Decision,
|
|
51
|
+
type DevReviewLoopEventInput,
|
|
52
|
+
type LoopState,
|
|
53
|
+
type Observations,
|
|
54
|
+
type PendingRound,
|
|
55
|
+
type RoundOutcome,
|
|
56
|
+
type RoundRecord,
|
|
57
|
+
type RoundStats,
|
|
58
|
+
type VerdictObservation
|
|
59
|
+
} from './types'
|
|
60
|
+
|
|
61
|
+
function loopEventEnvelope(state: LoopState): {
|
|
62
|
+
kind: 'dev_review_loop'
|
|
63
|
+
payload: Record<string, never>
|
|
64
|
+
loop_id: string
|
|
65
|
+
} {
|
|
66
|
+
return { kind: 'dev_review_loop', payload: {}, loop_id: state.config.loopId }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function loopStartedEvent(state: LoopState): DevReviewLoopEventInput {
|
|
70
|
+
return {
|
|
71
|
+
...loopEventEnvelope(state),
|
|
72
|
+
event: 'loop_started',
|
|
73
|
+
task: state.config.task,
|
|
74
|
+
policy: {
|
|
75
|
+
// Repository policy, resolved once by the driver into
|
|
76
|
+
// `LoopConfig.maxRounds` — never a hardcoded constant here.
|
|
77
|
+
max_rounds: state.config.maxRounds,
|
|
78
|
+
reviewers: state.config.reviewers as never,
|
|
79
|
+
models: state.config.models as never
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function roundStartedEvent(state: LoopState, round: number, baseHead: string): DevReviewLoopEventInput {
|
|
85
|
+
return { ...loopEventEnvelope(state), event: 'round_started', round, base_head: baseHead }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* `confidence` is exactly what THIS gate call's own confidence read
|
|
90
|
+
* returned — `undefined` for round 1 or a red gate (neither ever reads the
|
|
91
|
+
* file), `'absent'` for a missing or malformed statement, or the parsed
|
|
92
|
+
* value/reason otherwise. Called once per `assessGate` invocation, not only
|
|
93
|
+
* a round's first: a re-ask that recovers a real statement after an earlier
|
|
94
|
+
* absent read gets its own event, rather than leaving the round's log stuck
|
|
95
|
+
* on the earlier read's `confidence_unavailable: true`. `state.extraTurnUsed`
|
|
96
|
+
* is read here, before this call's own branch in `assessGate` can set it —
|
|
97
|
+
* so it reports whether the confidence rule's one extra turn was already
|
|
98
|
+
* spent BEFORE this read, never whether this call's own outcome later spends
|
|
99
|
+
* it.
|
|
100
|
+
*/
|
|
101
|
+
function gateResultReadEvent(
|
|
102
|
+
state: LoopState,
|
|
103
|
+
round: number,
|
|
104
|
+
head: string,
|
|
105
|
+
green: boolean,
|
|
106
|
+
confidence: Confidence | undefined
|
|
107
|
+
): DevReviewLoopEventInput {
|
|
108
|
+
const confidenceFields =
|
|
109
|
+
confidence === undefined
|
|
110
|
+
? {}
|
|
111
|
+
: confidence === 'absent'
|
|
112
|
+
? { confidence_unavailable: true as const, extra_turn_spent: state.extraTurnUsed }
|
|
113
|
+
: {
|
|
114
|
+
confidence_value: confidence.value,
|
|
115
|
+
...(confidence.reason !== undefined ? { confidence_reason: confidence.reason } : {}),
|
|
116
|
+
extra_turn_spent: state.extraTurnUsed
|
|
117
|
+
}
|
|
118
|
+
return { ...loopEventEnvelope(state), event: 'gate_result_read', round, head, green, ...confidenceFields }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* `FindingObservation` → `ReviewFindingSchema`
|
|
123
|
+
* field-for-field, snake_cased at this boundary the same way every other
|
|
124
|
+
* envelope field already is. `state: null` reads back as omitted — the
|
|
125
|
+
* schema's own `state` is an optional string, never nullable, matching
|
|
126
|
+
* `dispatchShared`'s sibling fields' own "absent, not null" convention.
|
|
127
|
+
*/
|
|
128
|
+
function toReviewFinding(f: VerdictObservation['findings'][number]): {
|
|
129
|
+
id: string
|
|
130
|
+
severity: string
|
|
131
|
+
state?: string
|
|
132
|
+
severity_scale?: string
|
|
133
|
+
policy_treatment?: 'blocking' | 'non_blocking' | 'unavailable'
|
|
134
|
+
confidence?: number
|
|
135
|
+
confidence_scale?: string
|
|
136
|
+
confidence_source?: string
|
|
137
|
+
} {
|
|
138
|
+
return {
|
|
139
|
+
id: f.id,
|
|
140
|
+
severity: f.severity,
|
|
141
|
+
...(f.state !== null && f.state !== undefined ? { state: f.state } : {}),
|
|
142
|
+
...(f.severityScale !== undefined ? { severity_scale: f.severityScale } : {}),
|
|
143
|
+
...(f.policyTreatment !== undefined ? { policy_treatment: f.policyTreatment } : {}),
|
|
144
|
+
...(f.confidence !== undefined ? { confidence: f.confidence } : {}),
|
|
145
|
+
...(f.confidenceScale !== undefined ? { confidence_scale: f.confidenceScale } : {}),
|
|
146
|
+
...(f.confidenceSource !== undefined ? { confidence_source: f.confidenceSource } : {})
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function verdictsReadEvent(state: LoopState, round: number, verdicts: VerdictObservation[]): DevReviewLoopEventInput {
|
|
151
|
+
const allApprove = verdicts.every((v) => v.verdict === 'APPROVE' || v.verdict === 'PASS')
|
|
152
|
+
const head = pendingHead(state, round)
|
|
153
|
+
const blockers = verdicts.filter((v) => v.verdict === 'REQUEST CHANGES' || v.verdict === 'FAIL').length
|
|
154
|
+
const findings = verdicts.flatMap((v) => v.findings.map(toReviewFinding))
|
|
155
|
+
return {
|
|
156
|
+
...loopEventEnvelope(state),
|
|
157
|
+
event: 'verdicts_read',
|
|
158
|
+
round,
|
|
159
|
+
head,
|
|
160
|
+
all_approve: allApprove,
|
|
161
|
+
blockers,
|
|
162
|
+
findings
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
type FindingsCompared = { round: number; open: string[]; resolved: string[]; new: string[]; recurring: string[] }
|
|
167
|
+
|
|
168
|
+
function findingsComparedEvent(state: LoopState, fc: FindingsCompared): DevReviewLoopEventInput {
|
|
169
|
+
return { ...loopEventEnvelope(state), event: 'findings_compared', ...fc }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function stopConditionMetEvent(
|
|
173
|
+
state: LoopState,
|
|
174
|
+
round: number,
|
|
175
|
+
condition: 'green' | 'max_rounds' | 'no_progress' | 'escalated' | 'confidence' | 'reappearance'
|
|
176
|
+
): DevReviewLoopEventInput {
|
|
177
|
+
return { ...loopEventEnvelope(state), event: 'stop_condition_met', round, condition }
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function pausedEvent(
|
|
181
|
+
state: LoopState,
|
|
182
|
+
round: number,
|
|
183
|
+
reason: 'escalation' | 'principal_item'
|
|
184
|
+
): DevReviewLoopEventInput {
|
|
185
|
+
return { ...loopEventEnvelope(state), event: 'paused', round, reason }
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function roundEndedEvent(
|
|
189
|
+
state: LoopState,
|
|
190
|
+
round: number,
|
|
191
|
+
stats: RoundStats,
|
|
192
|
+
outcome: 'green' | 'changes_requested' | 'escalated'
|
|
193
|
+
): DevReviewLoopEventInput {
|
|
194
|
+
return {
|
|
195
|
+
...loopEventEnvelope(state),
|
|
196
|
+
event: 'round_ended',
|
|
197
|
+
round,
|
|
198
|
+
base_head: stats.baseHead,
|
|
199
|
+
head: stats.head,
|
|
200
|
+
files_changed: stats.filesChanged,
|
|
201
|
+
insertions: stats.insertions,
|
|
202
|
+
deletions: stats.deletions,
|
|
203
|
+
wall_ms: stats.wallMs,
|
|
204
|
+
outcome
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function journalFinalizedEvent(
|
|
209
|
+
state: LoopState,
|
|
210
|
+
finalHead: string,
|
|
211
|
+
result: 'merged_ready' | 'stopped'
|
|
212
|
+
): DevReviewLoopEventInput {
|
|
213
|
+
return {
|
|
214
|
+
...loopEventEnvelope(state),
|
|
215
|
+
event: 'journal_finalized',
|
|
216
|
+
rounds: state.rounds.length,
|
|
217
|
+
total_wall_ms: state.totalWallMs,
|
|
218
|
+
time_to_green_ms: result === 'merged_ready' ? state.totalWallMs : null,
|
|
219
|
+
files_changed_total: state.totalFilesChanged,
|
|
220
|
+
final_head: finalHead,
|
|
221
|
+
result
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function pendingHead(state: LoopState, round: number): string {
|
|
226
|
+
if (state.pending && state.pending.round === round) return state.pending.stats.head
|
|
227
|
+
return ''
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function buildRoundRecord(
|
|
231
|
+
round: number,
|
|
232
|
+
verdicts: VerdictObservation[],
|
|
233
|
+
confidence: Confidence | null,
|
|
234
|
+
outcome: RoundOutcome
|
|
235
|
+
): RoundRecord {
|
|
236
|
+
const countsBySeverity: Record<string, number> = {}
|
|
237
|
+
for (const v of verdicts) {
|
|
238
|
+
for (const f of v.findings) {
|
|
239
|
+
const key = f.severity.toLowerCase()
|
|
240
|
+
if (!(SEVERITY_COLUMNS as readonly string[]).includes(key)) continue
|
|
241
|
+
countsBySeverity[key] = (countsBySeverity[key] ?? 0) + 1
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return { round, countsBySeverity, confidence, outcome }
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Folds one round's diff stats into the running totals `journal_finalized` reports — never recomputed from `rounds`. */
|
|
248
|
+
function withRoundStats(state: LoopState, stats: RoundStats): Pick<LoopState, 'totalWallMs' | 'totalFilesChanged'> {
|
|
249
|
+
return {
|
|
250
|
+
totalWallMs: state.totalWallMs + stats.wallMs,
|
|
251
|
+
totalFilesChanged: state.totalFilesChanged + stats.filesChanged
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Merges every verdict's findings into one round's id → state map, reusing `groupRounds`'s exact merge rule. */
|
|
256
|
+
function mergeFindings(verdicts: VerdictObservation[]): Map<string, string | null> {
|
|
257
|
+
const comments: VerdictComment[] = verdicts.map((v) => ({
|
|
258
|
+
judgedHead: 'this-round',
|
|
259
|
+
objectivesVersion: null,
|
|
260
|
+
ids: new Map(v.findings.map((f) => [f.id, f.state] as const))
|
|
261
|
+
}))
|
|
262
|
+
const rounds: Round[] = groupRounds(comments)
|
|
263
|
+
return rounds[0]?.ids ?? new Map()
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function computeFindingsCompared(
|
|
267
|
+
round: number,
|
|
268
|
+
priorIds: Map<string, string | null>,
|
|
269
|
+
currentIds: Map<string, string | null>
|
|
270
|
+
): FindingsCompared {
|
|
271
|
+
const open: string[] = []
|
|
272
|
+
const resolved: string[] = []
|
|
273
|
+
const newIds: string[] = []
|
|
274
|
+
const recurring: string[] = []
|
|
275
|
+
for (const [id, state] of currentIds) {
|
|
276
|
+
if (state === 'resolved') resolved.push(id)
|
|
277
|
+
else open.push(id)
|
|
278
|
+
if (!priorIds.has(id)) newIds.push(id)
|
|
279
|
+
else if (priorIds.get(id) === 'resolved' && state === 'reproduced') recurring.push(id)
|
|
280
|
+
}
|
|
281
|
+
return { round, open, resolved, new: newIds, recurring }
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function mergedIds(
|
|
285
|
+
priorIds: Map<string, string | null>,
|
|
286
|
+
currentIds: Map<string, string | null>
|
|
287
|
+
): Map<string, string | null> {
|
|
288
|
+
const merged = new Map(priorIds)
|
|
289
|
+
for (const [id, state] of currentIds) merged.set(id, state)
|
|
290
|
+
return merged
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function assessGate(
|
|
294
|
+
state: LoopState,
|
|
295
|
+
obs: { round: number; green: boolean; confidence?: Confidence; stats: RoundStats }
|
|
296
|
+
): { decision: Decision; state: LoopState; events: DevReviewLoopEventInput[] } {
|
|
297
|
+
const events: DevReviewLoopEventInput[] = []
|
|
298
|
+
const isNewRound = state.pending === null || state.pending.round !== obs.round
|
|
299
|
+
if (isNewRound) {
|
|
300
|
+
if (state.rounds.length === 0 && state.pending === null) events.push(loopStartedEvent(state))
|
|
301
|
+
events.push(roundStartedEvent(state, obs.round, obs.stats.baseHead))
|
|
302
|
+
}
|
|
303
|
+
// A confidence re-ask keeps `pending` alive on the SAME round (only its
|
|
304
|
+
// `confidenceAskCount` advances), so `isNewRound` alone would suppress the
|
|
305
|
+
// second, real read's own event and leave the round's log stuck on the
|
|
306
|
+
// first read's `confidence_unavailable: true` — logged even after the loop
|
|
307
|
+
// went on to read and act on a real value. Emitting on every call, not
|
|
308
|
+
// only a new round, means the re-ask's real read gets its own event too.
|
|
309
|
+
events.push(gateResultReadEvent(state, obs.round, obs.stats.head, obs.green, obs.confidence))
|
|
310
|
+
|
|
311
|
+
if (!obs.green) {
|
|
312
|
+
events.push(roundEndedEvent(state, obs.round, obs.stats, 'changes_requested'))
|
|
313
|
+
const record = buildRoundRecord(obs.round, [], null, 'changes_requested')
|
|
314
|
+
const newState: LoopState = {
|
|
315
|
+
...state,
|
|
316
|
+
rounds: [...state.rounds, record],
|
|
317
|
+
pending: null,
|
|
318
|
+
...withRoundStats(state, obs.stats)
|
|
319
|
+
}
|
|
320
|
+
return { decision: { type: 'dispatch_developer' }, state: newState, events }
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (obs.round === 1) {
|
|
324
|
+
const pending: PendingRound = {
|
|
325
|
+
round: obs.round,
|
|
326
|
+
stats: obs.stats,
|
|
327
|
+
confidenceAskCount: 0,
|
|
328
|
+
confidence: obs.confidence ?? null,
|
|
329
|
+
priorIds: state.lastIds
|
|
330
|
+
}
|
|
331
|
+
return { decision: { type: 'dispatch_reviewers' }, state: { ...state, pending }, events }
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Round ≥ 2: the confidence gate.
|
|
335
|
+
const priorAskCount = isNewRound ? 0 : (state.pending?.confidenceAskCount ?? 0)
|
|
336
|
+
const confidence = obs.confidence ?? 'absent'
|
|
337
|
+
|
|
338
|
+
if (confidence === 'absent') {
|
|
339
|
+
if (priorAskCount >= 1) {
|
|
340
|
+
events.push(stopConditionMetEvent(state, obs.round, 'confidence'))
|
|
341
|
+
events.push(pausedEvent(state, obs.round, 'principal_item'))
|
|
342
|
+
events.push(roundEndedEvent(state, obs.round, obs.stats, 'changes_requested'))
|
|
343
|
+
const record = buildRoundRecord(obs.round, [], null, 'stopped')
|
|
344
|
+
const preFinalize: LoopState = {
|
|
345
|
+
...state,
|
|
346
|
+
rounds: [...state.rounds, record],
|
|
347
|
+
pending: null,
|
|
348
|
+
...withRoundStats(state, obs.stats)
|
|
349
|
+
}
|
|
350
|
+
events.push(journalFinalizedEvent(preFinalize, obs.stats.head, 'stopped'))
|
|
351
|
+
return { decision: { type: 'pause', reason: 'confidence' }, state: preFinalize, events }
|
|
352
|
+
}
|
|
353
|
+
const pending: PendingRound = {
|
|
354
|
+
round: obs.round,
|
|
355
|
+
stats: obs.stats,
|
|
356
|
+
confidenceAskCount: priorAskCount + 1,
|
|
357
|
+
confidence: null,
|
|
358
|
+
priorIds: state.lastIds
|
|
359
|
+
}
|
|
360
|
+
return { decision: { type: 'ask_confidence' }, state: { ...state, pending }, events }
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (confidence.value < 50) {
|
|
364
|
+
if (state.extraTurnUsed) {
|
|
365
|
+
events.push(stopConditionMetEvent(state, obs.round, 'confidence'))
|
|
366
|
+
events.push(pausedEvent(state, obs.round, 'principal_item'))
|
|
367
|
+
events.push(roundEndedEvent(state, obs.round, obs.stats, 'changes_requested'))
|
|
368
|
+
const record = buildRoundRecord(obs.round, [], confidence, 'stopped')
|
|
369
|
+
const preFinalize: LoopState = {
|
|
370
|
+
...state,
|
|
371
|
+
rounds: [...state.rounds, record],
|
|
372
|
+
pending: null,
|
|
373
|
+
...withRoundStats(state, obs.stats)
|
|
374
|
+
}
|
|
375
|
+
events.push(journalFinalizedEvent(preFinalize, obs.stats.head, 'stopped'))
|
|
376
|
+
return { decision: { type: 'pause', reason: 'confidence' }, state: preFinalize, events }
|
|
377
|
+
}
|
|
378
|
+
events.push(roundEndedEvent(state, obs.round, obs.stats, 'changes_requested'))
|
|
379
|
+
const record = buildRoundRecord(obs.round, [], confidence, 'changes_requested')
|
|
380
|
+
const newState: LoopState = {
|
|
381
|
+
...state,
|
|
382
|
+
rounds: [...state.rounds, record],
|
|
383
|
+
pending: null,
|
|
384
|
+
extraTurnUsed: true,
|
|
385
|
+
...withRoundStats(state, obs.stats)
|
|
386
|
+
}
|
|
387
|
+
return { decision: { type: 'dispatch_developer', reason: 'confidence' }, state: newState, events }
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const pending: PendingRound = {
|
|
391
|
+
round: obs.round,
|
|
392
|
+
stats: obs.stats,
|
|
393
|
+
confidenceAskCount: priorAskCount,
|
|
394
|
+
confidence,
|
|
395
|
+
priorIds: state.lastIds
|
|
396
|
+
}
|
|
397
|
+
return { decision: { type: 'dispatch_reviewers' }, state: { ...state, pending }, events }
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function assessVerdicts(
|
|
401
|
+
state: LoopState,
|
|
402
|
+
obs: { round: number; verdicts: VerdictObservation[] }
|
|
403
|
+
): { decision: Decision; state: LoopState; events: DevReviewLoopEventInput[] } {
|
|
404
|
+
const pending = state.pending
|
|
405
|
+
if (pending === null || pending.round !== obs.round) {
|
|
406
|
+
throw new Error(`assessRound: verdicts observation for round ${obs.round} with no matching pending gate result`)
|
|
407
|
+
}
|
|
408
|
+
const events: DevReviewLoopEventInput[] = [verdictsReadEvent(state, obs.round, obs.verdicts)]
|
|
409
|
+
|
|
410
|
+
const currentIds = mergeFindings(obs.verdicts)
|
|
411
|
+
const fc = computeFindingsCompared(obs.round, pending.priorIds, currentIds)
|
|
412
|
+
events.push(findingsComparedEvent(state, fc))
|
|
413
|
+
|
|
414
|
+
const carriedIds = mergedIds(pending.priorIds, currentIds)
|
|
415
|
+
const confidence = pending.confidence
|
|
416
|
+
|
|
417
|
+
const hasEscalate = obs.verdicts.some((v) => v.verdict === 'ESCALATE')
|
|
418
|
+
if (hasEscalate) {
|
|
419
|
+
events.push(stopConditionMetEvent(state, obs.round, 'escalated'))
|
|
420
|
+
events.push(pausedEvent(state, obs.round, 'escalation'))
|
|
421
|
+
events.push(roundEndedEvent(state, obs.round, pending.stats, 'escalated'))
|
|
422
|
+
const record = buildRoundRecord(obs.round, obs.verdicts, confidence, 'escalated')
|
|
423
|
+
const preFinalize: LoopState = {
|
|
424
|
+
...state,
|
|
425
|
+
rounds: [...state.rounds, record],
|
|
426
|
+
pending: null,
|
|
427
|
+
lastIds: carriedIds,
|
|
428
|
+
...withRoundStats(state, pending.stats)
|
|
429
|
+
}
|
|
430
|
+
events.push(journalFinalizedEvent(preFinalize, pending.stats.head, 'stopped'))
|
|
431
|
+
return { decision: { type: 'pause', reason: 'escalation' }, state: preFinalize, events }
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const allObjectivesMet = obs.verdicts.every((v) => v.objectives.every((o) => o.met))
|
|
435
|
+
const allApprove = obs.verdicts.every((v) => v.verdict === 'APPROVE' || v.verdict === 'PASS')
|
|
436
|
+
const clean = allApprove && allObjectivesMet
|
|
437
|
+
|
|
438
|
+
if (clean) {
|
|
439
|
+
events.push(stopConditionMetEvent(state, obs.round, 'green'))
|
|
440
|
+
events.push(roundEndedEvent(state, obs.round, pending.stats, 'green'))
|
|
441
|
+
const record = buildRoundRecord(obs.round, obs.verdicts, confidence, 'green')
|
|
442
|
+
const preFinalize: LoopState = {
|
|
443
|
+
...state,
|
|
444
|
+
rounds: [...state.rounds, record],
|
|
445
|
+
pending: null,
|
|
446
|
+
lastIds: carriedIds,
|
|
447
|
+
...withRoundStats(state, pending.stats)
|
|
448
|
+
}
|
|
449
|
+
events.push(journalFinalizedEvent(preFinalize, pending.stats.head, 'merged_ready'))
|
|
450
|
+
return { decision: { type: 'publish' }, state: preFinalize, events }
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (fc.recurring.length > 0) {
|
|
454
|
+
events.push(stopConditionMetEvent(state, obs.round, 'reappearance'))
|
|
455
|
+
events.push(pausedEvent(state, obs.round, 'principal_item'))
|
|
456
|
+
events.push(roundEndedEvent(state, obs.round, pending.stats, 'changes_requested'))
|
|
457
|
+
const record = buildRoundRecord(obs.round, obs.verdicts, confidence, 'stopped')
|
|
458
|
+
const preFinalize: LoopState = {
|
|
459
|
+
...state,
|
|
460
|
+
rounds: [...state.rounds, record],
|
|
461
|
+
pending: null,
|
|
462
|
+
lastIds: carriedIds,
|
|
463
|
+
...withRoundStats(state, pending.stats)
|
|
464
|
+
}
|
|
465
|
+
events.push(journalFinalizedEvent(preFinalize, pending.stats.head, 'stopped'))
|
|
466
|
+
return { decision: { type: 'pause', reason: 'reappearance' }, state: preFinalize, events }
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (obs.round > state.config.maxRounds) {
|
|
470
|
+
events.push(stopConditionMetEvent(state, obs.round, 'max_rounds'))
|
|
471
|
+
events.push(pausedEvent(state, obs.round, 'principal_item'))
|
|
472
|
+
events.push(roundEndedEvent(state, obs.round, pending.stats, 'changes_requested'))
|
|
473
|
+
const record = buildRoundRecord(obs.round, obs.verdicts, confidence, 'stopped')
|
|
474
|
+
const preFinalize: LoopState = {
|
|
475
|
+
...state,
|
|
476
|
+
rounds: [...state.rounds, record],
|
|
477
|
+
pending: null,
|
|
478
|
+
lastIds: carriedIds,
|
|
479
|
+
...withRoundStats(state, pending.stats)
|
|
480
|
+
}
|
|
481
|
+
events.push(journalFinalizedEvent(preFinalize, pending.stats.head, 'stopped'))
|
|
482
|
+
// The pause names the configured cap, not a bare "max_rounds".
|
|
483
|
+
return {
|
|
484
|
+
decision: { type: 'pause', reason: 'max_rounds', detail: `max rounds: ${state.config.maxRounds}` },
|
|
485
|
+
state: preFinalize,
|
|
486
|
+
events
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
events.push(roundEndedEvent(state, obs.round, pending.stats, 'changes_requested'))
|
|
491
|
+
const record = buildRoundRecord(obs.round, obs.verdicts, confidence, 'changes_requested')
|
|
492
|
+
const newState: LoopState = {
|
|
493
|
+
...state,
|
|
494
|
+
rounds: [...state.rounds, record],
|
|
495
|
+
pending: null,
|
|
496
|
+
lastIds: carriedIds,
|
|
497
|
+
...withRoundStats(state, pending.stats)
|
|
498
|
+
}
|
|
499
|
+
return { decision: { type: 'dispatch_developer' }, state: newState, events }
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* `assessRound(state, observations) → { decision, state, events }` — pure,
|
|
504
|
+
* no I/O. `events` is the `DevReviewLoopEventInput[]` the caller passes,
|
|
505
|
+
* unchanged, to the injected `log()`; `assessRound` itself never calls
|
|
506
|
+
* it.
|
|
507
|
+
*/
|
|
508
|
+
export function assessRound(
|
|
509
|
+
state: LoopState,
|
|
510
|
+
observations: Observations
|
|
511
|
+
): { decision: Decision; state: LoopState; events: DevReviewLoopEventInput[] } {
|
|
512
|
+
if (observations.kind === 'gate') return assessGate(state, observations)
|
|
513
|
+
return assessVerdicts(state, observations)
|
|
514
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scripted fakes for the developer, both reviewers, and CI — zero network,
|
|
3
|
+
* zero subprocesses. Each fake produces a
|
|
4
|
+
* typed `Observations`/`VerdictObservation` value exactly as the real driver
|
|
5
|
+
* would once it has decoded the real actor's output; nothing here reaches a
|
|
6
|
+
* process, a file, or the forge.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { assessRound } from './assess-round'
|
|
10
|
+
import type {
|
|
11
|
+
Confidence,
|
|
12
|
+
Decision,
|
|
13
|
+
DevReviewLoopEventInput,
|
|
14
|
+
LoopState,
|
|
15
|
+
Observations,
|
|
16
|
+
RoundStats,
|
|
17
|
+
VerdictObservation
|
|
18
|
+
} from './types'
|
|
19
|
+
|
|
20
|
+
export function fakeStats(round: number, overrides: Partial<RoundStats> = {}): RoundStats {
|
|
21
|
+
return {
|
|
22
|
+
baseHead: `base${round}`,
|
|
23
|
+
head: `head${round}`,
|
|
24
|
+
filesChanged: 1,
|
|
25
|
+
insertions: 1,
|
|
26
|
+
deletions: 1,
|
|
27
|
+
wallMs: 1000,
|
|
28
|
+
...overrides
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The CI fake: a round's mechanical-gate result, optionally carrying the developer's confidence. */
|
|
33
|
+
export function fakeGate(
|
|
34
|
+
round: number,
|
|
35
|
+
green: boolean,
|
|
36
|
+
opts: { confidence?: Confidence; stats?: Partial<RoundStats> } = {}
|
|
37
|
+
): Observations {
|
|
38
|
+
return {
|
|
39
|
+
kind: 'gate',
|
|
40
|
+
round,
|
|
41
|
+
green,
|
|
42
|
+
...(opts.confidence !== undefined ? { confidence: opts.confidence } : {}),
|
|
43
|
+
stats: fakeStats(round, opts.stats)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The two-reviewer fake: bundles both verdicts into one round observation. */
|
|
48
|
+
export function fakeVerdicts(round: number, verdicts: VerdictObservation[]): Observations {
|
|
49
|
+
return { kind: 'verdicts', round, verdicts }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A clean reviewer/security verdict: approves, every named objective met, no findings. */
|
|
53
|
+
export function cleanVerdict(role: 'reviewer' | 'security', objectiveIds: string[] = []): VerdictObservation {
|
|
54
|
+
return {
|
|
55
|
+
role,
|
|
56
|
+
verdict: role === 'reviewer' ? 'APPROVE' : 'PASS',
|
|
57
|
+
objectives: objectiveIds.map((id) => ({ id, met: true })),
|
|
58
|
+
findings: []
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A reviewer/security verdict carrying findings — the verdict is derived (spec Rev 3.3 item 3), not asserted independently. */
|
|
63
|
+
export function blockingVerdict(
|
|
64
|
+
role: 'reviewer' | 'security',
|
|
65
|
+
findings: VerdictObservation['findings'],
|
|
66
|
+
objectiveIds: string[] = []
|
|
67
|
+
): VerdictObservation {
|
|
68
|
+
return {
|
|
69
|
+
role,
|
|
70
|
+
verdict: role === 'reviewer' ? 'REQUEST CHANGES' : 'FAIL',
|
|
71
|
+
objectives: objectiveIds.map((id) => ({ id, met: true })),
|
|
72
|
+
findings
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function escalateVerdict(role: 'reviewer' | 'security'): VerdictObservation {
|
|
77
|
+
return { role, verdict: 'ESCALATE', objectives: [], findings: [] }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A clean verdict whose objectives block carries one `NOT MET` entry — O3's "regardless of findings" case. */
|
|
81
|
+
export function notMetVerdict(role: 'reviewer' | 'security', objectiveIds: string[]): VerdictObservation {
|
|
82
|
+
return {
|
|
83
|
+
role,
|
|
84
|
+
verdict: role === 'reviewer' ? 'APPROVE' : 'PASS',
|
|
85
|
+
objectives: objectiveIds.map((id, i) => ({ id, met: i !== 0 })),
|
|
86
|
+
findings: []
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Drives `assessRound` through a scripted sequence of observations, threading
|
|
92
|
+
* state forward and concatenating every emitted event — the shape Part 1's
|
|
93
|
+
* byte-for-byte event-list assertion needs. Returns the final state, the flat
|
|
94
|
+
* event list, and every decision returned along the way (in order).
|
|
95
|
+
*/
|
|
96
|
+
export function runScenario(
|
|
97
|
+
initial: LoopState,
|
|
98
|
+
steps: Observations[]
|
|
99
|
+
): { state: LoopState; events: DevReviewLoopEventInput[]; decisions: Decision[] } {
|
|
100
|
+
let state = initial
|
|
101
|
+
const events: DevReviewLoopEventInput[] = []
|
|
102
|
+
const decisions: Decision[] = []
|
|
103
|
+
for (const step of steps) {
|
|
104
|
+
const result = assessRound(state, step)
|
|
105
|
+
state = result.state
|
|
106
|
+
events.push(...result.events)
|
|
107
|
+
decisions.push(result.decision)
|
|
108
|
+
}
|
|
109
|
+
return { state, events, decisions }
|
|
110
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { assessRound } from './assess-round'
|
|
2
|
+
export { renderSummary } from './render-summary'
|
|
3
|
+
export { initialLoopState } from './types'
|
|
4
|
+
export {
|
|
5
|
+
isPublishedSummaryComment,
|
|
6
|
+
nextRoundNumber,
|
|
7
|
+
reconstructRounds,
|
|
8
|
+
SUMMARY_TABLE_HEADER
|
|
9
|
+
} from './journal-reconstruction'
|
|
10
|
+
export type { ReconstructedJournal, ReconstructionInput } from './journal-reconstruction'
|
|
11
|
+
export type {
|
|
12
|
+
Confidence,
|
|
13
|
+
Decision,
|
|
14
|
+
DevReviewLoopEventInput,
|
|
15
|
+
FindingObservation,
|
|
16
|
+
FindingState,
|
|
17
|
+
Journal,
|
|
18
|
+
LoopConfig,
|
|
19
|
+
LoopState,
|
|
20
|
+
Observations,
|
|
21
|
+
PauseReason,
|
|
22
|
+
PendingRound,
|
|
23
|
+
RoundOutcome,
|
|
24
|
+
RoundRecord,
|
|
25
|
+
RoundStats,
|
|
26
|
+
VerdictObservation
|
|
27
|
+
} from './types'
|