@attalabs/vinaya 0.32.0 → 0.34.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/enforcement.md +1 -1
- package/aeg-root/glossary.md +4 -0
- package/aeg-root/roles/developer.md +3 -0
- package/aeg-root/roles/operator.md +89 -16
- package/aeg-root/roles/planner/reference.md +3 -2
- package/aeg-root/roles/planner.md +3 -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/brief-template.md +9 -7
- package/aeg-root/templates/pr-report-template.md +3 -1
- package/dist/checks/bin/check-body-bare-digits.js +213 -41
- package/dist/checks/bin/check-branch-topology.js +164 -41
- package/dist/checks/bin/check-brief-shape.js +219 -46
- package/dist/checks/bin/check-changeset-coverage.js +669 -152
- package/dist/checks/bin/check-closes-n.js +164 -41
- package/dist/checks/bin/check-coherence.js +220 -43
- package/dist/checks/bin/check-dead-branch-push.js +159 -40
- package/dist/checks/bin/check-dispatch-readiness.js +218 -42
- package/dist/checks/bin/check-doc-coverage-push.js +665 -148
- package/dist/checks/bin/check-doc-coverage.js +667 -150
- package/dist/checks/bin/check-doctrine-no-procedures.js +213 -41
- package/dist/checks/bin/check-doctrine-portability.js +666 -149
- package/dist/checks/bin/check-evidence-fresh.js +643 -125
- package/dist/checks/bin/check-exec-bits.js +663 -146
- package/dist/checks/bin/check-first-push-dispatch.js +218 -42
- package/dist/checks/bin/check-issue-assignment.js +164 -41
- package/dist/checks/bin/check-issue-milestone-attach.js +159 -40
- package/dist/checks/bin/check-issue-objectives-numbering.js +685 -41
- package/dist/checks/bin/check-issue-parts-coverage.js +159 -40
- package/dist/checks/bin/check-issue-surface-globs.js +258 -48
- package/dist/checks/bin/check-issue-title-grammar.js +159 -40
- package/dist/checks/bin/check-issue-tranche-label.js +159 -40
- package/dist/checks/bin/check-main-branch-refusal.js +159 -40
- package/dist/checks/bin/check-no-disk-state.js +159 -40
- package/dist/checks/bin/check-pr-premise-reassert.js +213 -41
- package/dist/checks/bin/check-pr-report-density.js +159 -40
- package/dist/checks/bin/check-principal-test-plan-wait.js +159 -40
- package/dist/checks/bin/check-quoted-command.js +586 -103
- package/dist/checks/bin/check-reader-resolvable-prose.js +637 -111
- package/dist/checks/bin/check-registry-gates.js +159 -40
- package/dist/checks/bin/check-retired-vocabulary.js +586 -103
- package/dist/checks/bin/check-review-gate.js +284 -152
- package/dist/checks/bin/check-single-plan-pr.js +159 -40
- package/dist/checks/bin/check-surface-scope.js +164 -41
- package/dist/checks/bin/check-test-plan.js +159 -40
- package/dist/checks/bin/check-token-collection-wired.js +159 -40
- package/dist/checks/bin/check-token-report.js +159 -40
- package/dist/checks/bin/check-workspace-escape.js +664 -147
- package/dist/index.js +3932 -1118
- package/dist/lib/pre-push-cache-test-run.js +507 -72
- package/dist/lib/pre-push-select-tests.js +136 -13
- 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 +222 -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 +30 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +219 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +97 -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 +425 -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 +254 -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 +208 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +80 -28
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +92 -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-phase-history.ts +194 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +712 -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 +368 -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]__0r7e54g._.js → [root-of-the-server]__07uhu5z._.js} +1 -1
- 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]__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/0ko698wh8xx2g.css +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 0q9p7c6vn-x2w.js} +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 2174nz5he_oc4.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3xnma0-359j17.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/0bm4nrrzwc7zi.css +0 -1
- 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/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → HmoeqXdX1E4drt7GReFOO}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → HmoeqXdX1E4drt7GReFOO}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → HmoeqXdX1E4drt7GReFOO}/_ssgManifest.js +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-doctrine-portability.ts
|
|
4
|
-
import { execFileSync as
|
|
5
|
-
import { readdirSync as
|
|
6
|
-
import { join as
|
|
4
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
5
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync2 } from "node:fs";
|
|
6
|
+
import { join as join10 } from "node:path";
|
|
7
7
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
8
8
|
var GATE_AUDIENCE = {
|
|
9
9
|
"check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
|
|
@@ -198,8 +198,8 @@ function maskIndentedCode(body, fill) {
|
|
|
198
198
|
var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
|
|
199
199
|
var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
|
|
200
200
|
var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
|
|
201
|
-
var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d
|
|
202
|
-
var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+
|
|
201
|
+
var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
|
|
202
|
+
var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
|
|
203
203
|
function splitSlugQualifiedEdge(edge) {
|
|
204
204
|
const m = edge.trim().match(SLUG_QUALIFIED_ID);
|
|
205
205
|
if (!m)
|
|
@@ -2047,12 +2047,24 @@ function extractBaseSha(comment) {
|
|
|
2047
2047
|
const m = firstThirteenLines(comment).match(BASE_SHA_PATTERN);
|
|
2048
2048
|
return m ? m[1].toLowerCase() : null;
|
|
2049
2049
|
}
|
|
2050
|
-
var
|
|
2050
|
+
var FINDING_DESCRIPTION_STATE = /^F(\d+)(?:\s+\S+)?(?:\s+(open|fix-claimed|reproduced|resolved))?:/;
|
|
2051
|
+
function parseFindingState(description) {
|
|
2052
|
+
const m = FINDING_DESCRIPTION_STATE.exec(description.trim());
|
|
2053
|
+
if (!m)
|
|
2054
|
+
return { id: null, state: null };
|
|
2055
|
+
return { id: `F${m[1]}`, state: m[2] ?? null };
|
|
2056
|
+
}
|
|
2057
|
+
var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—(?:\s+(.*))?$/gm;
|
|
2051
2058
|
function extractFindingSeverities(comment) {
|
|
2052
|
-
return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) =>
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2059
|
+
return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => {
|
|
2060
|
+
const { id, state } = parseFindingState(m[3] ?? "");
|
|
2061
|
+
return {
|
|
2062
|
+
severity: m[1],
|
|
2063
|
+
location: m[2],
|
|
2064
|
+
id,
|
|
2065
|
+
state
|
|
2066
|
+
};
|
|
2067
|
+
});
|
|
2056
2068
|
}
|
|
2057
2069
|
function extractVerdict(comments, valuePattern, missingLabel) {
|
|
2058
2070
|
const candidates = comments.filter((c) => valuePattern.test(c));
|
|
@@ -2466,6 +2478,12 @@ function evaluateReviewFindings(findings, scale, threshold) {
|
|
|
2466
2478
|
});
|
|
2467
2479
|
return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
|
|
2468
2480
|
}
|
|
2481
|
+
function isConsequentialFinding(finding) {
|
|
2482
|
+
return finding.state !== "resolved";
|
|
2483
|
+
}
|
|
2484
|
+
function consequentialFindings(findings) {
|
|
2485
|
+
return findings.filter((f) => isConsequentialFinding(f));
|
|
2486
|
+
}
|
|
2469
2487
|
function evaluateCodeReview(findings, policy) {
|
|
2470
2488
|
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
|
|
2471
2489
|
}
|
|
@@ -2602,7 +2620,7 @@ function isIssueNotFoundError(err) {
|
|
|
2602
2620
|
return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
|
|
2603
2621
|
}
|
|
2604
2622
|
function resolveObjectivesSource(prBody, issue, cutoverIssue) {
|
|
2605
|
-
if (issue !== null && issue < cutoverIssue)
|
|
2623
|
+
if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
|
|
2606
2624
|
return { kind: "none" };
|
|
2607
2625
|
if (issue !== null)
|
|
2608
2626
|
return { kind: "issue", issue };
|
|
@@ -2878,9 +2896,18 @@ var COMMIT_TYPES = [
|
|
|
2878
2896
|
];
|
|
2879
2897
|
var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
|
|
2880
2898
|
function checkForgeTitle(title) {
|
|
2881
|
-
const taskStyle = /^\[[a-z0-9._-]+\] \
|
|
2899
|
+
const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
|
|
2882
2900
|
if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
|
|
2883
2901
|
return { status: "pass", errors: [] };
|
|
2902
|
+
const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
|
|
2903
|
+
if (letteredTaskId) {
|
|
2904
|
+
return {
|
|
2905
|
+
status: "fail",
|
|
2906
|
+
errors: [
|
|
2907
|
+
`brief-validation title: "${title}" names task id \`${letteredTaskId[1]}\` — task ids are whole numbers (\`1\`, \`2\`), never lettered (\`2a\`). \`vinaya task run\` and \`task dispatch\` refuse a non-numeric id, so a plan titled this way names a task that cannot be started.`
|
|
2908
|
+
]
|
|
2909
|
+
};
|
|
2910
|
+
}
|
|
2884
2911
|
return {
|
|
2885
2912
|
status: "fail",
|
|
2886
2913
|
errors: [
|
|
@@ -2913,19 +2940,31 @@ function checkNoAgentBoxes(prBody) {
|
|
|
2913
2940
|
]
|
|
2914
2941
|
};
|
|
2915
2942
|
}
|
|
2916
|
-
function
|
|
2943
|
+
function rolloutRuleFor(message) {
|
|
2917
2944
|
if (message.startsWith("brief-validation unpinned code claim:") || message.startsWith("brief-validation commands carry output:") || message.startsWith("brief-validation consumer tests:") || message.startsWith("brief-validation defeat cases:")) {
|
|
2918
|
-
return
|
|
2945
|
+
return "briefRules";
|
|
2919
2946
|
}
|
|
2920
2947
|
if (message.startsWith("brief-validation no agent boxes:"))
|
|
2921
|
-
return
|
|
2948
|
+
return "agentBoxes";
|
|
2922
2949
|
return null;
|
|
2923
2950
|
}
|
|
2924
|
-
|
|
2951
|
+
var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
|
|
2952
|
+
briefRulesSincePr: BRIEF_RULES_SINCE_PR,
|
|
2953
|
+
agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
|
|
2954
|
+
};
|
|
2955
|
+
function rolloutThresholdFor(message, cutovers) {
|
|
2956
|
+
const rule = rolloutRuleFor(message);
|
|
2957
|
+
if (rule === "briefRules")
|
|
2958
|
+
return cutovers.briefRulesSincePr;
|
|
2959
|
+
if (rule === "agentBoxes")
|
|
2960
|
+
return cutovers.agentBoxesRefusedSincePr;
|
|
2961
|
+
return null;
|
|
2962
|
+
}
|
|
2963
|
+
function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
|
|
2925
2964
|
const blocking = [];
|
|
2926
2965
|
const info = [];
|
|
2927
2966
|
for (const e of errors) {
|
|
2928
|
-
const threshold = rolloutThresholdFor(e);
|
|
2967
|
+
const threshold = rolloutThresholdFor(e, cutovers);
|
|
2929
2968
|
const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
|
|
2930
2969
|
(grandfathered ? info : blocking).push(e);
|
|
2931
2970
|
}
|
|
@@ -3393,8 +3432,8 @@ function checkIssueRationale(body) {
|
|
|
3393
3432
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3394
3433
|
}
|
|
3395
3434
|
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3396
|
-
function checkIssueObjectives(body, issueNumber) {
|
|
3397
|
-
if (issueNumber !== null && issueNumber <
|
|
3435
|
+
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3436
|
+
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3398
3437
|
return { status: "pass", errors: [] };
|
|
3399
3438
|
const result = objectivesOf(body);
|
|
3400
3439
|
if (result.ok)
|
|
@@ -3839,7 +3878,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
|
|
|
3839
3878
|
return issueToEntry.get(Number(issueMatch[1]));
|
|
3840
3879
|
return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
|
|
3841
3880
|
}
|
|
3842
|
-
function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
|
|
3881
|
+
function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
|
|
3843
3882
|
const failures = [];
|
|
3844
3883
|
for (const [slug, issues] of issuesBySlug) {
|
|
3845
3884
|
for (const issue of issues) {
|
|
@@ -3848,7 +3887,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
|
|
|
3848
3887
|
const errors = [
|
|
3849
3888
|
...checkIssueRationale(issue.body).errors,
|
|
3850
3889
|
...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
|
|
3851
|
-
...checkIssueObjectives(issue.body, issue.number).errors,
|
|
3890
|
+
...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
|
|
3852
3891
|
...checkPartsCiteDefinedObjectives(issue.body).errors
|
|
3853
3892
|
];
|
|
3854
3893
|
if (errors.length === 0)
|
|
@@ -4098,8 +4137,8 @@ function checkReviewGate(input) {
|
|
|
4098
4137
|
let codeReviewPolicyEvaluation;
|
|
4099
4138
|
let securityPolicyEvaluation;
|
|
4100
4139
|
try {
|
|
4101
|
-
codeReviewPolicyEvaluation = evaluateCodeReview(codeReview.findingSeverities, policy);
|
|
4102
|
-
securityPolicyEvaluation = evaluateSecurityReview(security.findingSeverities, policy);
|
|
4140
|
+
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
|
|
4141
|
+
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
|
|
4103
4142
|
} catch (err) {
|
|
4104
4143
|
return {
|
|
4105
4144
|
verdict: "fail",
|
|
@@ -4471,13 +4510,27 @@ var SHIPS_PREFIX = "aeg-root/";
|
|
|
4471
4510
|
function shipsArchivePrefix(shipsPrefix) {
|
|
4472
4511
|
return `${shipsPrefix}tranches/completed/`;
|
|
4473
4512
|
}
|
|
4474
|
-
|
|
4475
|
-
|
|
4513
|
+
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
4514
|
+
function normalizeSpecPath(entry) {
|
|
4515
|
+
let out = entry.replace(/\\/g, "/");
|
|
4516
|
+
while (out.startsWith("./"))
|
|
4517
|
+
out = out.slice(2);
|
|
4518
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
4519
|
+
while (out.endsWith("/"))
|
|
4520
|
+
out = out.slice(0, -1);
|
|
4521
|
+
return out;
|
|
4522
|
+
}
|
|
4523
|
+
function isSpecFile2(path, specPaths) {
|
|
4524
|
+
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
4525
|
+
return true;
|
|
4526
|
+
if (!path.endsWith(".md"))
|
|
4527
|
+
return false;
|
|
4528
|
+
return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
|
|
4476
4529
|
}
|
|
4477
4530
|
function isClaudeMdFile(path) {
|
|
4478
4531
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
4479
4532
|
}
|
|
4480
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4533
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4481
4534
|
if (path.startsWith(shipsPrefix)) {
|
|
4482
4535
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
4483
4536
|
}
|
|
@@ -4486,7 +4539,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
4486
4539
|
}
|
|
4487
4540
|
if (isClaudeMdFile(path))
|
|
4488
4541
|
return "internal";
|
|
4489
|
-
if (isSpecFile2(path))
|
|
4542
|
+
if (isSpecFile2(path, specPaths))
|
|
4490
4543
|
return "spec";
|
|
4491
4544
|
if (isProductScopeFile(path))
|
|
4492
4545
|
return "product";
|
|
@@ -4515,13 +4568,14 @@ function lineAt(content, index) {
|
|
|
4515
4568
|
}
|
|
4516
4569
|
var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
|
|
4517
4570
|
var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
|
|
4571
|
+
var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
|
|
4518
4572
|
function legacySlugPattern(legacySlugs) {
|
|
4519
4573
|
if (legacySlugs.length === 0)
|
|
4520
4574
|
return null;
|
|
4521
4575
|
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
4522
4576
|
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
4523
4577
|
}
|
|
4524
|
-
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
|
|
4578
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4525
4579
|
const findings = [];
|
|
4526
4580
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
4527
4581
|
const grandfathered = new Set(specGrandfather);
|
|
@@ -4533,8 +4587,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
|
|
|
4533
4587
|
const productPatterns = [
|
|
4534
4588
|
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
4535
4589
|
];
|
|
4590
|
+
const specPatterns = [
|
|
4591
|
+
...patterns,
|
|
4592
|
+
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
4593
|
+
];
|
|
4536
4594
|
for (const file of files) {
|
|
4537
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
4595
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
4538
4596
|
if (!cls || cls === "internal")
|
|
4539
4597
|
continue;
|
|
4540
4598
|
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
@@ -4543,15 +4601,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
|
|
|
4543
4601
|
continue;
|
|
4544
4602
|
const blocking = cls === "product" || cls === "spec";
|
|
4545
4603
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
4546
|
-
const patternsToRun = cls === "product" ? productPatterns : patterns;
|
|
4604
|
+
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
4547
4605
|
for (const { pattern, what, group } of patternsToRun) {
|
|
4548
4606
|
pattern.lastIndex = 0;
|
|
4549
4607
|
let match = pattern.exec(scrubbed);
|
|
4550
4608
|
while (match !== null) {
|
|
4551
4609
|
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4610
|
+
const citedIndex = match.index + match[0].indexOf(cited);
|
|
4552
4611
|
findings.push({
|
|
4553
4612
|
file: file.path,
|
|
4554
|
-
line: lineAt(scrubbed,
|
|
4613
|
+
line: lineAt(scrubbed, citedIndex),
|
|
4555
4614
|
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4556
4615
|
blocking
|
|
4557
4616
|
});
|
|
@@ -4737,9 +4796,9 @@ function checkSourceComments(files, allowlist = []) {
|
|
|
4737
4796
|
}
|
|
4738
4797
|
return findings;
|
|
4739
4798
|
}
|
|
4740
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
|
|
4799
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4741
4800
|
return [
|
|
4742
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
|
|
4801
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
4743
4802
|
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4744
4803
|
];
|
|
4745
4804
|
}
|
|
@@ -5180,15 +5239,32 @@ var ObservedSchema = z.object({
|
|
|
5180
5239
|
var TaskStatusInputSchema = z.object({
|
|
5181
5240
|
task: TaskToolRefSchema.optional()
|
|
5182
5241
|
}).merge(PageRequestSchema).strict();
|
|
5242
|
+
var TaskConfidenceSchema = z.object({
|
|
5243
|
+
round: z.number().int().positive(),
|
|
5244
|
+
percent: z.number().int().min(0).max(100).nullable(),
|
|
5245
|
+
source: z.enum(["stated", "published-summary"])
|
|
5246
|
+
}).strict();
|
|
5247
|
+
var TaskPhaseHistorySchema = z.object({
|
|
5248
|
+
typicalPhaseMinutes: z.number().nonnegative(),
|
|
5249
|
+
typicalPhaseSamples: z.number().int().positive()
|
|
5250
|
+
}).strict();
|
|
5183
5251
|
var TaskStatusItemSchema = z.object({
|
|
5184
5252
|
task: TaskToolRefSchema,
|
|
5185
5253
|
issue: z.number().int().positive(),
|
|
5186
5254
|
pr: z.number().int().positive().nullable(),
|
|
5187
|
-
state: z.string()
|
|
5255
|
+
state: z.string(),
|
|
5256
|
+
round: z.number().int().positive().nullable().optional(),
|
|
5257
|
+
phase: z.string().min(1).nullable().optional(),
|
|
5258
|
+
minutesInPhase: z.number().nonnegative().nullable().optional(),
|
|
5259
|
+
phaseIsCurrent: z.boolean().nullable().optional(),
|
|
5260
|
+
lastConfidence: TaskConfidenceSchema.nullable().optional(),
|
|
5261
|
+
lastConfidenceUnread: z.boolean().optional(),
|
|
5262
|
+
phaseHistory: TaskPhaseHistorySchema.nullable().optional()
|
|
5188
5263
|
}).merge(ObservedSchema);
|
|
5189
5264
|
var TaskStatusResultSchema = z.object({
|
|
5190
5265
|
items: z.array(TaskStatusItemSchema),
|
|
5191
|
-
nextCursor: z.string().nullable()
|
|
5266
|
+
nextCursor: z.string().nullable(),
|
|
5267
|
+
table: z.string()
|
|
5192
5268
|
});
|
|
5193
5269
|
var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
|
|
5194
5270
|
var EscalationInputsSchema = z.object({
|
|
@@ -5196,7 +5272,7 @@ var EscalationInputsSchema = z.object({
|
|
|
5196
5272
|
round: z.number().int().nonnegative(),
|
|
5197
5273
|
head: z.string(),
|
|
5198
5274
|
branch: z.string(),
|
|
5199
|
-
prNumber: z.number().int().positive()
|
|
5275
|
+
prNumber: z.number().int().positive().nullable()
|
|
5200
5276
|
});
|
|
5201
5277
|
var EscalationEvidenceSchema = z.object({
|
|
5202
5278
|
round: z.number().int().nonnegative(),
|
|
@@ -5232,13 +5308,45 @@ var TaskEscalationReadResultSchema = z.object({
|
|
|
5232
5308
|
items: z.array(TaskEscalationPacketSchema),
|
|
5233
5309
|
nextCursor: z.string().nullable()
|
|
5234
5310
|
}).merge(ObservedSchema);
|
|
5235
|
-
var
|
|
5236
|
-
|
|
5237
|
-
|
|
5311
|
+
var TaskPrCheckSchema = z.object({
|
|
5312
|
+
name: z.string(),
|
|
5313
|
+
required: z.boolean(),
|
|
5314
|
+
status: z.string(),
|
|
5315
|
+
conclusion: z.string().nullable(),
|
|
5316
|
+
detailsUrl: z.string().nullable(),
|
|
5317
|
+
failureSummary: z.string().nullable()
|
|
5318
|
+
});
|
|
5319
|
+
var TaskPrVerdictSchema = z.object({
|
|
5320
|
+
role: z.enum(["code-review", "security"]),
|
|
5321
|
+
value: z.string(),
|
|
5322
|
+
judgedHead: z.string().nullable(),
|
|
5323
|
+
objectivesVersion: z.string().nullable()
|
|
5324
|
+
});
|
|
5325
|
+
var TaskPrPauseSchema = z.object({
|
|
5326
|
+
reason: z.string(),
|
|
5327
|
+
body: z.string()
|
|
5328
|
+
});
|
|
5329
|
+
var TaskPrReviewRecordSchema = z.object({
|
|
5330
|
+
verdicts: z.array(TaskPrVerdictSchema),
|
|
5331
|
+
roundMarkers: z.array(z.number().int().nonnegative()),
|
|
5332
|
+
summaryTable: z.string().nullable(),
|
|
5333
|
+
pause: TaskPrPauseSchema.nullable()
|
|
5334
|
+
});
|
|
5335
|
+
var TaskPrReadInputSchema = z.object({
|
|
5336
|
+
task: TaskToolRefSchema,
|
|
5337
|
+
pr: z.number().int().positive().optional()
|
|
5238
5338
|
}).strict();
|
|
5339
|
+
var TaskPrReadResultSchema = z.object({
|
|
5340
|
+
task: TaskToolRefSchema,
|
|
5341
|
+
issue: z.number().int().positive(),
|
|
5342
|
+
pr: z.number().int().positive(),
|
|
5343
|
+
head: z.string().nullable(),
|
|
5344
|
+
checks: z.array(TaskPrCheckSchema),
|
|
5345
|
+
review: TaskPrReviewRecordSchema
|
|
5346
|
+
}).merge(ObservedSchema);
|
|
5239
5347
|
var TaskStartResultSchema = z.object({
|
|
5240
5348
|
requestId: z.string().min(1),
|
|
5241
|
-
run:
|
|
5349
|
+
run: TaskToolRefSchema,
|
|
5242
5350
|
started: z.boolean(),
|
|
5243
5351
|
startedAt: z.string(),
|
|
5244
5352
|
mode: z.literal("attended")
|
|
@@ -5252,7 +5360,7 @@ var TaskCancelInputSchema = z.object({
|
|
|
5252
5360
|
}).strict();
|
|
5253
5361
|
var TaskResumeResultSchema = z.object({
|
|
5254
5362
|
task: z.number().int().positive(),
|
|
5255
|
-
pr: z.number().int().positive(),
|
|
5363
|
+
pr: z.number().int().positive().nullable(),
|
|
5256
5364
|
escalationId: z.string().min(1),
|
|
5257
5365
|
outcome: z.enum(["started", "already_resumed"]),
|
|
5258
5366
|
authenticatedBy: z.string().min(1),
|
|
@@ -5261,7 +5369,7 @@ var TaskResumeResultSchema = z.object({
|
|
|
5261
5369
|
var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
|
|
5262
5370
|
var TaskCancelResultSchema = z.object({
|
|
5263
5371
|
task: z.number().int().positive(),
|
|
5264
|
-
pr: z.number().int().positive(),
|
|
5372
|
+
pr: z.number().int().positive().nullable(),
|
|
5265
5373
|
escalationId: z.string().min(1),
|
|
5266
5374
|
outcome: TaskCancelOutcomeSchema,
|
|
5267
5375
|
authenticatedBy: z.string().min(1),
|
|
@@ -5272,6 +5380,7 @@ var TASK_TOOL_NAMES = [
|
|
|
5272
5380
|
"task_start",
|
|
5273
5381
|
"task_status",
|
|
5274
5382
|
"task_escalation_read",
|
|
5383
|
+
"task_pr_read",
|
|
5275
5384
|
"task_resume",
|
|
5276
5385
|
"task_cancel"
|
|
5277
5386
|
];
|
|
@@ -5499,6 +5608,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
|
|
|
5499
5608
|
}
|
|
5500
5609
|
return findings;
|
|
5501
5610
|
}
|
|
5611
|
+
// ../../packages/aeg-core/src/gate-cutovers.ts
|
|
5612
|
+
var NO_GATE_CUTOVERS = {
|
|
5613
|
+
objectivesSinceIssue: null,
|
|
5614
|
+
briefSectionsSinceIssue: null,
|
|
5615
|
+
documentationSinceIssue: null,
|
|
5616
|
+
briefRulesSincePr: null,
|
|
5617
|
+
agentBoxesRefusedSincePr: null
|
|
5618
|
+
};
|
|
5502
5619
|
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5503
5620
|
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5504
5621
|
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
@@ -5948,6 +6065,8 @@ function attemptFromEnv(value) {
|
|
|
5948
6065
|
function provenanceFor(input) {
|
|
5949
6066
|
if (input.provenance)
|
|
5950
6067
|
return input.provenance;
|
|
6068
|
+
if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
|
|
6069
|
+
return "unavailable";
|
|
5951
6070
|
if (input.env.role || input.env.task)
|
|
5952
6071
|
return "env_correlated";
|
|
5953
6072
|
return "unavailable";
|
|
@@ -5968,7 +6087,7 @@ function buildHeader(input) {
|
|
|
5968
6087
|
const role = isRole(input.env.role) ? input.env.role : "unattributed";
|
|
5969
6088
|
const round = roundFromEnv(input.env.round);
|
|
5970
6089
|
const subject = {
|
|
5971
|
-
issue: issueFromTask(input.env.task),
|
|
6090
|
+
issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
|
|
5972
6091
|
role,
|
|
5973
6092
|
...round !== undefined ? { round } : {},
|
|
5974
6093
|
...input.subject ?? {}
|
|
@@ -6408,7 +6527,12 @@ var VinayaConfigSchema = z4.object({
|
|
|
6408
6527
|
allowlist: z4.array(z4.string().min(1)).optional(),
|
|
6409
6528
|
severity: z4.enum(["warning", "error"]).optional()
|
|
6410
6529
|
}).optional(),
|
|
6411
|
-
specGrandfather: z4.array(z4.string().min(1)).optional()
|
|
6530
|
+
specGrandfather: z4.array(z4.string().min(1)).optional(),
|
|
6531
|
+
specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
|
|
6532
|
+
message: "must be a repository-relative path, not an absolute one"
|
|
6533
|
+
}).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
|
|
6534
|
+
message: "must stay inside the repository — no `..` segment"
|
|
6535
|
+
})).optional()
|
|
6412
6536
|
}).optional(),
|
|
6413
6537
|
projects: z4.array(ProjectEntrySchema).optional(),
|
|
6414
6538
|
dispatch: z4.object({
|
|
@@ -6422,6 +6546,13 @@ var VinayaConfigSchema = z4.object({
|
|
|
6422
6546
|
securityThreshold: z4.string().min(1).optional(),
|
|
6423
6547
|
maxRounds: z4.number().optional()
|
|
6424
6548
|
}).optional(),
|
|
6549
|
+
gateCutovers: z4.object({
|
|
6550
|
+
objectivesSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6551
|
+
briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6552
|
+
documentationSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6553
|
+
briefRulesSincePr: z4.number().int().nonnegative().optional(),
|
|
6554
|
+
agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
|
|
6555
|
+
}).optional(),
|
|
6425
6556
|
prePush: z4.object({
|
|
6426
6557
|
alwaysRun: z4.array(z4.string()).optional()
|
|
6427
6558
|
}).optional(),
|
|
@@ -6559,6 +6690,18 @@ function resolveReviewPolicy(config) {
|
|
|
6559
6690
|
maxRounds
|
|
6560
6691
|
};
|
|
6561
6692
|
}
|
|
6693
|
+
function resolveGateCutovers(config) {
|
|
6694
|
+
const raw = config?.gateCutovers;
|
|
6695
|
+
if (!raw)
|
|
6696
|
+
return NO_GATE_CUTOVERS;
|
|
6697
|
+
return {
|
|
6698
|
+
objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
|
|
6699
|
+
briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
|
|
6700
|
+
documentationSinceIssue: raw.documentationSinceIssue ?? null,
|
|
6701
|
+
briefRulesSincePr: raw.briefRulesSincePr ?? null,
|
|
6702
|
+
agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
|
|
6703
|
+
};
|
|
6704
|
+
}
|
|
6562
6705
|
function resolveRuntimeDirSetting(config) {
|
|
6563
6706
|
return config?.runtimeDir ?? null;
|
|
6564
6707
|
}
|
|
@@ -6633,7 +6776,28 @@ function trustAnchorRepoFromRemoteUrl(url) {
|
|
|
6633
6776
|
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
6634
6777
|
}
|
|
6635
6778
|
var execFileAsync4 = promisify4(execFile4);
|
|
6779
|
+
function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
6780
|
+
const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
|
|
6781
|
+
if (!ref)
|
|
6782
|
+
return null;
|
|
6783
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
6784
|
+
return null;
|
|
6785
|
+
if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
|
|
6786
|
+
return null;
|
|
6787
|
+
return ref;
|
|
6788
|
+
}
|
|
6789
|
+
function readTrustAnchorConfigAtRef(ref) {
|
|
6790
|
+
const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6791
|
+
encoding: "utf-8",
|
|
6792
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
6793
|
+
timeout: 1e4
|
|
6794
|
+
});
|
|
6795
|
+
return Buffer.from(raw, "utf-8").toString("base64");
|
|
6796
|
+
}
|
|
6636
6797
|
function ghFetchTrustAnchorConfig() {
|
|
6798
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6799
|
+
if (probeRef)
|
|
6800
|
+
return readTrustAnchorConfigAtRef(probeRef);
|
|
6637
6801
|
const repo = trustAnchorRepo();
|
|
6638
6802
|
if (!repo)
|
|
6639
6803
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
@@ -6643,6 +6807,14 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6643
6807
|
});
|
|
6644
6808
|
}
|
|
6645
6809
|
async function ghFetchTrustAnchorConfigAsync() {
|
|
6810
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6811
|
+
if (probeRef) {
|
|
6812
|
+
const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6813
|
+
encoding: "utf-8",
|
|
6814
|
+
timeout: 1e4
|
|
6815
|
+
});
|
|
6816
|
+
return Buffer.from(stdout, "utf-8").toString("base64");
|
|
6817
|
+
}
|
|
6646
6818
|
const repo = await trustAnchorRepoAsync();
|
|
6647
6819
|
if (!repo)
|
|
6648
6820
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
@@ -6720,13 +6892,13 @@ function loadConfig() {
|
|
|
6720
6892
|
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
6721
6893
|
|
|
6722
6894
|
// src/lib/diff-evidence.ts
|
|
6723
|
-
import { execFileSync as
|
|
6724
|
-
import { join as
|
|
6895
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
6896
|
+
import { join as join9, relative, resolve as resolve2 } from "node:path";
|
|
6725
6897
|
|
|
6726
6898
|
// src/lib/brief-assembly.ts
|
|
6727
|
-
import { execFileSync as
|
|
6728
|
-
import { existsSync as
|
|
6729
|
-
import { join as
|
|
6899
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
6900
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
|
|
6901
|
+
import { join as join4 } from "node:path";
|
|
6730
6902
|
|
|
6731
6903
|
// ../../packages/sources/src/commands.ts
|
|
6732
6904
|
var COMMANDS = [
|
|
@@ -6921,7 +7093,7 @@ var COMMANDS = [
|
|
|
6921
7093
|
details: [
|
|
6922
7094
|
"Exposes the task-operator tool catalog (`packages/aeg-core/src/task-tools.ts`) to an agent runtime as one MCP server speaking newline-delimited JSON-RPC 2.0 (`initialize`/`tools/list`/`tools/call`). Claude registers it through the generated `.mcp.json`; Codex through its documented `~/.codex/config.toml` `[mcp_servers]` table — both point at this same command.",
|
|
6923
7095
|
"stdout carries JSON-RPC and nothing else: any stray write from the CLI (a forge-read warning) is redirected to stderr, so the protocol stream is never corrupted.",
|
|
6924
|
-
"`task_status`/`task_escalation_read` read; `task_start` starts a run in attended mode only, requiring an authenticated caller from the invocation context (`VINAYA_MCP_CALLER`) and refusing without one — MCP is a transport, not authorization. `task_resume`/`task_cancel` require the same authenticated caller, plus a current Principal ruling read fresh from the run's own PR — never a caller-supplied approval; `task_resume` triggers the existing `dev-review-loop --resume` continuation exactly once per escalation, and `task_cancel` reports a truthful `confirmed`/`pending`/`uncertain` outcome, idempotently, across repeated calls. No unattended start until the worker-isolation boundary and a capability flag land."
|
|
7096
|
+
"`task_status`/`task_escalation_read`/`task_pr_read` read; `task_pr_read` returns the selected task's OWN pull request — every required and reported check with its state, conclusion and failure summary, plus the principal-authored review record (newest verdicts and their judged head, round markers, published summary table, pause comment) — and refuses any other pull request; `task_start` starts a run in attended mode only, requiring an authenticated caller from the invocation context (`VINAYA_MCP_CALLER`) and refusing without one — MCP is a transport, not authorization. `task_resume`/`task_cancel` require the same authenticated caller, plus a current Principal ruling read fresh from the run's own PR — never a caller-supplied approval; `task_resume` triggers the existing `dev-review-loop --resume` continuation exactly once per escalation, and `task_cancel` reports a truthful `confirmed`/`pending`/`uncertain` outcome, idempotently, across repeated calls. No unattended start until the worker-isolation boundary and a capability flag land."
|
|
6925
7097
|
],
|
|
6926
7098
|
status: "shipped"
|
|
6927
7099
|
},
|
|
@@ -7232,6 +7404,10 @@ var COMMANDS = [
|
|
|
7232
7404
|
flag: "--role <name>",
|
|
7233
7405
|
description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
|
|
7234
7406
|
},
|
|
7407
|
+
{
|
|
7408
|
+
flag: "--template <name>",
|
|
7409
|
+
description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
|
|
7410
|
+
},
|
|
7235
7411
|
{
|
|
7236
7412
|
flag: "--print",
|
|
7237
7413
|
description: "Emit the resolved file's body (frontmatter stripped) instead of its path — the one-hop mode every generated skill and slash command invokes. A role file whose frontmatter carries an `ack-token` emits that token as the output's own first line."
|
|
@@ -7567,13 +7743,47 @@ function packageRoot(moduleUrl) {
|
|
|
7567
7743
|
return dir;
|
|
7568
7744
|
}
|
|
7569
7745
|
|
|
7746
|
+
// src/commands/doctrine.ts
|
|
7747
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
7748
|
+
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
7749
|
+
import { dirname as dirname3, join as join3, sep } from "node:path";
|
|
7750
|
+
import matter2 from "gray-matter";
|
|
7751
|
+
var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
|
|
7752
|
+
function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
7753
|
+
return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
|
|
7754
|
+
}
|
|
7755
|
+
function gitToplevel(cwd) {
|
|
7756
|
+
try {
|
|
7757
|
+
return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
7758
|
+
encoding: "utf8",
|
|
7759
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
7760
|
+
}).trim();
|
|
7761
|
+
} catch {
|
|
7762
|
+
return null;
|
|
7763
|
+
}
|
|
7764
|
+
}
|
|
7765
|
+
function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
7766
|
+
const toplevel = gitToplevel(cwd);
|
|
7767
|
+
if (toplevel !== null) {
|
|
7768
|
+
const treeRoot = join3(toplevel, "aeg-root");
|
|
7769
|
+
if (existsSync3(join3(treeRoot, "roles")))
|
|
7770
|
+
return { root: treeRoot, source: "tree" };
|
|
7771
|
+
}
|
|
7772
|
+
const fromSource = !pkg.split(sep).includes("node_modules");
|
|
7773
|
+
const bundleRoot = fromSource ? join3(dirname3(dirname3(pkg)), "aeg-root") : join3(pkg, "aeg-root");
|
|
7774
|
+
return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
|
|
7775
|
+
}
|
|
7776
|
+
function hasDoctrineEntry(root) {
|
|
7777
|
+
return existsSync3(join3(root, ...ENTRY_SEGMENTS));
|
|
7778
|
+
}
|
|
7779
|
+
|
|
7570
7780
|
// src/lib/brief-assembly.ts
|
|
7571
7781
|
var PACKAGE_ROOT = packageRoot(import.meta.url);
|
|
7572
|
-
var PACKAGED_TEMPLATE_PATH =
|
|
7573
|
-
var TEMPLATE_PATH =
|
|
7782
|
+
var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
|
|
7783
|
+
var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
7574
7784
|
function git(args) {
|
|
7575
7785
|
try {
|
|
7576
|
-
return
|
|
7786
|
+
return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7577
7787
|
} catch {
|
|
7578
7788
|
return "";
|
|
7579
7789
|
}
|
|
@@ -7586,14 +7796,14 @@ function expandGlob(glob) {
|
|
|
7586
7796
|
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
7587
7797
|
|
|
7588
7798
|
// src/checks/registry.ts
|
|
7589
|
-
import { existsSync as
|
|
7590
|
-
import { join as
|
|
7591
|
-
var DIST_BIN_DIR =
|
|
7592
|
-
var SRC_BIN_DIR =
|
|
7593
|
-
var BIN_DIR =
|
|
7799
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
7800
|
+
import { join as join5 } from "node:path";
|
|
7801
|
+
var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
|
|
7802
|
+
var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
|
|
7803
|
+
var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
|
|
7594
7804
|
var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
|
|
7595
7805
|
function bin(name) {
|
|
7596
|
-
return
|
|
7806
|
+
return join5(BIN_DIR, `${name}${BIN_EXT}`);
|
|
7597
7807
|
}
|
|
7598
7808
|
var REGISTRY = [
|
|
7599
7809
|
[
|
|
@@ -8157,21 +8367,21 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
8157
8367
|
import {
|
|
8158
8368
|
closeSync as closeSync3,
|
|
8159
8369
|
constants as fsConstants3,
|
|
8160
|
-
existsSync as
|
|
8370
|
+
existsSync as existsSync7,
|
|
8161
8371
|
fstatSync as fstatSync2,
|
|
8162
8372
|
mkdirSync as mkdirSync3,
|
|
8163
8373
|
openSync as openSync3,
|
|
8164
|
-
readFileSync as
|
|
8374
|
+
readFileSync as readFileSync6,
|
|
8165
8375
|
renameSync as renameSync2,
|
|
8166
8376
|
writeSync as writeSync2
|
|
8167
8377
|
} from "node:fs";
|
|
8168
8378
|
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
8169
|
-
import { dirname as
|
|
8379
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
8170
8380
|
import { promisify as promisify5 } from "node:util";
|
|
8171
8381
|
|
|
8172
8382
|
// src/lib/run-paths.ts
|
|
8173
|
-
import { chmodSync, existsSync as
|
|
8174
|
-
import { dirname as
|
|
8383
|
+
import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
|
|
8384
|
+
import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
|
|
8175
8385
|
var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8176
8386
|
function isSafeRepoSegment(segment) {
|
|
8177
8387
|
return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
|
|
@@ -8182,7 +8392,7 @@ function repoSegment(repo) {
|
|
|
8182
8392
|
return `${repo.owner}-${repo.repo}`;
|
|
8183
8393
|
}
|
|
8184
8394
|
function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
|
|
8185
|
-
return
|
|
8395
|
+
return join6(home, "runtime", repoSegment(repo));
|
|
8186
8396
|
}
|
|
8187
8397
|
function resolveRuntimeDir(input) {
|
|
8188
8398
|
const local = resolveRuntimeDirSetting(input.localConfig);
|
|
@@ -8242,9 +8452,9 @@ function repoRootSync(start = process.cwd()) {
|
|
|
8242
8452
|
return null;
|
|
8243
8453
|
}
|
|
8244
8454
|
for (;; ) {
|
|
8245
|
-
if (
|
|
8455
|
+
if (existsSync6(join6(dir, ".git")))
|
|
8246
8456
|
return dir;
|
|
8247
|
-
const parent =
|
|
8457
|
+
const parent = dirname4(dir);
|
|
8248
8458
|
if (parent === dir)
|
|
8249
8459
|
return null;
|
|
8250
8460
|
dir = parent;
|
|
@@ -8259,16 +8469,17 @@ import {
|
|
|
8259
8469
|
mkdirSync as mkdirSync2,
|
|
8260
8470
|
openSync as openSync2,
|
|
8261
8471
|
linkSync,
|
|
8262
|
-
readFileSync as
|
|
8472
|
+
readFileSync as readFileSync5,
|
|
8263
8473
|
renameSync,
|
|
8264
8474
|
statSync,
|
|
8265
8475
|
unlinkSync,
|
|
8476
|
+
utimesSync,
|
|
8266
8477
|
writeFileSync as writeFileSync2,
|
|
8267
8478
|
writeSync
|
|
8268
8479
|
} from "node:fs";
|
|
8269
8480
|
import { randomUUID } from "node:crypto";
|
|
8270
8481
|
import { homedir as homedir2 } from "node:os";
|
|
8271
|
-
import { dirname as
|
|
8482
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
8272
8483
|
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
8273
8484
|
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
8274
8485
|
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
@@ -8284,7 +8495,7 @@ function isEnoent(err) {
|
|
|
8284
8495
|
var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
|
|
8285
8496
|
function tryCreateLock(lockPath, token) {
|
|
8286
8497
|
try {
|
|
8287
|
-
mkdirSync2(
|
|
8498
|
+
mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
|
|
8288
8499
|
const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
|
|
8289
8500
|
try {
|
|
8290
8501
|
writeSync(fd, `${token}
|
|
@@ -8346,9 +8557,30 @@ function acquireDrainLock(lockPath) {
|
|
|
8346
8557
|
unlinkSync(claimed);
|
|
8347
8558
|
return tryCreateLock(lockPath, token) ? token : null;
|
|
8348
8559
|
}
|
|
8560
|
+
function renewDrainLock(lockPath, token) {
|
|
8561
|
+
let holder;
|
|
8562
|
+
try {
|
|
8563
|
+
holder = readFileSync5(lockPath, "utf8").trim();
|
|
8564
|
+
} catch (err) {
|
|
8565
|
+
if (!isEnoent(err))
|
|
8566
|
+
throw err;
|
|
8567
|
+
return false;
|
|
8568
|
+
}
|
|
8569
|
+
if (holder !== token)
|
|
8570
|
+
return false;
|
|
8571
|
+
const now = new Date;
|
|
8572
|
+
try {
|
|
8573
|
+
utimesSync(lockPath, now, now);
|
|
8574
|
+
} catch (err) {
|
|
8575
|
+
if (!isEnoent(err))
|
|
8576
|
+
throw err;
|
|
8577
|
+
return false;
|
|
8578
|
+
}
|
|
8579
|
+
return true;
|
|
8580
|
+
}
|
|
8349
8581
|
function releaseDrainLock(lockPath, token) {
|
|
8350
8582
|
try {
|
|
8351
|
-
const holder =
|
|
8583
|
+
const holder = readFileSync5(lockPath, "utf8").trim();
|
|
8352
8584
|
if (holder !== token)
|
|
8353
8585
|
return;
|
|
8354
8586
|
unlinkSync(lockPath);
|
|
@@ -8365,68 +8597,205 @@ class WebhookDrainError extends Error {
|
|
|
8365
8597
|
this.code = code;
|
|
8366
8598
|
}
|
|
8367
8599
|
}
|
|
8600
|
+
function backupPathFor(queuePath) {
|
|
8601
|
+
return queuePath.replace(/\.ndjson$/, ".1.ndjson");
|
|
8602
|
+
}
|
|
8603
|
+
function drainingPathFor(queuePath) {
|
|
8604
|
+
return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
|
|
8605
|
+
}
|
|
8606
|
+
function rejectedPathFor(queuePath) {
|
|
8607
|
+
return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
|
|
8608
|
+
}
|
|
8609
|
+
var rejectionWarnedThisProcess = false;
|
|
8610
|
+
function warnRejectionOnce(message) {
|
|
8611
|
+
if (rejectionWarnedThisProcess)
|
|
8612
|
+
return;
|
|
8613
|
+
rejectionWarnedThisProcess = true;
|
|
8614
|
+
try {
|
|
8615
|
+
process.stderr.write(message);
|
|
8616
|
+
} catch {}
|
|
8617
|
+
}
|
|
8618
|
+
function queueLines(buf) {
|
|
8619
|
+
const lines = [];
|
|
8620
|
+
let start = 0;
|
|
8621
|
+
for (let i = 0;i < buf.byteLength; i++) {
|
|
8622
|
+
if (buf[i] !== 10)
|
|
8623
|
+
continue;
|
|
8624
|
+
if (i > start)
|
|
8625
|
+
lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
|
|
8626
|
+
start = i + 1;
|
|
8627
|
+
}
|
|
8628
|
+
if (start < buf.byteLength)
|
|
8629
|
+
lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
|
|
8630
|
+
return lines;
|
|
8631
|
+
}
|
|
8632
|
+
function removeQueueHead(path, cut) {
|
|
8633
|
+
const remaining = readFileSync5(path);
|
|
8634
|
+
writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
|
|
8635
|
+
}
|
|
8636
|
+
function queueBucketSize(path) {
|
|
8637
|
+
let lstat;
|
|
8638
|
+
try {
|
|
8639
|
+
lstat = lstatSync(path);
|
|
8640
|
+
} catch (err) {
|
|
8641
|
+
if (!isEnoent(err))
|
|
8642
|
+
throw err;
|
|
8643
|
+
}
|
|
8644
|
+
if (lstat === undefined)
|
|
8645
|
+
return null;
|
|
8646
|
+
if (!lstat.isFile()) {
|
|
8647
|
+
throw new WebhookDrainError("log-webhook-drain-symlink", `log webhook drain: outbox target is not a regular file (symlink, FIFO, or similar) — refusing to read: ${path}`);
|
|
8648
|
+
}
|
|
8649
|
+
return Number(lstat.size);
|
|
8650
|
+
}
|
|
8651
|
+
function readQueueFile(path) {
|
|
8652
|
+
if (queueBucketSize(path) === null)
|
|
8653
|
+
return null;
|
|
8654
|
+
return readFileSync5(path);
|
|
8655
|
+
}
|
|
8656
|
+
function rejectLine(rejectedPath, reason, status, identity, raw) {
|
|
8657
|
+
const record = JSON.stringify({
|
|
8658
|
+
rejected_at: new Date().toISOString(),
|
|
8659
|
+
status,
|
|
8660
|
+
reason,
|
|
8661
|
+
identity,
|
|
8662
|
+
bytes: Buffer.byteLength(raw, "utf8"),
|
|
8663
|
+
raw
|
|
8664
|
+
});
|
|
8665
|
+
const failure = appendHardenedLine(rejectedPath, `${record}
|
|
8666
|
+
`);
|
|
8667
|
+
if (failure !== null) {
|
|
8668
|
+
throw new WebhookDrainError("log-webhook-drain-rejected-write", `log webhook drain: a queued line failed re-validation (${reason}) and could not be set aside in ${rejectedPath} — ${failure}; the line stays queued`);
|
|
8669
|
+
}
|
|
8670
|
+
warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
|
|
8671
|
+
`);
|
|
8672
|
+
}
|
|
8673
|
+
async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
|
|
8674
|
+
const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
|
|
8675
|
+
let response;
|
|
8676
|
+
try {
|
|
8677
|
+
response = await fetch(webhookUrl, {
|
|
8678
|
+
method: "POST",
|
|
8679
|
+
headers: { "content-type": "application/x-ndjson", ...headers },
|
|
8680
|
+
body,
|
|
8681
|
+
signal: AbortSignal.timeout(fetchTimeoutMs)
|
|
8682
|
+
});
|
|
8683
|
+
} catch (err) {
|
|
8684
|
+
const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
|
|
8685
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
|
|
8686
|
+
}
|
|
8687
|
+
if (!response.ok) {
|
|
8688
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
|
|
8689
|
+
}
|
|
8690
|
+
}
|
|
8691
|
+
async function drainQueueFile(args) {
|
|
8692
|
+
const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
|
|
8693
|
+
const buf = readQueueFile(path);
|
|
8694
|
+
if (buf === null || buf.byteLength === 0)
|
|
8695
|
+
return;
|
|
8696
|
+
const lines = queueLines(buf);
|
|
8697
|
+
if (lines.length === 0) {
|
|
8698
|
+
removeQueueHead(path, buf.byteLength);
|
|
8699
|
+
return;
|
|
8700
|
+
}
|
|
8701
|
+
let removed = 0;
|
|
8702
|
+
let pendingEnd = 0;
|
|
8703
|
+
let chunk = [];
|
|
8704
|
+
let chunkBytes = 0;
|
|
8705
|
+
const deliverChunk = async () => {
|
|
8706
|
+
const body = `${chunk.join(`
|
|
8707
|
+
`)}
|
|
8708
|
+
`;
|
|
8709
|
+
args.keepLock();
|
|
8710
|
+
await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
|
|
8711
|
+
totals.chunks += 1;
|
|
8712
|
+
totals.lineCount += chunk.length;
|
|
8713
|
+
totals.bytes += Buffer.byteLength(body, "utf8");
|
|
8714
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8715
|
+
removed = pendingEnd;
|
|
8716
|
+
chunk = [];
|
|
8717
|
+
chunkBytes = 0;
|
|
8718
|
+
};
|
|
8719
|
+
const setAside = async (reason, status, identity, line) => {
|
|
8720
|
+
if (chunk.length > 0)
|
|
8721
|
+
await deliverChunk();
|
|
8722
|
+
rejectLine(rejectedPath, reason, status, identity, line.raw);
|
|
8723
|
+
totals.rejected += 1;
|
|
8724
|
+
pendingEnd = line.end;
|
|
8725
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8726
|
+
removed = pendingEnd;
|
|
8727
|
+
};
|
|
8728
|
+
for (const line of lines) {
|
|
8729
|
+
const record = classifyStoredLine(line.raw, homedir2());
|
|
8730
|
+
if (record.status !== "ok") {
|
|
8731
|
+
await setAside(record.reason, record.status, record.identity, line);
|
|
8732
|
+
continue;
|
|
8733
|
+
}
|
|
8734
|
+
const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
|
|
8735
|
+
if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
|
|
8736
|
+
await setAside(`one line is ${lineBytes} byte(s), over the ${MAX_WEBHOOK_BODY_BYTES}-byte per-POST cap — no chunking can carry it`, "too_large", record.identity, line);
|
|
8737
|
+
continue;
|
|
8738
|
+
}
|
|
8739
|
+
if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
|
|
8740
|
+
await deliverChunk();
|
|
8741
|
+
chunk.push(record.postLine);
|
|
8742
|
+
chunkBytes += lineBytes;
|
|
8743
|
+
pendingEnd = line.end;
|
|
8744
|
+
}
|
|
8745
|
+
pendingEnd = buf.byteLength;
|
|
8746
|
+
if (chunk.length > 0) {
|
|
8747
|
+
await deliverChunk();
|
|
8748
|
+
return;
|
|
8749
|
+
}
|
|
8750
|
+
if (pendingEnd > removed)
|
|
8751
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8752
|
+
}
|
|
8753
|
+
async function drainRenamedAside(args, livePath, source) {
|
|
8754
|
+
args.keepLock();
|
|
8755
|
+
const draining = drainingPathFor(livePath);
|
|
8756
|
+
try {
|
|
8757
|
+
renameSync(source, draining);
|
|
8758
|
+
} catch (err) {
|
|
8759
|
+
if (isEnoent(err))
|
|
8760
|
+
return;
|
|
8761
|
+
throw err;
|
|
8762
|
+
}
|
|
8763
|
+
await drainQueueFile({ ...args, path: draining });
|
|
8764
|
+
unlinkSync(draining);
|
|
8765
|
+
}
|
|
8368
8766
|
async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
|
|
8369
8767
|
const resolved = await resolveRepo();
|
|
8370
8768
|
const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
|
|
8371
|
-
const outboxRoot = () =>
|
|
8769
|
+
const outboxRoot = () => join7(GLOBAL_VINAYA_HOME, "outbox");
|
|
8372
8770
|
const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
|
|
8373
8771
|
const lockPath = `${path}.flush-lock`;
|
|
8374
8772
|
const lockToken = acquireDrainLock(lockPath);
|
|
8773
|
+
const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
|
|
8375
8774
|
if (lockToken === null)
|
|
8376
|
-
return { flushed: false };
|
|
8775
|
+
return { flushed: false, ...totals };
|
|
8377
8776
|
try {
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
const
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
throw new WebhookDrainError("log-webhook-drain-corrupt-line", `log webhook drain: outbox line ${i} failed schema re-validation — ${record.reason}`);
|
|
8401
|
-
}
|
|
8402
|
-
postLines.push(record.postLine);
|
|
8403
|
-
}
|
|
8404
|
-
const body = `${postLines.join(`
|
|
8405
|
-
`)}
|
|
8406
|
-
`;
|
|
8407
|
-
const bytes = Buffer.byteLength(body, "utf8");
|
|
8408
|
-
if (bytes > MAX_WEBHOOK_BODY_BYTES) {
|
|
8409
|
-
throw new WebhookDrainError("log-webhook-drain-too-large", `log webhook drain: outbox body is ${bytes} byte(s), over the ${MAX_WEBHOOK_BODY_BYTES}-byte per-call cap — flush more often to drain it.`);
|
|
8410
|
-
}
|
|
8411
|
-
let response;
|
|
8412
|
-
try {
|
|
8413
|
-
response = await fetch(webhookUrl, {
|
|
8414
|
-
method: "POST",
|
|
8415
|
-
headers: { "content-type": "application/x-ndjson", ...headers },
|
|
8416
|
-
body,
|
|
8417
|
-
signal: AbortSignal.timeout(fetchTimeoutMs)
|
|
8418
|
-
});
|
|
8419
|
-
} catch (err) {
|
|
8420
|
-
const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
|
|
8421
|
-
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed: ${reason}`);
|
|
8422
|
-
}
|
|
8423
|
-
if (!response.ok) {
|
|
8424
|
-
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}`);
|
|
8425
|
-
}
|
|
8426
|
-
const liveNow = readFileSync4(path);
|
|
8427
|
-
const tail = liveNow.subarray(Math.min(startOffset, liveNow.byteLength));
|
|
8428
|
-
writeFileSync2(path, tail);
|
|
8429
|
-
return { flushed: true, lineCount: postLines.length, bytes };
|
|
8777
|
+
const keepLock = () => {
|
|
8778
|
+
if (renewDrainLock(lockPath, lockToken))
|
|
8779
|
+
return;
|
|
8780
|
+
throw new WebhookDrainError("log-webhook-drain-lock-lost", `log webhook drain: this drain's lock on ${lockPath} was taken over by another process — stopping here; that process delivers the rest`);
|
|
8781
|
+
};
|
|
8782
|
+
const shared = {
|
|
8783
|
+
rejectedPath: rejectedPathFor(path),
|
|
8784
|
+
webhookUrl,
|
|
8785
|
+
headers,
|
|
8786
|
+
fetchTimeoutMs,
|
|
8787
|
+
totals,
|
|
8788
|
+
keepLock
|
|
8789
|
+
};
|
|
8790
|
+
const draining = drainingPathFor(path);
|
|
8791
|
+
if (queueBucketSize(draining) !== null) {
|
|
8792
|
+
keepLock();
|
|
8793
|
+
await drainQueueFile({ ...shared, path: draining });
|
|
8794
|
+
unlinkSync(draining);
|
|
8795
|
+
}
|
|
8796
|
+
await drainRenamedAside(shared, path, backupPathFor(path));
|
|
8797
|
+
await drainRenamedAside(shared, path, path);
|
|
8798
|
+
return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
|
|
8430
8799
|
} finally {
|
|
8431
8800
|
releaseDrainLock(lockPath, lockToken);
|
|
8432
8801
|
}
|
|
@@ -8509,7 +8878,7 @@ async function defaultResolveLogDestination(repo, env) {
|
|
|
8509
8878
|
trustAnchorConfig: unattended ? await processTrustAnchor() : null,
|
|
8510
8879
|
unattended,
|
|
8511
8880
|
env,
|
|
8512
|
-
defaultFolder:
|
|
8881
|
+
defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
|
|
8513
8882
|
repoRoot: repoRootSync()
|
|
8514
8883
|
});
|
|
8515
8884
|
}
|
|
@@ -8524,7 +8893,7 @@ async function resolveDoctrine(cwd, vinayaVersion) {
|
|
|
8524
8893
|
} catch (err) {
|
|
8525
8894
|
return isEnoent2(err) ? "unknown" : vinayaVersion;
|
|
8526
8895
|
}
|
|
8527
|
-
if (!
|
|
8896
|
+
if (!existsSync7(join8(toplevel, "aeg-root", "roles")))
|
|
8528
8897
|
return vinayaVersion;
|
|
8529
8898
|
try {
|
|
8530
8899
|
const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
|
|
@@ -8533,9 +8902,99 @@ async function resolveDoctrine(cwd, vinayaVersion) {
|
|
|
8533
8902
|
return vinayaVersion;
|
|
8534
8903
|
}
|
|
8535
8904
|
}
|
|
8905
|
+
var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
8906
|
+
function taskRefFromBranch2(branch) {
|
|
8907
|
+
const backlog = /^task\/issue-(\d+)$/.exec(branch);
|
|
8908
|
+
if (backlog) {
|
|
8909
|
+
const issue = Number(backlog[1]);
|
|
8910
|
+
return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
|
|
8911
|
+
}
|
|
8912
|
+
const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
|
|
8913
|
+
if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
|
|
8914
|
+
return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
|
|
8915
|
+
}
|
|
8916
|
+
return null;
|
|
8917
|
+
}
|
|
8918
|
+
var TRANCHE_ISSUE_LIST_LIMIT = 200;
|
|
8919
|
+
async function issueForTrancheTask(tranche, taskId, cwd, repo) {
|
|
8920
|
+
let stdout;
|
|
8921
|
+
try {
|
|
8922
|
+
({ stdout } = await execFileAsync5("gh", [
|
|
8923
|
+
"issue",
|
|
8924
|
+
"list",
|
|
8925
|
+
"--state",
|
|
8926
|
+
"all",
|
|
8927
|
+
"--label",
|
|
8928
|
+
`vinaya/tranche:${tranche}`,
|
|
8929
|
+
"--json",
|
|
8930
|
+
"number,title,labels",
|
|
8931
|
+
"--limit",
|
|
8932
|
+
String(TRANCHE_ISSUE_LIST_LIMIT),
|
|
8933
|
+
...repo === null ? [] : ["--repo", repo]
|
|
8934
|
+
], {
|
|
8935
|
+
cwd,
|
|
8936
|
+
encoding: "utf8",
|
|
8937
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
8938
|
+
timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
|
|
8939
|
+
killSignal: "SIGKILL"
|
|
8940
|
+
}));
|
|
8941
|
+
} catch {
|
|
8942
|
+
return null;
|
|
8943
|
+
}
|
|
8944
|
+
let issues;
|
|
8945
|
+
try {
|
|
8946
|
+
issues = JSON.parse(stdout);
|
|
8947
|
+
} catch {
|
|
8948
|
+
return null;
|
|
8949
|
+
}
|
|
8950
|
+
for (const issue of issues) {
|
|
8951
|
+
const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
|
|
8952
|
+
if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
|
|
8953
|
+
return issue.number;
|
|
8954
|
+
}
|
|
8955
|
+
return null;
|
|
8956
|
+
}
|
|
8957
|
+
async function confirmBacklogIssue(issue, cwd, repo) {
|
|
8958
|
+
let stdout;
|
|
8959
|
+
try {
|
|
8960
|
+
({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
|
|
8961
|
+
cwd,
|
|
8962
|
+
encoding: "utf8",
|
|
8963
|
+
timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
|
|
8964
|
+
killSignal: "SIGKILL"
|
|
8965
|
+
}));
|
|
8966
|
+
} catch (err) {
|
|
8967
|
+
const stderr = typeof err.stderr === "string" ? err.stderr : "";
|
|
8968
|
+
return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
|
|
8969
|
+
}
|
|
8970
|
+
try {
|
|
8971
|
+
return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
|
|
8972
|
+
} catch {
|
|
8973
|
+
return "unknown";
|
|
8974
|
+
}
|
|
8975
|
+
}
|
|
8976
|
+
async function resolveBranchIssue(cwd, env = process.env, repo = null) {
|
|
8977
|
+
let branch;
|
|
8978
|
+
try {
|
|
8979
|
+
branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
|
|
8980
|
+
encoding: "utf8",
|
|
8981
|
+
timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
|
|
8982
|
+
killSignal: "SIGKILL"
|
|
8983
|
+
})).stdout.trim();
|
|
8984
|
+
} catch {
|
|
8985
|
+
return null;
|
|
8986
|
+
}
|
|
8987
|
+
const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
|
|
8988
|
+
const ref = taskRefFromBranch2(named);
|
|
8989
|
+
if (ref === null)
|
|
8990
|
+
return null;
|
|
8991
|
+
if (ref.kind === "tranche")
|
|
8992
|
+
return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
|
|
8993
|
+
return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
|
|
8994
|
+
}
|
|
8536
8995
|
function readVinayaVersion() {
|
|
8537
8996
|
try {
|
|
8538
|
-
const pkg = JSON.parse(
|
|
8997
|
+
const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
8539
8998
|
return pkg.version ?? "unknown";
|
|
8540
8999
|
} catch {
|
|
8541
9000
|
return "unknown";
|
|
@@ -8545,10 +9004,15 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
|
8545
9004
|
function isSafeRepoSegment3(segment) {
|
|
8546
9005
|
return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
|
|
8547
9006
|
}
|
|
9007
|
+
function safeRepoSlug(repo) {
|
|
9008
|
+
if (repo === null)
|
|
9009
|
+
return null;
|
|
9010
|
+
return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
|
|
9011
|
+
}
|
|
8548
9012
|
function outboxPathFor(deps, repo, issue) {
|
|
8549
9013
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
8550
9014
|
const fileName = `${issue ?? "none"}.ndjson`;
|
|
8551
|
-
return
|
|
9015
|
+
return join8(deps.outboxRoot(), dirName, fileName);
|
|
8552
9016
|
}
|
|
8553
9017
|
function hostFromEnv(env) {
|
|
8554
9018
|
if (env.GITHUB_ACTIONS)
|
|
@@ -8566,9 +9030,21 @@ function defaultStderr(message) {
|
|
|
8566
9030
|
warnedThisProcess = true;
|
|
8567
9031
|
process.stderr.write(message);
|
|
8568
9032
|
}
|
|
9033
|
+
var branchIssueFallbackEnabled = true;
|
|
9034
|
+
var branchIssueByCwd = new Map;
|
|
9035
|
+
function branchIssueRead(key, read, shared) {
|
|
9036
|
+
if (!shared)
|
|
9037
|
+
return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
9038
|
+
const cached = branchIssueByCwd.get(key);
|
|
9039
|
+
if (cached !== undefined)
|
|
9040
|
+
return cached;
|
|
9041
|
+
const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
9042
|
+
branchIssueByCwd.set(key, reading);
|
|
9043
|
+
return reading;
|
|
9044
|
+
}
|
|
8569
9045
|
function defaultDeps() {
|
|
8570
9046
|
return {
|
|
8571
|
-
outboxRoot: () =>
|
|
9047
|
+
outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
|
|
8572
9048
|
home: () => homedir3(),
|
|
8573
9049
|
hostname: () => osHostname(),
|
|
8574
9050
|
cwd: () => process.cwd(),
|
|
@@ -8591,10 +9067,28 @@ function guardedAppendOpen(path) {
|
|
|
8591
9067
|
return;
|
|
8592
9068
|
}
|
|
8593
9069
|
}
|
|
9070
|
+
function appendHardenedLine(path, line) {
|
|
9071
|
+
try {
|
|
9072
|
+
mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
|
|
9073
|
+
const fd = guardedAppendOpen(path);
|
|
9074
|
+
if (fd === undefined)
|
|
9075
|
+
return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
|
|
9076
|
+
try {
|
|
9077
|
+
if (!fstatSync2(fd).isFile())
|
|
9078
|
+
return `target is not a regular file: ${path}`;
|
|
9079
|
+
writeSync2(fd, line);
|
|
9080
|
+
} finally {
|
|
9081
|
+
closeSync3(fd);
|
|
9082
|
+
}
|
|
9083
|
+
return null;
|
|
9084
|
+
} catch (err) {
|
|
9085
|
+
return err instanceof Error ? err.message : String(err);
|
|
9086
|
+
}
|
|
9087
|
+
}
|
|
8594
9088
|
function reportRotationOverflow(backupPath, warn) {
|
|
8595
9089
|
let raw;
|
|
8596
9090
|
try {
|
|
8597
|
-
raw =
|
|
9091
|
+
raw = readFileSync6(backupPath, "utf8");
|
|
8598
9092
|
} catch {
|
|
8599
9093
|
return;
|
|
8600
9094
|
}
|
|
@@ -8617,7 +9111,7 @@ function reportRotationOverflow(backupPath, warn) {
|
|
|
8617
9111
|
}
|
|
8618
9112
|
function appendLine(path, line, warn) {
|
|
8619
9113
|
try {
|
|
8620
|
-
mkdirSync3(
|
|
9114
|
+
mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
|
|
8621
9115
|
let fd = guardedAppendOpen(path);
|
|
8622
9116
|
if (fd === undefined) {
|
|
8623
9117
|
warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
|
|
@@ -8658,7 +9152,11 @@ function appendLine(path, line, warn) {
|
|
|
8658
9152
|
}
|
|
8659
9153
|
}
|
|
8660
9154
|
function createLogSink(overrides = {}) {
|
|
8661
|
-
const deps = {
|
|
9155
|
+
const deps = {
|
|
9156
|
+
...defaultDeps(),
|
|
9157
|
+
resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
|
|
9158
|
+
...overrides
|
|
9159
|
+
};
|
|
8662
9160
|
const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
|
|
8663
9161
|
const processId = randomUUID2();
|
|
8664
9162
|
let seq = 0;
|
|
@@ -8678,6 +9176,19 @@ function createLogSink(overrides = {}) {
|
|
|
8678
9176
|
}
|
|
8679
9177
|
return doctrineCache;
|
|
8680
9178
|
};
|
|
9179
|
+
const readerIsReal = overrides.resolveBranchIssue === undefined;
|
|
9180
|
+
let ownBranchIssue;
|
|
9181
|
+
const branchIssueOnce = (repo) => {
|
|
9182
|
+
if (!branchIssueFallbackEnabled)
|
|
9183
|
+
return Promise.resolve(null);
|
|
9184
|
+
const slug = safeRepoSlug(repo);
|
|
9185
|
+
const read = () => deps.resolveBranchIssue(slug);
|
|
9186
|
+
if (readerIsReal)
|
|
9187
|
+
return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
|
|
9188
|
+
if (ownBranchIssue === undefined)
|
|
9189
|
+
ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
|
|
9190
|
+
return ownBranchIssue;
|
|
9191
|
+
};
|
|
8681
9192
|
let resolveRepoCache;
|
|
8682
9193
|
const resolveRepoOnce = () => {
|
|
8683
9194
|
if (resolveRepoCache === undefined)
|
|
@@ -8700,6 +9211,7 @@ function createLogSink(overrides = {}) {
|
|
|
8700
9211
|
};
|
|
8701
9212
|
let drainChain = Promise.resolve();
|
|
8702
9213
|
const pendingWrites = new Set;
|
|
9214
|
+
let writeChain = Promise.resolve();
|
|
8703
9215
|
const scheduleWebhookDrain = (issue, url, headers) => {
|
|
8704
9216
|
drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
|
|
8705
9217
|
return;
|
|
@@ -8722,7 +9234,14 @@ function createLogSink(overrides = {}) {
|
|
|
8722
9234
|
attempt: env.VINAYA_ATTEMPT,
|
|
8723
9235
|
parent: env.VINAYA_PARENT_EVENT
|
|
8724
9236
|
};
|
|
8725
|
-
const
|
|
9237
|
+
const write = async () => {
|
|
9238
|
+
const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
|
|
9239
|
+
if (resolvedDestination.kind === "none") {
|
|
9240
|
+
warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
|
|
9241
|
+
`);
|
|
9242
|
+
return;
|
|
9243
|
+
}
|
|
9244
|
+
const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
|
|
8726
9245
|
const header = buildHeader({
|
|
8727
9246
|
now,
|
|
8728
9247
|
runId,
|
|
@@ -8733,15 +9252,11 @@ function createLogSink(overrides = {}) {
|
|
|
8733
9252
|
host,
|
|
8734
9253
|
hostname: deps.hostname(),
|
|
8735
9254
|
env: envFields,
|
|
9255
|
+
branchIssue,
|
|
8736
9256
|
eventId: randomUUID2(),
|
|
8737
9257
|
processId,
|
|
8738
9258
|
inputVersions: deps.inputVersions()
|
|
8739
9259
|
});
|
|
8740
|
-
if (resolvedDestination.kind === "none") {
|
|
8741
|
-
warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
|
|
8742
|
-
`);
|
|
8743
|
-
return;
|
|
8744
|
-
}
|
|
8745
9260
|
const full = { ...e, ...header };
|
|
8746
9261
|
const parsed = LogEventSchema.safeParse(full);
|
|
8747
9262
|
if (!parsed.success) {
|
|
@@ -8758,10 +9273,12 @@ function createLogSink(overrides = {}) {
|
|
|
8758
9273
|
} else {
|
|
8759
9274
|
appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
|
|
8760
9275
|
}
|
|
8761
|
-
}
|
|
9276
|
+
};
|
|
9277
|
+
const written = writeChain.then(write).catch((err) => {
|
|
8762
9278
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8763
9279
|
`);
|
|
8764
9280
|
});
|
|
9281
|
+
writeChain = written;
|
|
8765
9282
|
pendingWrites.add(written);
|
|
8766
9283
|
written.finally(() => pendingWrites.delete(written));
|
|
8767
9284
|
} catch (err) {
|
|
@@ -8837,7 +9354,7 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
8837
9354
|
function fileDiffAgainst(ref, path) {
|
|
8838
9355
|
let out;
|
|
8839
9356
|
try {
|
|
8840
|
-
out =
|
|
9357
|
+
out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
8841
9358
|
encoding: "utf8",
|
|
8842
9359
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8843
9360
|
}).trim();
|
|
@@ -8848,7 +9365,7 @@ function fileDiffAgainst(ref, path) {
|
|
|
8848
9365
|
}
|
|
8849
9366
|
function revParse(ref) {
|
|
8850
9367
|
try {
|
|
8851
|
-
return
|
|
9368
|
+
return execFileSync6("git", ["rev-parse", "--verify", ref], {
|
|
8852
9369
|
encoding: "utf8",
|
|
8853
9370
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8854
9371
|
}).trim();
|
|
@@ -8858,7 +9375,7 @@ function revParse(ref) {
|
|
|
8858
9375
|
}
|
|
8859
9376
|
function repoRoot() {
|
|
8860
9377
|
try {
|
|
8861
|
-
return
|
|
9378
|
+
return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
|
|
8862
9379
|
encoding: "utf8",
|
|
8863
9380
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8864
9381
|
}).trim();
|
|
@@ -8869,7 +9386,7 @@ function repoRoot() {
|
|
|
8869
9386
|
function changedFiles(base) {
|
|
8870
9387
|
let out;
|
|
8871
9388
|
try {
|
|
8872
|
-
out =
|
|
9389
|
+
out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
8873
9390
|
encoding: "utf8",
|
|
8874
9391
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8875
9392
|
}).trim();
|
|
@@ -8894,7 +9411,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
|
|
|
8894
9411
|
const relPaths = changedFiles(ref);
|
|
8895
9412
|
if (relPaths === null)
|
|
8896
9413
|
continue;
|
|
8897
|
-
return { base: ref, root, files: relPaths.map((p) =>
|
|
9414
|
+
return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
|
|
8898
9415
|
}
|
|
8899
9416
|
return null;
|
|
8900
9417
|
}
|
|
@@ -8931,7 +9448,7 @@ var DOCTRINE_ROOT = loadConfig()?.proseGates?.doctrineRoot ?? "aeg-root";
|
|
|
8931
9448
|
var SHIPS_PREFIX2 = `${DOCTRINE_ROOT}/`;
|
|
8932
9449
|
function git2(args) {
|
|
8933
9450
|
try {
|
|
8934
|
-
return
|
|
9451
|
+
return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
8935
9452
|
} catch {
|
|
8936
9453
|
return "";
|
|
8937
9454
|
}
|
|
@@ -8939,12 +9456,12 @@ function git2(args) {
|
|
|
8939
9456
|
function collectWorkingTree(dir, out = []) {
|
|
8940
9457
|
let entries;
|
|
8941
9458
|
try {
|
|
8942
|
-
entries =
|
|
9459
|
+
entries = readdirSync3(dir);
|
|
8943
9460
|
} catch {
|
|
8944
9461
|
return out;
|
|
8945
9462
|
}
|
|
8946
9463
|
for (const name of entries) {
|
|
8947
|
-
const full =
|
|
9464
|
+
const full = join10(dir, name);
|
|
8948
9465
|
let isDir;
|
|
8949
9466
|
try {
|
|
8950
9467
|
isDir = statSync2(full).isDirectory();
|
|
@@ -8962,7 +9479,7 @@ function collectWorkingTree(dir, out = []) {
|
|
|
8962
9479
|
return out;
|
|
8963
9480
|
}
|
|
8964
9481
|
function readWorkingTree(paths) {
|
|
8965
|
-
return paths.map((p) => ({ path: p, content:
|
|
9482
|
+
return paths.map((p) => ({ path: p, content: readFileSync7(p, "utf8") }));
|
|
8966
9483
|
}
|
|
8967
9484
|
function collectAtRef(ref, dir) {
|
|
8968
9485
|
const listing = git2(["ls-tree", "-r", "--name-only", ref, "--", dir]);
|