@attalabs/vinaya 0.32.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 +1 -1
- package/aeg-root/contracts/principal-operator.md +18 -5
- 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/dist/checks/bin/check-body-bare-digits.js +111 -15
- package/dist/checks/bin/check-branch-topology.js +83 -16
- package/dist/checks/bin/check-brief-shape.js +111 -15
- package/dist/checks/bin/check-changeset-coverage.js +342 -69
- package/dist/checks/bin/check-closes-n.js +83 -16
- package/dist/checks/bin/check-coherence.js +112 -16
- package/dist/checks/bin/check-dead-branch-push.js +82 -15
- package/dist/checks/bin/check-dispatch-readiness.js +112 -16
- package/dist/checks/bin/check-doc-coverage-push.js +342 -69
- package/dist/checks/bin/check-doc-coverage.js +342 -69
- package/dist/checks/bin/check-doctrine-no-procedures.js +111 -15
- package/dist/checks/bin/check-doctrine-portability.js +342 -69
- package/dist/checks/bin/check-evidence-fresh.js +343 -69
- package/dist/checks/bin/check-exec-bits.js +342 -69
- package/dist/checks/bin/check-first-push-dispatch.js +112 -16
- package/dist/checks/bin/check-issue-assignment.js +83 -16
- package/dist/checks/bin/check-issue-milestone-attach.js +82 -15
- package/dist/checks/bin/check-issue-objectives-numbering.js +82 -15
- package/dist/checks/bin/check-issue-parts-coverage.js +82 -15
- package/dist/checks/bin/check-issue-surface-globs.js +112 -16
- package/dist/checks/bin/check-issue-title-grammar.js +82 -15
- package/dist/checks/bin/check-issue-tranche-label.js +82 -15
- package/dist/checks/bin/check-main-branch-refusal.js +82 -15
- package/dist/checks/bin/check-no-disk-state.js +82 -15
- package/dist/checks/bin/check-pr-premise-reassert.js +111 -15
- package/dist/checks/bin/check-pr-report-density.js +82 -15
- package/dist/checks/bin/check-principal-test-plan-wait.js +82 -15
- package/dist/checks/bin/check-quoted-command.js +342 -69
- package/dist/checks/bin/check-reader-resolvable-prose.js +342 -69
- package/dist/checks/bin/check-registry-gates.js +82 -15
- package/dist/checks/bin/check-retired-vocabulary.js +342 -69
- package/dist/checks/bin/check-review-gate.js +179 -124
- package/dist/checks/bin/check-single-plan-pr.js +82 -15
- package/dist/checks/bin/check-surface-scope.js +83 -16
- package/dist/checks/bin/check-test-plan.js +82 -15
- package/dist/checks/bin/check-token-collection-wired.js +82 -15
- package/dist/checks/bin/check-token-report.js +82 -15
- package/dist/checks/bin/check-workspace-escape.js +342 -69
- package/dist/index.js +2495 -590
- package/dist/lib/pre-push-cache-test-run.js +317 -61
- package/dist/lib/pre-push-select-tests.js +91 -10
- package/package.json +1 -1
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The review loop's own state, derived
|
|
2
|
+
* The review loop's own state, derived.
|
|
3
3
|
* Pure — no `fs`, no `fetch`, no `process.env`; the CLI shim
|
|
4
4
|
* (`apps/cli/src/commands/review-status.ts`) fetches the PR's comments, head
|
|
5
5
|
* and base through `gh` and hands them here.
|
|
@@ -42,13 +42,27 @@ const FINDING_LINE =
|
|
|
42
42
|
|
|
43
43
|
export type ReviewStatus =
|
|
44
44
|
| { state: 'CONTINUE' }
|
|
45
|
-
| {
|
|
45
|
+
| {
|
|
46
|
+
state: 'PAUSE'
|
|
47
|
+
reason: 'reappearance' | 'zero-deaths' | 'stale' | 'objectives-moved' | 'max-rounds'
|
|
48
|
+
id?: string
|
|
49
|
+
round: number
|
|
50
|
+
}
|
|
46
51
|
|
|
47
52
|
export type ReviewStatusInput = {
|
|
48
53
|
comments: { body: string; author: string | null }[]
|
|
49
54
|
headSha: string
|
|
50
55
|
principalAllowlist: string[]
|
|
51
56
|
maxRounds: number
|
|
57
|
+
/**
|
|
58
|
+
* The current `objectivesVersion` this PR is judged against —
|
|
59
|
+
* same resolution `checkReviewGate`'s caller supplies. `null` (or the field
|
|
60
|
+
* omitted entirely — the CLI command wiring is a separate task's surface,
|
|
61
|
+
* so an existing caller that does not supply it yet must keep compiling
|
|
62
|
+
* and behaving exactly as before) skips the `objectives-moved` pause
|
|
63
|
+
* entirely — the same fail-open-on-`null` rule the gate itself uses.
|
|
64
|
+
*/
|
|
65
|
+
objectivesVersion?: string | null
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
/**
|
|
@@ -64,9 +78,13 @@ export function parseDeveloperRoundMarker(body: string): number | null {
|
|
|
64
78
|
return Number.isFinite(n) ? n : null
|
|
65
79
|
}
|
|
66
80
|
|
|
67
|
-
type VerdictComment = {
|
|
81
|
+
export type VerdictComment = {
|
|
82
|
+
judgedHead: string | null
|
|
83
|
+
objectivesVersion: string | null
|
|
84
|
+
ids: Map<string, string | null>
|
|
85
|
+
}
|
|
68
86
|
|
|
69
|
-
function findingStates(body: string): Map<string, string | null> {
|
|
87
|
+
export function findingStates(body: string): Map<string, string | null> {
|
|
70
88
|
const out = new Map<string, string | null>()
|
|
71
89
|
for (const m of body.matchAll(FINDING_LINE)) {
|
|
72
90
|
const id = `F${m[1]}`
|
|
@@ -87,22 +105,35 @@ function asVerdictComment(body: string): VerdictComment | null {
|
|
|
87
105
|
const code = extractCodeReviewVerdict([body])
|
|
88
106
|
const security = extractSecurityReviewVerdict([body])
|
|
89
107
|
if (code.danglingNote !== null && security.danglingNote !== null) return null
|
|
90
|
-
return {
|
|
108
|
+
return {
|
|
109
|
+
judgedHead: code.headSha ?? security.headSha,
|
|
110
|
+
objectivesVersion: code.objectivesVersion ?? security.objectivesVersion,
|
|
111
|
+
ids: findingStates(body)
|
|
112
|
+
}
|
|
91
113
|
}
|
|
92
114
|
|
|
93
|
-
type Round = { judgedHead: string | null; ids: Map<string, string | null> }
|
|
115
|
+
export type Round = { judgedHead: string | null; objectivesVersion: string | null; ids: Map<string, string | null> }
|
|
94
116
|
|
|
95
117
|
/**
|
|
96
118
|
* One round per `Judged head:` value, in the order that head was first
|
|
97
119
|
* judged. A code-review verdict and a security verdict cast on the same head
|
|
98
120
|
* are one round, not two — which is why the grouping key is the judged head
|
|
99
121
|
* and not the comment count.
|
|
122
|
+
*
|
|
123
|
+
* Exported for `dev-review-loop/assess-round.ts` to reuse the same id-state merge semantics (first non-null state
|
|
124
|
+
* wins on a duplicate id) when it combines a round's reviewer and security
|
|
125
|
+
* `VerdictObservation`s into one id-state map — no behaviour change, no
|
|
126
|
+
* second copy of the merge rule.
|
|
100
127
|
*/
|
|
101
|
-
function groupRounds(verdicts: VerdictComment[]): Round[] {
|
|
128
|
+
export function groupRounds(verdicts: VerdictComment[]): Round[] {
|
|
102
129
|
const rounds: Round[] = []
|
|
103
130
|
for (const v of verdicts) {
|
|
104
131
|
const existing = rounds.find((r) => r.judgedHead === v.judgedHead)
|
|
105
|
-
const target = existing ?? {
|
|
132
|
+
const target = existing ?? {
|
|
133
|
+
judgedHead: v.judgedHead,
|
|
134
|
+
objectivesVersion: v.objectivesVersion,
|
|
135
|
+
ids: new Map<string, string | null>()
|
|
136
|
+
}
|
|
106
137
|
if (!existing) rounds.push(target)
|
|
107
138
|
for (const [id, state] of v.ids) {
|
|
108
139
|
if (!target.ids.has(id) || target.ids.get(id) === null) target.ids.set(id, state)
|
|
@@ -113,12 +144,13 @@ function groupRounds(verdicts: VerdictComment[]): Round[] {
|
|
|
113
144
|
|
|
114
145
|
/**
|
|
115
146
|
* `CONTINUE` means the loop is still converging; a `PAUSE` names the one
|
|
116
|
-
* reason it is not and the round that produced it. The
|
|
147
|
+
* reason it is not and the round that produced it. The five reasons are
|
|
117
148
|
* evaluated in the order they are declared on `ReviewStatus`, most specific
|
|
118
149
|
* first: a reappearance names an individual finding, zero-deaths names a
|
|
119
|
-
* round, staleness names the loop's own inactivity,
|
|
120
|
-
*
|
|
121
|
-
*
|
|
150
|
+
* round, staleness names the loop's own inactivity, objectives-moved names
|
|
151
|
+
* an edit to the objectives list since the newest verdict, and max-rounds is
|
|
152
|
+
* the count alone. The first that holds is reported — a paused loop needs
|
|
153
|
+
* one actionable reason, not a list.
|
|
122
154
|
*/
|
|
123
155
|
export function deriveReviewStatus(input: ReviewStatusInput): ReviewStatus {
|
|
124
156
|
const verdicts: VerdictComment[] = []
|
|
@@ -177,6 +209,18 @@ export function deriveReviewStatus(input: ReviewStatusInput): ReviewStatus {
|
|
|
177
209
|
return { state: 'PAUSE', reason: 'stale', round: rounds.length }
|
|
178
210
|
}
|
|
179
211
|
|
|
212
|
+
// objectives-moved — the head is unchanged (the `stale` check
|
|
213
|
+
// above already passed), but the objectives list the PR is judged against
|
|
214
|
+
// has moved since the newest verdict. `input.objectivesVersion === null`
|
|
215
|
+
// skips this entirely (the same fail-open-on-`null` rule `checkReviewGate`
|
|
216
|
+
// uses); `newest.objectivesVersion === null` (a verdict cast before the
|
|
217
|
+
// block existed at all, or with no version line) counts as "differs" too —
|
|
218
|
+
// it cannot be the current version by definition.
|
|
219
|
+
const currentObjectivesVersion = input.objectivesVersion ?? null
|
|
220
|
+
if (currentObjectivesVersion !== null && newest.objectivesVersion !== currentObjectivesVersion) {
|
|
221
|
+
return { state: 'PAUSE', reason: 'objectives-moved', round: rounds.length }
|
|
222
|
+
}
|
|
223
|
+
|
|
180
224
|
// max-rounds — the count alone. The loop may still be converging; it has
|
|
181
225
|
// simply run long enough that the Principal decides whether it continues.
|
|
182
226
|
if (rounds.length >= input.maxRounds) return { state: 'PAUSE', reason: 'max-rounds', round: rounds.length }
|
|
@@ -186,15 +230,18 @@ export function deriveReviewStatus(input: ReviewStatusInput): ReviewStatus {
|
|
|
186
230
|
|
|
187
231
|
/**
|
|
188
232
|
* The one-line rendering the CLI prints: `CONTINUE`, or `PAUSE: <reason>[ <id>]`
|
|
189
|
-
* — except `stale
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
233
|
+
* — except `stale` and `objectives-moved`, each rendered as the actionable
|
|
234
|
+
* fact it names rather than the bare reason word. `stale`'s condition (the
|
|
235
|
+
* newest verdict's judged head is no longer the PR's, and no Developer round
|
|
236
|
+
* comment has answered it since) is exactly "a commit landed after the
|
|
237
|
+
* newest verdict, unacknowledged": `push after verdict — re-review required`.
|
|
238
|
+
* `objectives-moved`'s condition is the same shape for the
|
|
239
|
+
* objectives list instead of the head: `objectives moved — re-review
|
|
240
|
+
* required`.
|
|
195
241
|
*/
|
|
196
242
|
export function renderReviewStatus(status: ReviewStatus): string {
|
|
197
243
|
if (status.state === 'CONTINUE') return 'CONTINUE'
|
|
198
244
|
if (status.reason === 'stale') return 'push after verdict — re-review required'
|
|
245
|
+
if (status.reason === 'objectives-moved') return 'objectives moved — re-review required'
|
|
199
246
|
return status.id !== undefined ? `PAUSE: ${status.reason} ${status.id}` : `PAUSE: ${status.reason}`
|
|
200
247
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The newest principal-authored ruling ordinal on a pull request.
|
|
3
|
+
* One implementation, shared by
|
|
4
|
+
* every caller that needs it — `apps/cli/src/lib/dev-review-loop.ts` (the
|
|
5
|
+
* loop's own `fetchRulings`, which this duplicates the marker regex for,
|
|
6
|
+
* predates this package's involvement and stays local; this is the
|
|
7
|
+
* NEW shared logic `check-review-gate.ts` and `review-post.ts` both need
|
|
8
|
+
* and had no prior copy of), so the marker's parsing never drifts between
|
|
9
|
+
* the gate and the hand-cast command the way `verdict-extraction.ts`'s own
|
|
10
|
+
* module comment warns a duplicated pattern eventually would.
|
|
11
|
+
*
|
|
12
|
+
* Pure — no `fs`, no `fetch`. Every caller resolves the PR's comments via
|
|
13
|
+
* `gh` itself and passes them in.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { isPrincipal } from './waiver-label'
|
|
17
|
+
|
|
18
|
+
/** The marker `apps/cli/src/commands/pr-rule.ts` posts: `<!-- aeg:principal:ruling:<pr>-<k> -->`, one line, nothing else on it. */
|
|
19
|
+
const RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/
|
|
20
|
+
|
|
21
|
+
export type RulingComment = {
|
|
22
|
+
body: string
|
|
23
|
+
/** The comment author's GitHub login, or `null` when the caller could not resolve one. */
|
|
24
|
+
author: string | null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* `0` when no principal-authored ruling comment matches — never `null`: a
|
|
29
|
+
* PR's ruling count is always a well-defined fact, unlike an objectives
|
|
30
|
+
* list that can be genuinely unresolvable pre-cutover. `k` is read from the
|
|
31
|
+
* marker's own `<pr>-<k>` and compared numerically, never by string/lexical
|
|
32
|
+
* order or by comment timestamp — the ruling command assigns `k` strictly
|
|
33
|
+
* increasing, so the highest `k` among principal-authored matches is always
|
|
34
|
+
* the newest ruling, regardless of the comments array's own order.
|
|
35
|
+
*/
|
|
36
|
+
export function newestPrincipalRulingOrdinal(comments: readonly RulingComment[], allowlist: readonly string[]): number {
|
|
37
|
+
let best = 0
|
|
38
|
+
for (const c of comments) {
|
|
39
|
+
if (!isPrincipal(c.author, allowlist as string[])) continue
|
|
40
|
+
const firstLine = (c.body.split('\n')[0] ?? '').trim()
|
|
41
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine)
|
|
42
|
+
if (!m) continue
|
|
43
|
+
const k = Number.parseInt(m[1] as string, 10)
|
|
44
|
+
if (k > best) best = k
|
|
45
|
+
}
|
|
46
|
+
return best
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The AUTHOR of the newest principal-authored ruling comment — `null` when
|
|
51
|
+
* none matches (`newestPrincipalRulingOrdinal` returning `0` for the
|
|
52
|
+
* identical reason). An authenticated resolution record's own need (O2): its
|
|
53
|
+
* `authenticatedBy` field names WHO
|
|
54
|
+
* authorized a `--resume`/`--cancel`, not just that an authorization
|
|
55
|
+
* existed. Same scan, same ordinal-wins rule, so the two functions can never
|
|
56
|
+
* disagree about which ruling is newest.
|
|
57
|
+
*/
|
|
58
|
+
export function newestPrincipalRulingAuthor(
|
|
59
|
+
comments: readonly RulingComment[],
|
|
60
|
+
allowlist: readonly string[]
|
|
61
|
+
): string | null {
|
|
62
|
+
let best = 0
|
|
63
|
+
let bestAuthor: string | null = null
|
|
64
|
+
for (const c of comments) {
|
|
65
|
+
if (!isPrincipal(c.author, allowlist as string[])) continue
|
|
66
|
+
const firstLine = (c.body.split('\n')[0] ?? '').trim()
|
|
67
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine)
|
|
68
|
+
if (!m) continue
|
|
69
|
+
const k = Number.parseInt(m[1] as string, 10)
|
|
70
|
+
if (k > best) {
|
|
71
|
+
best = k
|
|
72
|
+
bestAuthor = c.author
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return bestAuthor
|
|
76
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Single-plan-PR guard predicate
|
|
3
|
-
* `bin/open-pr.ts`
|
|
2
|
+
* Single-plan-PR guard predicate. Extracted from
|
|
3
|
+
* `bin/open-pr.ts` so the
|
|
4
4
|
* exact same implementation can be consumed by both the ring-0 local wrapper
|
|
5
5
|
* (`open-pr.ts`, prevention) and a ring-1 CI check (detection, for PRs opened
|
|
6
6
|
* via the web UI that bypass the wrapper entirely) — one implementation per
|
|
@@ -27,11 +27,11 @@ export function trancheSlugFromTopologyPath(path: string): string | null {
|
|
|
27
27
|
export type OpenPrFiles = { number: number; files: string[] }
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Single-plan-PR guard
|
|
30
|
+
* Single-plan-PR guard: refuses a plan-branch diff
|
|
31
31
|
* that touches a tranche's topology file when another OPEN PR's diff
|
|
32
32
|
* already touches that SAME tranche's topology file. Ends the plan-PR
|
|
33
33
|
* race that produced two concurrent plan PRs for `aeg-governance-hardening`
|
|
34
|
-
* itself
|
|
34
|
+
* itself — each cut from `origin/main` unaware of the other's
|
|
35
35
|
* newly-cut Issue.
|
|
36
36
|
*
|
|
37
37
|
* `branchFiles` is this branch's diff vs `origin/main` (or vs the PR's
|
|
@@ -20,9 +20,14 @@
|
|
|
20
20
|
* **Order is load-bearing, not incidental.** `blocked` must win over every
|
|
21
21
|
* other conclusion; the reopened-after-merge rules must precede the plain
|
|
22
22
|
* `merged` rule or a reopened Issue would permanently read `merged` off a
|
|
23
|
-
* stale fact
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* stale fact; the closed-Issue rules (`closed-not-planned`, `closed-without-
|
|
24
|
+
* merge`) must precede `branch-exists`/`issue-open` — neither of those two
|
|
25
|
+
* checks `issueState`, so a closed Issue whose task branch was never cleaned
|
|
26
|
+
* up used to be swallowed by `branch-exists` and read as permanently
|
|
27
|
+
* `in-flight` instead of `dropped`/`incoherent` (issue-545, O6). `deriveStatus`
|
|
28
|
+
* (`derive-tranche.ts`) executes this list verbatim, so reordering entries
|
|
29
|
+
* here changes real status everywhere — every gate, the Studio, and the CLI
|
|
30
|
+
* read their status through it.
|
|
26
31
|
*
|
|
27
32
|
* **Deliberately not imported here: the label vocabulary.** Derivation works
|
|
28
33
|
* on `ForgeFacts` — booleans and enums — never on label *strings*; the one
|
|
@@ -153,8 +158,12 @@ export type DerivationRule = {
|
|
|
153
158
|
}
|
|
154
159
|
|
|
155
160
|
/**
|
|
156
|
-
* The ordered chain. First match wins
|
|
157
|
-
*
|
|
161
|
+
* The ordered chain. First match wins. No single rule here is unconditional
|
|
162
|
+
* any more (issue-545, O6 narrowed `closed-without-merge`'s predicate to
|
|
163
|
+
* `issueState === 'closed'` so it could move ahead of `branch-exists`/
|
|
164
|
+
* `issue-open` without swallowing every open Issue too) — totality is
|
|
165
|
+
* guaranteed one level up, by `deriveStatusFromModel`'s own trailing
|
|
166
|
+
* fallback, not by a catch-all entry in this list.
|
|
158
167
|
*
|
|
159
168
|
* Every predicate is written to be safe against `undefined` facts even though
|
|
160
169
|
* only the first rule can observe that case — the guard is structural, so
|
|
@@ -218,36 +227,36 @@ export const DERIVATION_RULES: DerivationRule[] = [
|
|
|
218
227
|
why: 'Opening the PR is itself the in-flight → in-review transition; no status is ever written to record it.'
|
|
219
228
|
},
|
|
220
229
|
{
|
|
221
|
-
id: '
|
|
230
|
+
id: 'closed-not-planned',
|
|
231
|
+
chainStep: 6,
|
|
232
|
+
when: 'Issue closed NOT_PLANNED, with no merged PR',
|
|
233
|
+
matches: (facts) => facts?.issueState === 'closed' && facts.stateReason === 'not_planned',
|
|
234
|
+
status: 'dropped',
|
|
235
|
+
why: 'A legitimately abandoned task. Must precede branch-exists/issue-open (issue-545, O6): neither checks issueState, so a closed NOT_PLANNED Issue whose task branch was never cleaned up used to be swallowed by branch-exists and read as in-flight forever.'
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
id: 'closed-without-merge',
|
|
222
239
|
chainStep: 6,
|
|
240
|
+
when: 'Issue closed for any other reason, with no merged PR',
|
|
241
|
+
matches: (facts) => facts?.issueState === 'closed',
|
|
242
|
+
status: 'incoherent',
|
|
243
|
+
why: "The honest terminal case for a closed, unprovable Issue. Same ordering fix as closed-not-planned (issue-545, O6) and for the identical reason: must precede branch-exists/issue-open or a closed Issue with a lingering branch read as in-flight instead. No longer the list’s unconditional catch-all — `deriveStatusFromModel`’s own trailing fallback (below) is what keeps the function total now that this predicate is scoped to `issueState === 'closed'`."
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
id: 'branch-exists',
|
|
247
|
+
chainStep: 7,
|
|
223
248
|
when: 'A task branch exists, with no PR',
|
|
224
249
|
matches: (facts) => facts?.branchExists === true,
|
|
225
250
|
status: 'in-flight',
|
|
226
|
-
why:
|
|
251
|
+
why: "Publishing the branch is the todo → in-flight transition. Below the PR rules (a PR is the stronger signal) and below the closed-Issue rules (issue-545, O6) — every fact set reaching this rule already has issueState === 'open'."
|
|
227
252
|
},
|
|
228
253
|
{
|
|
229
254
|
id: 'issue-open',
|
|
230
|
-
chainStep:
|
|
255
|
+
chainStep: 8,
|
|
231
256
|
when: 'The Issue is open, with no branch and no PR',
|
|
232
257
|
matches: (facts) => facts?.issueState === 'open',
|
|
233
258
|
status: 'todo',
|
|
234
259
|
why: 'Not started. Assigned or not, both are todo inside a tranche.'
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
id: 'closed-not-planned',
|
|
238
|
-
chainStep: 8,
|
|
239
|
-
when: 'Issue closed NOT_PLANNED, with no merged PR',
|
|
240
|
-
matches: (facts) => facts?.stateReason === 'not_planned',
|
|
241
|
-
status: 'dropped',
|
|
242
|
-
why: 'A legitimately abandoned task. Reached only when the Issue is closed and nothing merged.'
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
id: 'closed-without-merge',
|
|
246
|
-
chainStep: 8,
|
|
247
|
-
when: 'Issue closed for any other reason, with no merged PR',
|
|
248
|
-
matches: () => true,
|
|
249
|
-
status: 'incoherent',
|
|
250
|
-
why: 'The honest terminal fallback: closed but unprovable must never read as todo. Total by design, so derivation always concludes.'
|
|
251
260
|
}
|
|
252
261
|
]
|
|
253
262
|
|
|
@@ -257,9 +266,13 @@ export const DERIVATION_RULES: DerivationRule[] = [
|
|
|
257
266
|
* rendered rules and the real derivation are the same list — the whole point
|
|
258
267
|
* of the discipline.
|
|
259
268
|
*
|
|
260
|
-
* The trailing return is
|
|
261
|
-
*
|
|
262
|
-
*
|
|
269
|
+
* The trailing `return 'incoherent'` is this function's own totality
|
|
270
|
+
* guarantee (issue-545, O6): no rule in `DERIVATION_RULES` is unconditional
|
|
271
|
+
* any more, so the type checker cannot see the list as exhaustive, and in
|
|
272
|
+
* practice every real `ForgeFacts` (`issueState` is always `'open'` or
|
|
273
|
+
* `'closed'`) is fully covered by the rules above it — this line exists for
|
|
274
|
+
* the type checker and as a defensive floor, not as the reachable case
|
|
275
|
+
* `state-machine-model.test.ts` used to assert of the last array entry.
|
|
263
276
|
*/
|
|
264
277
|
export function deriveStatusFromModel(facts: ForgeFacts | undefined): DerivedStatus {
|
|
265
278
|
for (const rule of DERIVATION_RULES) {
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* third neighbour, and all three declare an unexported `stripBackticks`. So
|
|
7
7
|
* "the registry's backtick stripper" names nothing a reader can resolve, and
|
|
8
8
|
* checking a claim about it by grepping returns a confident answer about
|
|
9
|
-
* whichever copy the search landed on. That happened twice
|
|
10
|
-
*
|
|
9
|
+
* whichever copy the search landed on. That happened twice in real practice:
|
|
10
|
+
* once in a verification pass that reached the right
|
|
11
11
|
* conclusion for the wrong reason, once in a filed Issue that sent a reader to
|
|
12
12
|
* the wrong file. `parse-registry.ts` was also binary to git at the time (see
|
|
13
13
|
* `no-binary-sources.test.ts`), so `git grep` could not have shown its copy.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task-branch identity. A developer branch names
|
|
3
|
+
* its task one of two ways: `task/<tranche>/<n>`, keyed to a tranche
|
|
4
|
+
* topology row, or `task/issue-<n>`, keyed directly to a backlog Issue that
|
|
5
|
+
* carries no tranche at all. This is the one parser for both shapes — every
|
|
6
|
+
* check that resolves a task's identity off its branch name (`closes-n`,
|
|
7
|
+
* `surface-scope`, `dispatch-readiness`) reads through this, rather than
|
|
8
|
+
* carrying its own two-segment regex.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately NOT the same export as `first-push-dispatch-gate.ts`'s
|
|
11
|
+
* `parseTaskBranch` — that function (and its flat `{tranche, taskId}` return
|
|
12
|
+
* shape) is shared by `first-push-dispatch`/`issue-assignment`/
|
|
13
|
+
* `assign-task-issue`, none of which are in this task's Surface or Boundary;
|
|
14
|
+
* widening its return type would ripple into checks this task has no brief
|
|
15
|
+
* coverage for. This module is the new, additional shape-parser named in the
|
|
16
|
+
* Traps to avoid: "`task/issue-<n>` is its own shape, parsed by one function
|
|
17
|
+
* next to `task/<tranche>/<n>`."
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export type TaskBranchIdentity =
|
|
21
|
+
| { readonly kind: 'tranche'; readonly tranche: string; readonly taskId: string }
|
|
22
|
+
| { readonly kind: 'issue'; readonly issueNumber: number }
|
|
23
|
+
|
|
24
|
+
const ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/
|
|
25
|
+
const TRANCHE_BRANCH_PATTERN = /^task\/([^/]+)\/([^/]+)$/
|
|
26
|
+
|
|
27
|
+
export function parseTaskBranchIdentity(branch: string): TaskBranchIdentity | null {
|
|
28
|
+
const issueMatch = ISSUE_BRANCH_PATTERN.exec(branch)
|
|
29
|
+
if (issueMatch) return { kind: 'issue', issueNumber: Number(issueMatch[1]) }
|
|
30
|
+
const trancheMatch = TRANCHE_BRANCH_PATTERN.exec(branch)
|
|
31
|
+
if (trancheMatch) return { kind: 'tranche', tranche: trancheMatch[1] as string, taskId: trancheMatch[2] as string }
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** `task/issue-<n>` — the branch shape for a backlog Issue with no tranche. */
|
|
36
|
+
export function issueBranchName(issueNumber: number): string {
|
|
37
|
+
return `task/issue-${issueNumber}`
|
|
38
|
+
}
|