@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
|
@@ -3,8 +3,8 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
4
|
|
|
5
5
|
// src/checks/bin/check-workspace-escape.ts
|
|
6
|
-
import { readdirSync as
|
|
7
|
-
import { join as
|
|
6
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync2 } from "node:fs";
|
|
7
|
+
import { join as join10 } from "node:path";
|
|
8
8
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
9
9
|
var GATE_AUDIENCE = {
|
|
10
10
|
"check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
|
|
@@ -199,8 +199,8 @@ function maskIndentedCode(body, fill) {
|
|
|
199
199
|
var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
|
|
200
200
|
var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
|
|
201
201
|
var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
|
|
202
|
-
var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d
|
|
203
|
-
var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+
|
|
202
|
+
var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
|
|
203
|
+
var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
|
|
204
204
|
function splitSlugQualifiedEdge(edge) {
|
|
205
205
|
const m = edge.trim().match(SLUG_QUALIFIED_ID);
|
|
206
206
|
if (!m)
|
|
@@ -2048,12 +2048,24 @@ function extractBaseSha(comment) {
|
|
|
2048
2048
|
const m = firstThirteenLines(comment).match(BASE_SHA_PATTERN);
|
|
2049
2049
|
return m ? m[1].toLowerCase() : null;
|
|
2050
2050
|
}
|
|
2051
|
-
var
|
|
2051
|
+
var FINDING_DESCRIPTION_STATE = /^F(\d+)(?:\s+\S+)?(?:\s+(open|fix-claimed|reproduced|resolved))?:/;
|
|
2052
|
+
function parseFindingState(description) {
|
|
2053
|
+
const m = FINDING_DESCRIPTION_STATE.exec(description.trim());
|
|
2054
|
+
if (!m)
|
|
2055
|
+
return { id: null, state: null };
|
|
2056
|
+
return { id: `F${m[1]}`, state: m[2] ?? null };
|
|
2057
|
+
}
|
|
2058
|
+
var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—(?:\s+(.*))?$/gm;
|
|
2052
2059
|
function extractFindingSeverities(comment) {
|
|
2053
|
-
return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) =>
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2060
|
+
return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => {
|
|
2061
|
+
const { id, state } = parseFindingState(m[3] ?? "");
|
|
2062
|
+
return {
|
|
2063
|
+
severity: m[1],
|
|
2064
|
+
location: m[2],
|
|
2065
|
+
id,
|
|
2066
|
+
state
|
|
2067
|
+
};
|
|
2068
|
+
});
|
|
2057
2069
|
}
|
|
2058
2070
|
function extractVerdict(comments, valuePattern, missingLabel) {
|
|
2059
2071
|
const candidates = comments.filter((c) => valuePattern.test(c));
|
|
@@ -2467,6 +2479,12 @@ function evaluateReviewFindings(findings, scale, threshold) {
|
|
|
2467
2479
|
});
|
|
2468
2480
|
return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
|
|
2469
2481
|
}
|
|
2482
|
+
function isConsequentialFinding(finding) {
|
|
2483
|
+
return finding.state !== "resolved";
|
|
2484
|
+
}
|
|
2485
|
+
function consequentialFindings(findings) {
|
|
2486
|
+
return findings.filter((f) => isConsequentialFinding(f));
|
|
2487
|
+
}
|
|
2470
2488
|
function evaluateCodeReview(findings, policy) {
|
|
2471
2489
|
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
|
|
2472
2490
|
}
|
|
@@ -2603,7 +2621,7 @@ function isIssueNotFoundError(err) {
|
|
|
2603
2621
|
return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
|
|
2604
2622
|
}
|
|
2605
2623
|
function resolveObjectivesSource(prBody, issue, cutoverIssue) {
|
|
2606
|
-
if (issue !== null && issue < cutoverIssue)
|
|
2624
|
+
if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
|
|
2607
2625
|
return { kind: "none" };
|
|
2608
2626
|
if (issue !== null)
|
|
2609
2627
|
return { kind: "issue", issue };
|
|
@@ -2879,9 +2897,18 @@ var COMMIT_TYPES = [
|
|
|
2879
2897
|
];
|
|
2880
2898
|
var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
|
|
2881
2899
|
function checkForgeTitle(title) {
|
|
2882
|
-
const taskStyle = /^\[[a-z0-9._-]+\] \
|
|
2900
|
+
const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
|
|
2883
2901
|
if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
|
|
2884
2902
|
return { status: "pass", errors: [] };
|
|
2903
|
+
const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
|
|
2904
|
+
if (letteredTaskId) {
|
|
2905
|
+
return {
|
|
2906
|
+
status: "fail",
|
|
2907
|
+
errors: [
|
|
2908
|
+
`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.`
|
|
2909
|
+
]
|
|
2910
|
+
};
|
|
2911
|
+
}
|
|
2885
2912
|
return {
|
|
2886
2913
|
status: "fail",
|
|
2887
2914
|
errors: [
|
|
@@ -2914,19 +2941,31 @@ function checkNoAgentBoxes(prBody) {
|
|
|
2914
2941
|
]
|
|
2915
2942
|
};
|
|
2916
2943
|
}
|
|
2917
|
-
function
|
|
2944
|
+
function rolloutRuleFor(message) {
|
|
2918
2945
|
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:")) {
|
|
2919
|
-
return
|
|
2946
|
+
return "briefRules";
|
|
2920
2947
|
}
|
|
2921
2948
|
if (message.startsWith("brief-validation no agent boxes:"))
|
|
2922
|
-
return
|
|
2949
|
+
return "agentBoxes";
|
|
2950
|
+
return null;
|
|
2951
|
+
}
|
|
2952
|
+
var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
|
|
2953
|
+
briefRulesSincePr: BRIEF_RULES_SINCE_PR,
|
|
2954
|
+
agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
|
|
2955
|
+
};
|
|
2956
|
+
function rolloutThresholdFor(message, cutovers) {
|
|
2957
|
+
const rule = rolloutRuleFor(message);
|
|
2958
|
+
if (rule === "briefRules")
|
|
2959
|
+
return cutovers.briefRulesSincePr;
|
|
2960
|
+
if (rule === "agentBoxes")
|
|
2961
|
+
return cutovers.agentBoxesRefusedSincePr;
|
|
2923
2962
|
return null;
|
|
2924
2963
|
}
|
|
2925
|
-
function partitionBriefErrorsByRollout(errors, prNumber) {
|
|
2964
|
+
function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
|
|
2926
2965
|
const blocking = [];
|
|
2927
2966
|
const info = [];
|
|
2928
2967
|
for (const e of errors) {
|
|
2929
|
-
const threshold = rolloutThresholdFor(e);
|
|
2968
|
+
const threshold = rolloutThresholdFor(e, cutovers);
|
|
2930
2969
|
const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
|
|
2931
2970
|
(grandfathered ? info : blocking).push(e);
|
|
2932
2971
|
}
|
|
@@ -3394,8 +3433,8 @@ function checkIssueRationale(body) {
|
|
|
3394
3433
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3395
3434
|
}
|
|
3396
3435
|
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3397
|
-
function checkIssueObjectives(body, issueNumber) {
|
|
3398
|
-
if (issueNumber !== null && issueNumber <
|
|
3436
|
+
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3437
|
+
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3399
3438
|
return { status: "pass", errors: [] };
|
|
3400
3439
|
const result = objectivesOf(body);
|
|
3401
3440
|
if (result.ok)
|
|
@@ -3840,7 +3879,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
|
|
|
3840
3879
|
return issueToEntry.get(Number(issueMatch[1]));
|
|
3841
3880
|
return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
|
|
3842
3881
|
}
|
|
3843
|
-
function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
|
|
3882
|
+
function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
|
|
3844
3883
|
const failures = [];
|
|
3845
3884
|
for (const [slug, issues] of issuesBySlug) {
|
|
3846
3885
|
for (const issue of issues) {
|
|
@@ -3849,7 +3888,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
|
|
|
3849
3888
|
const errors = [
|
|
3850
3889
|
...checkIssueRationale(issue.body).errors,
|
|
3851
3890
|
...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
|
|
3852
|
-
...checkIssueObjectives(issue.body, issue.number).errors,
|
|
3891
|
+
...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
|
|
3853
3892
|
...checkPartsCiteDefinedObjectives(issue.body).errors
|
|
3854
3893
|
];
|
|
3855
3894
|
if (errors.length === 0)
|
|
@@ -4099,8 +4138,8 @@ function checkReviewGate(input) {
|
|
|
4099
4138
|
let codeReviewPolicyEvaluation;
|
|
4100
4139
|
let securityPolicyEvaluation;
|
|
4101
4140
|
try {
|
|
4102
|
-
codeReviewPolicyEvaluation = evaluateCodeReview(codeReview.findingSeverities, policy);
|
|
4103
|
-
securityPolicyEvaluation = evaluateSecurityReview(security.findingSeverities, policy);
|
|
4141
|
+
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
|
|
4142
|
+
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
|
|
4104
4143
|
} catch (err) {
|
|
4105
4144
|
return {
|
|
4106
4145
|
verdict: "fail",
|
|
@@ -4472,13 +4511,27 @@ var SHIPS_PREFIX = "aeg-root/";
|
|
|
4472
4511
|
function shipsArchivePrefix(shipsPrefix) {
|
|
4473
4512
|
return `${shipsPrefix}tranches/completed/`;
|
|
4474
4513
|
}
|
|
4475
|
-
|
|
4476
|
-
|
|
4514
|
+
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
4515
|
+
function normalizeSpecPath(entry) {
|
|
4516
|
+
let out = entry.replace(/\\/g, "/");
|
|
4517
|
+
while (out.startsWith("./"))
|
|
4518
|
+
out = out.slice(2);
|
|
4519
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
4520
|
+
while (out.endsWith("/"))
|
|
4521
|
+
out = out.slice(0, -1);
|
|
4522
|
+
return out;
|
|
4523
|
+
}
|
|
4524
|
+
function isSpecFile2(path, specPaths) {
|
|
4525
|
+
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
4526
|
+
return true;
|
|
4527
|
+
if (!path.endsWith(".md"))
|
|
4528
|
+
return false;
|
|
4529
|
+
return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
|
|
4477
4530
|
}
|
|
4478
4531
|
function isClaudeMdFile(path) {
|
|
4479
4532
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
4480
4533
|
}
|
|
4481
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4534
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4482
4535
|
if (path.startsWith(shipsPrefix)) {
|
|
4483
4536
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
4484
4537
|
}
|
|
@@ -4487,7 +4540,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
4487
4540
|
}
|
|
4488
4541
|
if (isClaudeMdFile(path))
|
|
4489
4542
|
return "internal";
|
|
4490
|
-
if (isSpecFile2(path))
|
|
4543
|
+
if (isSpecFile2(path, specPaths))
|
|
4491
4544
|
return "spec";
|
|
4492
4545
|
if (isProductScopeFile(path))
|
|
4493
4546
|
return "product";
|
|
@@ -4516,13 +4569,14 @@ function lineAt(content, index) {
|
|
|
4516
4569
|
}
|
|
4517
4570
|
var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
|
|
4518
4571
|
var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
|
|
4572
|
+
var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
|
|
4519
4573
|
function legacySlugPattern(legacySlugs) {
|
|
4520
4574
|
if (legacySlugs.length === 0)
|
|
4521
4575
|
return null;
|
|
4522
4576
|
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
4523
4577
|
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
4524
4578
|
}
|
|
4525
|
-
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
|
|
4579
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4526
4580
|
const findings = [];
|
|
4527
4581
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
4528
4582
|
const grandfathered = new Set(specGrandfather);
|
|
@@ -4534,8 +4588,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
|
|
|
4534
4588
|
const productPatterns = [
|
|
4535
4589
|
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
4536
4590
|
];
|
|
4591
|
+
const specPatterns = [
|
|
4592
|
+
...patterns,
|
|
4593
|
+
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
4594
|
+
];
|
|
4537
4595
|
for (const file of files) {
|
|
4538
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
4596
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
4539
4597
|
if (!cls || cls === "internal")
|
|
4540
4598
|
continue;
|
|
4541
4599
|
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
@@ -4544,15 +4602,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
|
|
|
4544
4602
|
continue;
|
|
4545
4603
|
const blocking = cls === "product" || cls === "spec";
|
|
4546
4604
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
4547
|
-
const patternsToRun = cls === "product" ? productPatterns : patterns;
|
|
4605
|
+
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
4548
4606
|
for (const { pattern, what, group } of patternsToRun) {
|
|
4549
4607
|
pattern.lastIndex = 0;
|
|
4550
4608
|
let match = pattern.exec(scrubbed);
|
|
4551
4609
|
while (match !== null) {
|
|
4552
4610
|
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4611
|
+
const citedIndex = match.index + match[0].indexOf(cited);
|
|
4553
4612
|
findings.push({
|
|
4554
4613
|
file: file.path,
|
|
4555
|
-
line: lineAt(scrubbed,
|
|
4614
|
+
line: lineAt(scrubbed, citedIndex),
|
|
4556
4615
|
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4557
4616
|
blocking
|
|
4558
4617
|
});
|
|
@@ -4738,9 +4797,9 @@ function checkSourceComments(files, allowlist = []) {
|
|
|
4738
4797
|
}
|
|
4739
4798
|
return findings;
|
|
4740
4799
|
}
|
|
4741
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
|
|
4800
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4742
4801
|
return [
|
|
4743
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
|
|
4802
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
4744
4803
|
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4745
4804
|
];
|
|
4746
4805
|
}
|
|
@@ -5181,15 +5240,32 @@ var ObservedSchema = z.object({
|
|
|
5181
5240
|
var TaskStatusInputSchema = z.object({
|
|
5182
5241
|
task: TaskToolRefSchema.optional()
|
|
5183
5242
|
}).merge(PageRequestSchema).strict();
|
|
5243
|
+
var TaskConfidenceSchema = z.object({
|
|
5244
|
+
round: z.number().int().positive(),
|
|
5245
|
+
percent: z.number().int().min(0).max(100).nullable(),
|
|
5246
|
+
source: z.enum(["stated", "published-summary"])
|
|
5247
|
+
}).strict();
|
|
5248
|
+
var TaskPhaseHistorySchema = z.object({
|
|
5249
|
+
typicalPhaseMinutes: z.number().nonnegative(),
|
|
5250
|
+
typicalPhaseSamples: z.number().int().positive()
|
|
5251
|
+
}).strict();
|
|
5184
5252
|
var TaskStatusItemSchema = z.object({
|
|
5185
5253
|
task: TaskToolRefSchema,
|
|
5186
5254
|
issue: z.number().int().positive(),
|
|
5187
5255
|
pr: z.number().int().positive().nullable(),
|
|
5188
|
-
state: z.string()
|
|
5256
|
+
state: z.string(),
|
|
5257
|
+
round: z.number().int().positive().nullable().optional(),
|
|
5258
|
+
phase: z.string().min(1).nullable().optional(),
|
|
5259
|
+
minutesInPhase: z.number().nonnegative().nullable().optional(),
|
|
5260
|
+
phaseIsCurrent: z.boolean().nullable().optional(),
|
|
5261
|
+
lastConfidence: TaskConfidenceSchema.nullable().optional(),
|
|
5262
|
+
lastConfidenceUnread: z.boolean().optional(),
|
|
5263
|
+
phaseHistory: TaskPhaseHistorySchema.nullable().optional()
|
|
5189
5264
|
}).merge(ObservedSchema);
|
|
5190
5265
|
var TaskStatusResultSchema = z.object({
|
|
5191
5266
|
items: z.array(TaskStatusItemSchema),
|
|
5192
|
-
nextCursor: z.string().nullable()
|
|
5267
|
+
nextCursor: z.string().nullable(),
|
|
5268
|
+
table: z.string()
|
|
5193
5269
|
});
|
|
5194
5270
|
var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
|
|
5195
5271
|
var EscalationInputsSchema = z.object({
|
|
@@ -5197,7 +5273,7 @@ var EscalationInputsSchema = z.object({
|
|
|
5197
5273
|
round: z.number().int().nonnegative(),
|
|
5198
5274
|
head: z.string(),
|
|
5199
5275
|
branch: z.string(),
|
|
5200
|
-
prNumber: z.number().int().positive()
|
|
5276
|
+
prNumber: z.number().int().positive().nullable()
|
|
5201
5277
|
});
|
|
5202
5278
|
var EscalationEvidenceSchema = z.object({
|
|
5203
5279
|
round: z.number().int().nonnegative(),
|
|
@@ -5233,13 +5309,45 @@ var TaskEscalationReadResultSchema = z.object({
|
|
|
5233
5309
|
items: z.array(TaskEscalationPacketSchema),
|
|
5234
5310
|
nextCursor: z.string().nullable()
|
|
5235
5311
|
}).merge(ObservedSchema);
|
|
5236
|
-
var
|
|
5237
|
-
|
|
5238
|
-
|
|
5312
|
+
var TaskPrCheckSchema = z.object({
|
|
5313
|
+
name: z.string(),
|
|
5314
|
+
required: z.boolean(),
|
|
5315
|
+
status: z.string(),
|
|
5316
|
+
conclusion: z.string().nullable(),
|
|
5317
|
+
detailsUrl: z.string().nullable(),
|
|
5318
|
+
failureSummary: z.string().nullable()
|
|
5319
|
+
});
|
|
5320
|
+
var TaskPrVerdictSchema = z.object({
|
|
5321
|
+
role: z.enum(["code-review", "security"]),
|
|
5322
|
+
value: z.string(),
|
|
5323
|
+
judgedHead: z.string().nullable(),
|
|
5324
|
+
objectivesVersion: z.string().nullable()
|
|
5325
|
+
});
|
|
5326
|
+
var TaskPrPauseSchema = z.object({
|
|
5327
|
+
reason: z.string(),
|
|
5328
|
+
body: z.string()
|
|
5329
|
+
});
|
|
5330
|
+
var TaskPrReviewRecordSchema = z.object({
|
|
5331
|
+
verdicts: z.array(TaskPrVerdictSchema),
|
|
5332
|
+
roundMarkers: z.array(z.number().int().nonnegative()),
|
|
5333
|
+
summaryTable: z.string().nullable(),
|
|
5334
|
+
pause: TaskPrPauseSchema.nullable()
|
|
5335
|
+
});
|
|
5336
|
+
var TaskPrReadInputSchema = z.object({
|
|
5337
|
+
task: TaskToolRefSchema,
|
|
5338
|
+
pr: z.number().int().positive().optional()
|
|
5239
5339
|
}).strict();
|
|
5340
|
+
var TaskPrReadResultSchema = z.object({
|
|
5341
|
+
task: TaskToolRefSchema,
|
|
5342
|
+
issue: z.number().int().positive(),
|
|
5343
|
+
pr: z.number().int().positive(),
|
|
5344
|
+
head: z.string().nullable(),
|
|
5345
|
+
checks: z.array(TaskPrCheckSchema),
|
|
5346
|
+
review: TaskPrReviewRecordSchema
|
|
5347
|
+
}).merge(ObservedSchema);
|
|
5240
5348
|
var TaskStartResultSchema = z.object({
|
|
5241
5349
|
requestId: z.string().min(1),
|
|
5242
|
-
run:
|
|
5350
|
+
run: TaskToolRefSchema,
|
|
5243
5351
|
started: z.boolean(),
|
|
5244
5352
|
startedAt: z.string(),
|
|
5245
5353
|
mode: z.literal("attended")
|
|
@@ -5253,7 +5361,7 @@ var TaskCancelInputSchema = z.object({
|
|
|
5253
5361
|
}).strict();
|
|
5254
5362
|
var TaskResumeResultSchema = z.object({
|
|
5255
5363
|
task: z.number().int().positive(),
|
|
5256
|
-
pr: z.number().int().positive(),
|
|
5364
|
+
pr: z.number().int().positive().nullable(),
|
|
5257
5365
|
escalationId: z.string().min(1),
|
|
5258
5366
|
outcome: z.enum(["started", "already_resumed"]),
|
|
5259
5367
|
authenticatedBy: z.string().min(1),
|
|
@@ -5262,7 +5370,7 @@ var TaskResumeResultSchema = z.object({
|
|
|
5262
5370
|
var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
|
|
5263
5371
|
var TaskCancelResultSchema = z.object({
|
|
5264
5372
|
task: z.number().int().positive(),
|
|
5265
|
-
pr: z.number().int().positive(),
|
|
5373
|
+
pr: z.number().int().positive().nullable(),
|
|
5266
5374
|
escalationId: z.string().min(1),
|
|
5267
5375
|
outcome: TaskCancelOutcomeSchema,
|
|
5268
5376
|
authenticatedBy: z.string().min(1),
|
|
@@ -5273,6 +5381,7 @@ var TASK_TOOL_NAMES = [
|
|
|
5273
5381
|
"task_start",
|
|
5274
5382
|
"task_status",
|
|
5275
5383
|
"task_escalation_read",
|
|
5384
|
+
"task_pr_read",
|
|
5276
5385
|
"task_resume",
|
|
5277
5386
|
"task_cancel"
|
|
5278
5387
|
];
|
|
@@ -5500,6 +5609,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
|
|
|
5500
5609
|
}
|
|
5501
5610
|
return findings;
|
|
5502
5611
|
}
|
|
5612
|
+
// ../../packages/aeg-core/src/gate-cutovers.ts
|
|
5613
|
+
var NO_GATE_CUTOVERS = {
|
|
5614
|
+
objectivesSinceIssue: null,
|
|
5615
|
+
briefSectionsSinceIssue: null,
|
|
5616
|
+
documentationSinceIssue: null,
|
|
5617
|
+
briefRulesSincePr: null,
|
|
5618
|
+
agentBoxesRefusedSincePr: null
|
|
5619
|
+
};
|
|
5503
5620
|
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5504
5621
|
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5505
5622
|
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
@@ -5949,6 +6066,8 @@ function attemptFromEnv(value) {
|
|
|
5949
6066
|
function provenanceFor(input) {
|
|
5950
6067
|
if (input.provenance)
|
|
5951
6068
|
return input.provenance;
|
|
6069
|
+
if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
|
|
6070
|
+
return "unavailable";
|
|
5952
6071
|
if (input.env.role || input.env.task)
|
|
5953
6072
|
return "env_correlated";
|
|
5954
6073
|
return "unavailable";
|
|
@@ -5969,7 +6088,7 @@ function buildHeader(input) {
|
|
|
5969
6088
|
const role = isRole(input.env.role) ? input.env.role : "unattributed";
|
|
5970
6089
|
const round = roundFromEnv(input.env.round);
|
|
5971
6090
|
const subject = {
|
|
5972
|
-
issue: issueFromTask(input.env.task),
|
|
6091
|
+
issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
|
|
5973
6092
|
role,
|
|
5974
6093
|
...round !== undefined ? { round } : {},
|
|
5975
6094
|
...input.subject ?? {}
|
|
@@ -6250,8 +6369,8 @@ var ResolutionRecordSchema = z3.object({
|
|
|
6250
6369
|
consumedAt: isoTimestamp
|
|
6251
6370
|
}).strict();
|
|
6252
6371
|
// src/lib/diff-evidence.ts
|
|
6253
|
-
import { execFileSync as
|
|
6254
|
-
import { join as
|
|
6372
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
6373
|
+
import { join as join9, relative, resolve as resolve2 } from "node:path";
|
|
6255
6374
|
|
|
6256
6375
|
// src/lib/config.ts
|
|
6257
6376
|
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
@@ -6413,7 +6532,12 @@ var VinayaConfigSchema = z4.object({
|
|
|
6413
6532
|
allowlist: z4.array(z4.string().min(1)).optional(),
|
|
6414
6533
|
severity: z4.enum(["warning", "error"]).optional()
|
|
6415
6534
|
}).optional(),
|
|
6416
|
-
specGrandfather: z4.array(z4.string().min(1)).optional()
|
|
6535
|
+
specGrandfather: z4.array(z4.string().min(1)).optional(),
|
|
6536
|
+
specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
|
|
6537
|
+
message: "must be a repository-relative path, not an absolute one"
|
|
6538
|
+
}).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
|
|
6539
|
+
message: "must stay inside the repository — no `..` segment"
|
|
6540
|
+
})).optional()
|
|
6417
6541
|
}).optional(),
|
|
6418
6542
|
projects: z4.array(ProjectEntrySchema).optional(),
|
|
6419
6543
|
dispatch: z4.object({
|
|
@@ -6427,6 +6551,13 @@ var VinayaConfigSchema = z4.object({
|
|
|
6427
6551
|
securityThreshold: z4.string().min(1).optional(),
|
|
6428
6552
|
maxRounds: z4.number().optional()
|
|
6429
6553
|
}).optional(),
|
|
6554
|
+
gateCutovers: z4.object({
|
|
6555
|
+
objectivesSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6556
|
+
briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6557
|
+
documentationSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6558
|
+
briefRulesSincePr: z4.number().int().nonnegative().optional(),
|
|
6559
|
+
agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
|
|
6560
|
+
}).optional(),
|
|
6430
6561
|
prePush: z4.object({
|
|
6431
6562
|
alwaysRun: z4.array(z4.string()).optional()
|
|
6432
6563
|
}).optional(),
|
|
@@ -6564,6 +6695,18 @@ function resolveReviewPolicy(config) {
|
|
|
6564
6695
|
maxRounds
|
|
6565
6696
|
};
|
|
6566
6697
|
}
|
|
6698
|
+
function resolveGateCutovers(config) {
|
|
6699
|
+
const raw = config?.gateCutovers;
|
|
6700
|
+
if (!raw)
|
|
6701
|
+
return NO_GATE_CUTOVERS;
|
|
6702
|
+
return {
|
|
6703
|
+
objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
|
|
6704
|
+
briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
|
|
6705
|
+
documentationSinceIssue: raw.documentationSinceIssue ?? null,
|
|
6706
|
+
briefRulesSincePr: raw.briefRulesSincePr ?? null,
|
|
6707
|
+
agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
|
|
6708
|
+
};
|
|
6709
|
+
}
|
|
6567
6710
|
function resolveRuntimeDirSetting(config) {
|
|
6568
6711
|
return config?.runtimeDir ?? null;
|
|
6569
6712
|
}
|
|
@@ -6638,7 +6781,28 @@ function trustAnchorRepoFromRemoteUrl(url) {
|
|
|
6638
6781
|
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
6639
6782
|
}
|
|
6640
6783
|
var execFileAsync4 = promisify4(execFile4);
|
|
6784
|
+
function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
6785
|
+
const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
|
|
6786
|
+
if (!ref)
|
|
6787
|
+
return null;
|
|
6788
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
6789
|
+
return null;
|
|
6790
|
+
if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
|
|
6791
|
+
return null;
|
|
6792
|
+
return ref;
|
|
6793
|
+
}
|
|
6794
|
+
function readTrustAnchorConfigAtRef(ref) {
|
|
6795
|
+
const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6796
|
+
encoding: "utf-8",
|
|
6797
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
6798
|
+
timeout: 1e4
|
|
6799
|
+
});
|
|
6800
|
+
return Buffer.from(raw, "utf-8").toString("base64");
|
|
6801
|
+
}
|
|
6641
6802
|
function ghFetchTrustAnchorConfig() {
|
|
6803
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6804
|
+
if (probeRef)
|
|
6805
|
+
return readTrustAnchorConfigAtRef(probeRef);
|
|
6642
6806
|
const repo = trustAnchorRepo();
|
|
6643
6807
|
if (!repo)
|
|
6644
6808
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
@@ -6648,6 +6812,14 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6648
6812
|
});
|
|
6649
6813
|
}
|
|
6650
6814
|
async function ghFetchTrustAnchorConfigAsync() {
|
|
6815
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6816
|
+
if (probeRef) {
|
|
6817
|
+
const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6818
|
+
encoding: "utf-8",
|
|
6819
|
+
timeout: 1e4
|
|
6820
|
+
});
|
|
6821
|
+
return Buffer.from(stdout, "utf-8").toString("base64");
|
|
6822
|
+
}
|
|
6651
6823
|
const repo = await trustAnchorRepoAsync();
|
|
6652
6824
|
if (!repo)
|
|
6653
6825
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
@@ -6725,9 +6897,9 @@ function loadConfig() {
|
|
|
6725
6897
|
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
6726
6898
|
|
|
6727
6899
|
// src/lib/brief-assembly.ts
|
|
6728
|
-
import { execFileSync as
|
|
6729
|
-
import { existsSync as
|
|
6730
|
-
import { join as
|
|
6900
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
6901
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
|
|
6902
|
+
import { join as join4 } from "node:path";
|
|
6731
6903
|
|
|
6732
6904
|
// ../../packages/sources/src/commands.ts
|
|
6733
6905
|
var COMMANDS = [
|
|
@@ -6922,7 +7094,7 @@ var COMMANDS = [
|
|
|
6922
7094
|
details: [
|
|
6923
7095
|
"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.",
|
|
6924
7096
|
"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.",
|
|
6925
|
-
"`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."
|
|
7097
|
+
"`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."
|
|
6926
7098
|
],
|
|
6927
7099
|
status: "shipped"
|
|
6928
7100
|
},
|
|
@@ -7233,6 +7405,10 @@ var COMMANDS = [
|
|
|
7233
7405
|
flag: "--role <name>",
|
|
7234
7406
|
description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
|
|
7235
7407
|
},
|
|
7408
|
+
{
|
|
7409
|
+
flag: "--template <name>",
|
|
7410
|
+
description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
|
|
7411
|
+
},
|
|
7236
7412
|
{
|
|
7237
7413
|
flag: "--print",
|
|
7238
7414
|
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."
|
|
@@ -7568,13 +7744,47 @@ function packageRoot(moduleUrl) {
|
|
|
7568
7744
|
return dir;
|
|
7569
7745
|
}
|
|
7570
7746
|
|
|
7747
|
+
// src/commands/doctrine.ts
|
|
7748
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
7749
|
+
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
7750
|
+
import { dirname as dirname3, join as join3, sep } from "node:path";
|
|
7751
|
+
import matter2 from "gray-matter";
|
|
7752
|
+
var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
|
|
7753
|
+
function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
7754
|
+
return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
|
|
7755
|
+
}
|
|
7756
|
+
function gitToplevel(cwd) {
|
|
7757
|
+
try {
|
|
7758
|
+
return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
7759
|
+
encoding: "utf8",
|
|
7760
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
7761
|
+
}).trim();
|
|
7762
|
+
} catch {
|
|
7763
|
+
return null;
|
|
7764
|
+
}
|
|
7765
|
+
}
|
|
7766
|
+
function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
7767
|
+
const toplevel = gitToplevel(cwd);
|
|
7768
|
+
if (toplevel !== null) {
|
|
7769
|
+
const treeRoot = join3(toplevel, "aeg-root");
|
|
7770
|
+
if (existsSync3(join3(treeRoot, "roles")))
|
|
7771
|
+
return { root: treeRoot, source: "tree" };
|
|
7772
|
+
}
|
|
7773
|
+
const fromSource = !pkg.split(sep).includes("node_modules");
|
|
7774
|
+
const bundleRoot = fromSource ? join3(dirname3(dirname3(pkg)), "aeg-root") : join3(pkg, "aeg-root");
|
|
7775
|
+
return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
|
|
7776
|
+
}
|
|
7777
|
+
function hasDoctrineEntry(root) {
|
|
7778
|
+
return existsSync3(join3(root, ...ENTRY_SEGMENTS));
|
|
7779
|
+
}
|
|
7780
|
+
|
|
7571
7781
|
// src/lib/brief-assembly.ts
|
|
7572
7782
|
var PACKAGE_ROOT = packageRoot(import.meta.url);
|
|
7573
|
-
var PACKAGED_TEMPLATE_PATH =
|
|
7574
|
-
var TEMPLATE_PATH =
|
|
7783
|
+
var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
|
|
7784
|
+
var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
7575
7785
|
function git(args) {
|
|
7576
7786
|
try {
|
|
7577
|
-
return
|
|
7787
|
+
return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7578
7788
|
} catch {
|
|
7579
7789
|
return "";
|
|
7580
7790
|
}
|
|
@@ -7587,14 +7797,14 @@ function expandGlob(glob) {
|
|
|
7587
7797
|
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
7588
7798
|
|
|
7589
7799
|
// src/checks/registry.ts
|
|
7590
|
-
import { existsSync as
|
|
7591
|
-
import { join as
|
|
7592
|
-
var DIST_BIN_DIR =
|
|
7593
|
-
var SRC_BIN_DIR =
|
|
7594
|
-
var BIN_DIR =
|
|
7800
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
7801
|
+
import { join as join5 } from "node:path";
|
|
7802
|
+
var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
|
|
7803
|
+
var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
|
|
7804
|
+
var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
|
|
7595
7805
|
var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
|
|
7596
7806
|
function bin(name) {
|
|
7597
|
-
return
|
|
7807
|
+
return join5(BIN_DIR, `${name}${BIN_EXT}`);
|
|
7598
7808
|
}
|
|
7599
7809
|
var REGISTRY = [
|
|
7600
7810
|
[
|
|
@@ -8158,21 +8368,21 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
8158
8368
|
import {
|
|
8159
8369
|
closeSync as closeSync3,
|
|
8160
8370
|
constants as fsConstants3,
|
|
8161
|
-
existsSync as
|
|
8371
|
+
existsSync as existsSync7,
|
|
8162
8372
|
fstatSync as fstatSync2,
|
|
8163
8373
|
mkdirSync as mkdirSync3,
|
|
8164
8374
|
openSync as openSync3,
|
|
8165
|
-
readFileSync as
|
|
8375
|
+
readFileSync as readFileSync6,
|
|
8166
8376
|
renameSync as renameSync2,
|
|
8167
8377
|
writeSync as writeSync2
|
|
8168
8378
|
} from "node:fs";
|
|
8169
8379
|
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
8170
|
-
import { dirname as
|
|
8380
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
8171
8381
|
import { promisify as promisify5 } from "node:util";
|
|
8172
8382
|
|
|
8173
8383
|
// src/lib/run-paths.ts
|
|
8174
|
-
import { chmodSync, existsSync as
|
|
8175
|
-
import { dirname as
|
|
8384
|
+
import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
|
|
8385
|
+
import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
|
|
8176
8386
|
var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8177
8387
|
function isSafeRepoSegment(segment) {
|
|
8178
8388
|
return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
|
|
@@ -8183,7 +8393,7 @@ function repoSegment(repo) {
|
|
|
8183
8393
|
return `${repo.owner}-${repo.repo}`;
|
|
8184
8394
|
}
|
|
8185
8395
|
function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
|
|
8186
|
-
return
|
|
8396
|
+
return join6(home, "runtime", repoSegment(repo));
|
|
8187
8397
|
}
|
|
8188
8398
|
function resolveRuntimeDir(input) {
|
|
8189
8399
|
const local = resolveRuntimeDirSetting(input.localConfig);
|
|
@@ -8243,9 +8453,9 @@ function repoRootSync(start = process.cwd()) {
|
|
|
8243
8453
|
return null;
|
|
8244
8454
|
}
|
|
8245
8455
|
for (;; ) {
|
|
8246
|
-
if (
|
|
8456
|
+
if (existsSync6(join6(dir, ".git")))
|
|
8247
8457
|
return dir;
|
|
8248
|
-
const parent =
|
|
8458
|
+
const parent = dirname4(dir);
|
|
8249
8459
|
if (parent === dir)
|
|
8250
8460
|
return null;
|
|
8251
8461
|
dir = parent;
|
|
@@ -8260,16 +8470,17 @@ import {
|
|
|
8260
8470
|
mkdirSync as mkdirSync2,
|
|
8261
8471
|
openSync as openSync2,
|
|
8262
8472
|
linkSync,
|
|
8263
|
-
readFileSync as
|
|
8473
|
+
readFileSync as readFileSync5,
|
|
8264
8474
|
renameSync,
|
|
8265
8475
|
statSync,
|
|
8266
8476
|
unlinkSync,
|
|
8477
|
+
utimesSync,
|
|
8267
8478
|
writeFileSync as writeFileSync2,
|
|
8268
8479
|
writeSync
|
|
8269
8480
|
} from "node:fs";
|
|
8270
8481
|
import { randomUUID } from "node:crypto";
|
|
8271
8482
|
import { homedir as homedir2 } from "node:os";
|
|
8272
|
-
import { dirname as
|
|
8483
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
8273
8484
|
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
8274
8485
|
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
8275
8486
|
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
@@ -8285,7 +8496,7 @@ function isEnoent(err) {
|
|
|
8285
8496
|
var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
|
|
8286
8497
|
function tryCreateLock(lockPath, token) {
|
|
8287
8498
|
try {
|
|
8288
|
-
mkdirSync2(
|
|
8499
|
+
mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
|
|
8289
8500
|
const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
|
|
8290
8501
|
try {
|
|
8291
8502
|
writeSync(fd, `${token}
|
|
@@ -8347,9 +8558,30 @@ function acquireDrainLock(lockPath) {
|
|
|
8347
8558
|
unlinkSync(claimed);
|
|
8348
8559
|
return tryCreateLock(lockPath, token) ? token : null;
|
|
8349
8560
|
}
|
|
8561
|
+
function renewDrainLock(lockPath, token) {
|
|
8562
|
+
let holder;
|
|
8563
|
+
try {
|
|
8564
|
+
holder = readFileSync5(lockPath, "utf8").trim();
|
|
8565
|
+
} catch (err) {
|
|
8566
|
+
if (!isEnoent(err))
|
|
8567
|
+
throw err;
|
|
8568
|
+
return false;
|
|
8569
|
+
}
|
|
8570
|
+
if (holder !== token)
|
|
8571
|
+
return false;
|
|
8572
|
+
const now = new Date;
|
|
8573
|
+
try {
|
|
8574
|
+
utimesSync(lockPath, now, now);
|
|
8575
|
+
} catch (err) {
|
|
8576
|
+
if (!isEnoent(err))
|
|
8577
|
+
throw err;
|
|
8578
|
+
return false;
|
|
8579
|
+
}
|
|
8580
|
+
return true;
|
|
8581
|
+
}
|
|
8350
8582
|
function releaseDrainLock(lockPath, token) {
|
|
8351
8583
|
try {
|
|
8352
|
-
const holder =
|
|
8584
|
+
const holder = readFileSync5(lockPath, "utf8").trim();
|
|
8353
8585
|
if (holder !== token)
|
|
8354
8586
|
return;
|
|
8355
8587
|
unlinkSync(lockPath);
|
|
@@ -8366,68 +8598,205 @@ class WebhookDrainError extends Error {
|
|
|
8366
8598
|
this.code = code;
|
|
8367
8599
|
}
|
|
8368
8600
|
}
|
|
8601
|
+
function backupPathFor(queuePath) {
|
|
8602
|
+
return queuePath.replace(/\.ndjson$/, ".1.ndjson");
|
|
8603
|
+
}
|
|
8604
|
+
function drainingPathFor(queuePath) {
|
|
8605
|
+
return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
|
|
8606
|
+
}
|
|
8607
|
+
function rejectedPathFor(queuePath) {
|
|
8608
|
+
return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
|
|
8609
|
+
}
|
|
8610
|
+
var rejectionWarnedThisProcess = false;
|
|
8611
|
+
function warnRejectionOnce(message) {
|
|
8612
|
+
if (rejectionWarnedThisProcess)
|
|
8613
|
+
return;
|
|
8614
|
+
rejectionWarnedThisProcess = true;
|
|
8615
|
+
try {
|
|
8616
|
+
process.stderr.write(message);
|
|
8617
|
+
} catch {}
|
|
8618
|
+
}
|
|
8619
|
+
function queueLines(buf) {
|
|
8620
|
+
const lines = [];
|
|
8621
|
+
let start = 0;
|
|
8622
|
+
for (let i = 0;i < buf.byteLength; i++) {
|
|
8623
|
+
if (buf[i] !== 10)
|
|
8624
|
+
continue;
|
|
8625
|
+
if (i > start)
|
|
8626
|
+
lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
|
|
8627
|
+
start = i + 1;
|
|
8628
|
+
}
|
|
8629
|
+
if (start < buf.byteLength)
|
|
8630
|
+
lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
|
|
8631
|
+
return lines;
|
|
8632
|
+
}
|
|
8633
|
+
function removeQueueHead(path, cut) {
|
|
8634
|
+
const remaining = readFileSync5(path);
|
|
8635
|
+
writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
|
|
8636
|
+
}
|
|
8637
|
+
function queueBucketSize(path) {
|
|
8638
|
+
let lstat;
|
|
8639
|
+
try {
|
|
8640
|
+
lstat = lstatSync(path);
|
|
8641
|
+
} catch (err) {
|
|
8642
|
+
if (!isEnoent(err))
|
|
8643
|
+
throw err;
|
|
8644
|
+
}
|
|
8645
|
+
if (lstat === undefined)
|
|
8646
|
+
return null;
|
|
8647
|
+
if (!lstat.isFile()) {
|
|
8648
|
+
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}`);
|
|
8649
|
+
}
|
|
8650
|
+
return Number(lstat.size);
|
|
8651
|
+
}
|
|
8652
|
+
function readQueueFile(path) {
|
|
8653
|
+
if (queueBucketSize(path) === null)
|
|
8654
|
+
return null;
|
|
8655
|
+
return readFileSync5(path);
|
|
8656
|
+
}
|
|
8657
|
+
function rejectLine(rejectedPath, reason, status, identity, raw) {
|
|
8658
|
+
const record = JSON.stringify({
|
|
8659
|
+
rejected_at: new Date().toISOString(),
|
|
8660
|
+
status,
|
|
8661
|
+
reason,
|
|
8662
|
+
identity,
|
|
8663
|
+
bytes: Buffer.byteLength(raw, "utf8"),
|
|
8664
|
+
raw
|
|
8665
|
+
});
|
|
8666
|
+
const failure = appendHardenedLine(rejectedPath, `${record}
|
|
8667
|
+
`);
|
|
8668
|
+
if (failure !== null) {
|
|
8669
|
+
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`);
|
|
8670
|
+
}
|
|
8671
|
+
warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
|
|
8672
|
+
`);
|
|
8673
|
+
}
|
|
8674
|
+
async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
|
|
8675
|
+
const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
|
|
8676
|
+
let response;
|
|
8677
|
+
try {
|
|
8678
|
+
response = await fetch(webhookUrl, {
|
|
8679
|
+
method: "POST",
|
|
8680
|
+
headers: { "content-type": "application/x-ndjson", ...headers },
|
|
8681
|
+
body,
|
|
8682
|
+
signal: AbortSignal.timeout(fetchTimeoutMs)
|
|
8683
|
+
});
|
|
8684
|
+
} catch (err) {
|
|
8685
|
+
const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
|
|
8686
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
|
|
8687
|
+
}
|
|
8688
|
+
if (!response.ok) {
|
|
8689
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
|
|
8690
|
+
}
|
|
8691
|
+
}
|
|
8692
|
+
async function drainQueueFile(args) {
|
|
8693
|
+
const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
|
|
8694
|
+
const buf = readQueueFile(path);
|
|
8695
|
+
if (buf === null || buf.byteLength === 0)
|
|
8696
|
+
return;
|
|
8697
|
+
const lines = queueLines(buf);
|
|
8698
|
+
if (lines.length === 0) {
|
|
8699
|
+
removeQueueHead(path, buf.byteLength);
|
|
8700
|
+
return;
|
|
8701
|
+
}
|
|
8702
|
+
let removed = 0;
|
|
8703
|
+
let pendingEnd = 0;
|
|
8704
|
+
let chunk = [];
|
|
8705
|
+
let chunkBytes = 0;
|
|
8706
|
+
const deliverChunk = async () => {
|
|
8707
|
+
const body = `${chunk.join(`
|
|
8708
|
+
`)}
|
|
8709
|
+
`;
|
|
8710
|
+
args.keepLock();
|
|
8711
|
+
await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
|
|
8712
|
+
totals.chunks += 1;
|
|
8713
|
+
totals.lineCount += chunk.length;
|
|
8714
|
+
totals.bytes += Buffer.byteLength(body, "utf8");
|
|
8715
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8716
|
+
removed = pendingEnd;
|
|
8717
|
+
chunk = [];
|
|
8718
|
+
chunkBytes = 0;
|
|
8719
|
+
};
|
|
8720
|
+
const setAside = async (reason, status, identity, line) => {
|
|
8721
|
+
if (chunk.length > 0)
|
|
8722
|
+
await deliverChunk();
|
|
8723
|
+
rejectLine(rejectedPath, reason, status, identity, line.raw);
|
|
8724
|
+
totals.rejected += 1;
|
|
8725
|
+
pendingEnd = line.end;
|
|
8726
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8727
|
+
removed = pendingEnd;
|
|
8728
|
+
};
|
|
8729
|
+
for (const line of lines) {
|
|
8730
|
+
const record = classifyStoredLine(line.raw, homedir2());
|
|
8731
|
+
if (record.status !== "ok") {
|
|
8732
|
+
await setAside(record.reason, record.status, record.identity, line);
|
|
8733
|
+
continue;
|
|
8734
|
+
}
|
|
8735
|
+
const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
|
|
8736
|
+
if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
|
|
8737
|
+
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);
|
|
8738
|
+
continue;
|
|
8739
|
+
}
|
|
8740
|
+
if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
|
|
8741
|
+
await deliverChunk();
|
|
8742
|
+
chunk.push(record.postLine);
|
|
8743
|
+
chunkBytes += lineBytes;
|
|
8744
|
+
pendingEnd = line.end;
|
|
8745
|
+
}
|
|
8746
|
+
pendingEnd = buf.byteLength;
|
|
8747
|
+
if (chunk.length > 0) {
|
|
8748
|
+
await deliverChunk();
|
|
8749
|
+
return;
|
|
8750
|
+
}
|
|
8751
|
+
if (pendingEnd > removed)
|
|
8752
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8753
|
+
}
|
|
8754
|
+
async function drainRenamedAside(args, livePath, source) {
|
|
8755
|
+
args.keepLock();
|
|
8756
|
+
const draining = drainingPathFor(livePath);
|
|
8757
|
+
try {
|
|
8758
|
+
renameSync(source, draining);
|
|
8759
|
+
} catch (err) {
|
|
8760
|
+
if (isEnoent(err))
|
|
8761
|
+
return;
|
|
8762
|
+
throw err;
|
|
8763
|
+
}
|
|
8764
|
+
await drainQueueFile({ ...args, path: draining });
|
|
8765
|
+
unlinkSync(draining);
|
|
8766
|
+
}
|
|
8369
8767
|
async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
|
|
8370
8768
|
const resolved = await resolveRepo();
|
|
8371
8769
|
const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
|
|
8372
|
-
const outboxRoot = () =>
|
|
8770
|
+
const outboxRoot = () => join7(GLOBAL_VINAYA_HOME, "outbox");
|
|
8373
8771
|
const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
|
|
8374
8772
|
const lockPath = `${path}.flush-lock`;
|
|
8375
8773
|
const lockToken = acquireDrainLock(lockPath);
|
|
8774
|
+
const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
|
|
8376
8775
|
if (lockToken === null)
|
|
8377
|
-
return { flushed: false };
|
|
8776
|
+
return { flushed: false, ...totals };
|
|
8378
8777
|
try {
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
const
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
throw new WebhookDrainError("log-webhook-drain-corrupt-line", `log webhook drain: outbox line ${i} failed schema re-validation — ${record.reason}`);
|
|
8402
|
-
}
|
|
8403
|
-
postLines.push(record.postLine);
|
|
8404
|
-
}
|
|
8405
|
-
const body = `${postLines.join(`
|
|
8406
|
-
`)}
|
|
8407
|
-
`;
|
|
8408
|
-
const bytes = Buffer.byteLength(body, "utf8");
|
|
8409
|
-
if (bytes > MAX_WEBHOOK_BODY_BYTES) {
|
|
8410
|
-
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.`);
|
|
8411
|
-
}
|
|
8412
|
-
let response;
|
|
8413
|
-
try {
|
|
8414
|
-
response = await fetch(webhookUrl, {
|
|
8415
|
-
method: "POST",
|
|
8416
|
-
headers: { "content-type": "application/x-ndjson", ...headers },
|
|
8417
|
-
body,
|
|
8418
|
-
signal: AbortSignal.timeout(fetchTimeoutMs)
|
|
8419
|
-
});
|
|
8420
|
-
} catch (err) {
|
|
8421
|
-
const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
|
|
8422
|
-
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed: ${reason}`);
|
|
8423
|
-
}
|
|
8424
|
-
if (!response.ok) {
|
|
8425
|
-
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}`);
|
|
8426
|
-
}
|
|
8427
|
-
const liveNow = readFileSync4(path);
|
|
8428
|
-
const tail = liveNow.subarray(Math.min(startOffset, liveNow.byteLength));
|
|
8429
|
-
writeFileSync2(path, tail);
|
|
8430
|
-
return { flushed: true, lineCount: postLines.length, bytes };
|
|
8778
|
+
const keepLock = () => {
|
|
8779
|
+
if (renewDrainLock(lockPath, lockToken))
|
|
8780
|
+
return;
|
|
8781
|
+
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`);
|
|
8782
|
+
};
|
|
8783
|
+
const shared = {
|
|
8784
|
+
rejectedPath: rejectedPathFor(path),
|
|
8785
|
+
webhookUrl,
|
|
8786
|
+
headers,
|
|
8787
|
+
fetchTimeoutMs,
|
|
8788
|
+
totals,
|
|
8789
|
+
keepLock
|
|
8790
|
+
};
|
|
8791
|
+
const draining = drainingPathFor(path);
|
|
8792
|
+
if (queueBucketSize(draining) !== null) {
|
|
8793
|
+
keepLock();
|
|
8794
|
+
await drainQueueFile({ ...shared, path: draining });
|
|
8795
|
+
unlinkSync(draining);
|
|
8796
|
+
}
|
|
8797
|
+
await drainRenamedAside(shared, path, backupPathFor(path));
|
|
8798
|
+
await drainRenamedAside(shared, path, path);
|
|
8799
|
+
return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
|
|
8431
8800
|
} finally {
|
|
8432
8801
|
releaseDrainLock(lockPath, lockToken);
|
|
8433
8802
|
}
|
|
@@ -8510,7 +8879,7 @@ async function defaultResolveLogDestination(repo, env) {
|
|
|
8510
8879
|
trustAnchorConfig: unattended ? await processTrustAnchor() : null,
|
|
8511
8880
|
unattended,
|
|
8512
8881
|
env,
|
|
8513
|
-
defaultFolder:
|
|
8882
|
+
defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
|
|
8514
8883
|
repoRoot: repoRootSync()
|
|
8515
8884
|
});
|
|
8516
8885
|
}
|
|
@@ -8525,7 +8894,7 @@ async function resolveDoctrine(cwd, vinayaVersion) {
|
|
|
8525
8894
|
} catch (err) {
|
|
8526
8895
|
return isEnoent2(err) ? "unknown" : vinayaVersion;
|
|
8527
8896
|
}
|
|
8528
|
-
if (!
|
|
8897
|
+
if (!existsSync7(join8(toplevel, "aeg-root", "roles")))
|
|
8529
8898
|
return vinayaVersion;
|
|
8530
8899
|
try {
|
|
8531
8900
|
const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
|
|
@@ -8534,9 +8903,99 @@ async function resolveDoctrine(cwd, vinayaVersion) {
|
|
|
8534
8903
|
return vinayaVersion;
|
|
8535
8904
|
}
|
|
8536
8905
|
}
|
|
8906
|
+
var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
8907
|
+
function taskRefFromBranch2(branch) {
|
|
8908
|
+
const backlog = /^task\/issue-(\d+)$/.exec(branch);
|
|
8909
|
+
if (backlog) {
|
|
8910
|
+
const issue = Number(backlog[1]);
|
|
8911
|
+
return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
|
|
8912
|
+
}
|
|
8913
|
+
const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
|
|
8914
|
+
if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
|
|
8915
|
+
return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
|
|
8916
|
+
}
|
|
8917
|
+
return null;
|
|
8918
|
+
}
|
|
8919
|
+
var TRANCHE_ISSUE_LIST_LIMIT = 200;
|
|
8920
|
+
async function issueForTrancheTask(tranche, taskId, cwd, repo) {
|
|
8921
|
+
let stdout;
|
|
8922
|
+
try {
|
|
8923
|
+
({ stdout } = await execFileAsync5("gh", [
|
|
8924
|
+
"issue",
|
|
8925
|
+
"list",
|
|
8926
|
+
"--state",
|
|
8927
|
+
"all",
|
|
8928
|
+
"--label",
|
|
8929
|
+
`vinaya/tranche:${tranche}`,
|
|
8930
|
+
"--json",
|
|
8931
|
+
"number,title,labels",
|
|
8932
|
+
"--limit",
|
|
8933
|
+
String(TRANCHE_ISSUE_LIST_LIMIT),
|
|
8934
|
+
...repo === null ? [] : ["--repo", repo]
|
|
8935
|
+
], {
|
|
8936
|
+
cwd,
|
|
8937
|
+
encoding: "utf8",
|
|
8938
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
8939
|
+
timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
|
|
8940
|
+
killSignal: "SIGKILL"
|
|
8941
|
+
}));
|
|
8942
|
+
} catch {
|
|
8943
|
+
return null;
|
|
8944
|
+
}
|
|
8945
|
+
let issues;
|
|
8946
|
+
try {
|
|
8947
|
+
issues = JSON.parse(stdout);
|
|
8948
|
+
} catch {
|
|
8949
|
+
return null;
|
|
8950
|
+
}
|
|
8951
|
+
for (const issue of issues) {
|
|
8952
|
+
const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
|
|
8953
|
+
if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
|
|
8954
|
+
return issue.number;
|
|
8955
|
+
}
|
|
8956
|
+
return null;
|
|
8957
|
+
}
|
|
8958
|
+
async function confirmBacklogIssue(issue, cwd, repo) {
|
|
8959
|
+
let stdout;
|
|
8960
|
+
try {
|
|
8961
|
+
({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
|
|
8962
|
+
cwd,
|
|
8963
|
+
encoding: "utf8",
|
|
8964
|
+
timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
|
|
8965
|
+
killSignal: "SIGKILL"
|
|
8966
|
+
}));
|
|
8967
|
+
} catch (err) {
|
|
8968
|
+
const stderr = typeof err.stderr === "string" ? err.stderr : "";
|
|
8969
|
+
return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
|
|
8970
|
+
}
|
|
8971
|
+
try {
|
|
8972
|
+
return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
|
|
8973
|
+
} catch {
|
|
8974
|
+
return "unknown";
|
|
8975
|
+
}
|
|
8976
|
+
}
|
|
8977
|
+
async function resolveBranchIssue(cwd, env = process.env, repo = null) {
|
|
8978
|
+
let branch;
|
|
8979
|
+
try {
|
|
8980
|
+
branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
|
|
8981
|
+
encoding: "utf8",
|
|
8982
|
+
timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
|
|
8983
|
+
killSignal: "SIGKILL"
|
|
8984
|
+
})).stdout.trim();
|
|
8985
|
+
} catch {
|
|
8986
|
+
return null;
|
|
8987
|
+
}
|
|
8988
|
+
const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
|
|
8989
|
+
const ref = taskRefFromBranch2(named);
|
|
8990
|
+
if (ref === null)
|
|
8991
|
+
return null;
|
|
8992
|
+
if (ref.kind === "tranche")
|
|
8993
|
+
return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
|
|
8994
|
+
return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
|
|
8995
|
+
}
|
|
8537
8996
|
function readVinayaVersion() {
|
|
8538
8997
|
try {
|
|
8539
|
-
const pkg = JSON.parse(
|
|
8998
|
+
const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
8540
8999
|
return pkg.version ?? "unknown";
|
|
8541
9000
|
} catch {
|
|
8542
9001
|
return "unknown";
|
|
@@ -8546,10 +9005,15 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
|
8546
9005
|
function isSafeRepoSegment3(segment) {
|
|
8547
9006
|
return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
|
|
8548
9007
|
}
|
|
9008
|
+
function safeRepoSlug(repo) {
|
|
9009
|
+
if (repo === null)
|
|
9010
|
+
return null;
|
|
9011
|
+
return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
|
|
9012
|
+
}
|
|
8549
9013
|
function outboxPathFor(deps, repo, issue) {
|
|
8550
9014
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
8551
9015
|
const fileName = `${issue ?? "none"}.ndjson`;
|
|
8552
|
-
return
|
|
9016
|
+
return join8(deps.outboxRoot(), dirName, fileName);
|
|
8553
9017
|
}
|
|
8554
9018
|
function hostFromEnv(env) {
|
|
8555
9019
|
if (env.GITHUB_ACTIONS)
|
|
@@ -8567,9 +9031,21 @@ function defaultStderr(message) {
|
|
|
8567
9031
|
warnedThisProcess = true;
|
|
8568
9032
|
process.stderr.write(message);
|
|
8569
9033
|
}
|
|
9034
|
+
var branchIssueFallbackEnabled = true;
|
|
9035
|
+
var branchIssueByCwd = new Map;
|
|
9036
|
+
function branchIssueRead(key, read, shared) {
|
|
9037
|
+
if (!shared)
|
|
9038
|
+
return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
9039
|
+
const cached = branchIssueByCwd.get(key);
|
|
9040
|
+
if (cached !== undefined)
|
|
9041
|
+
return cached;
|
|
9042
|
+
const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
9043
|
+
branchIssueByCwd.set(key, reading);
|
|
9044
|
+
return reading;
|
|
9045
|
+
}
|
|
8570
9046
|
function defaultDeps() {
|
|
8571
9047
|
return {
|
|
8572
|
-
outboxRoot: () =>
|
|
9048
|
+
outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
|
|
8573
9049
|
home: () => homedir3(),
|
|
8574
9050
|
hostname: () => osHostname(),
|
|
8575
9051
|
cwd: () => process.cwd(),
|
|
@@ -8592,10 +9068,28 @@ function guardedAppendOpen(path) {
|
|
|
8592
9068
|
return;
|
|
8593
9069
|
}
|
|
8594
9070
|
}
|
|
9071
|
+
function appendHardenedLine(path, line) {
|
|
9072
|
+
try {
|
|
9073
|
+
mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
|
|
9074
|
+
const fd = guardedAppendOpen(path);
|
|
9075
|
+
if (fd === undefined)
|
|
9076
|
+
return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
|
|
9077
|
+
try {
|
|
9078
|
+
if (!fstatSync2(fd).isFile())
|
|
9079
|
+
return `target is not a regular file: ${path}`;
|
|
9080
|
+
writeSync2(fd, line);
|
|
9081
|
+
} finally {
|
|
9082
|
+
closeSync3(fd);
|
|
9083
|
+
}
|
|
9084
|
+
return null;
|
|
9085
|
+
} catch (err) {
|
|
9086
|
+
return err instanceof Error ? err.message : String(err);
|
|
9087
|
+
}
|
|
9088
|
+
}
|
|
8595
9089
|
function reportRotationOverflow(backupPath, warn) {
|
|
8596
9090
|
let raw;
|
|
8597
9091
|
try {
|
|
8598
|
-
raw =
|
|
9092
|
+
raw = readFileSync6(backupPath, "utf8");
|
|
8599
9093
|
} catch {
|
|
8600
9094
|
return;
|
|
8601
9095
|
}
|
|
@@ -8618,7 +9112,7 @@ function reportRotationOverflow(backupPath, warn) {
|
|
|
8618
9112
|
}
|
|
8619
9113
|
function appendLine(path, line, warn) {
|
|
8620
9114
|
try {
|
|
8621
|
-
mkdirSync3(
|
|
9115
|
+
mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
|
|
8622
9116
|
let fd = guardedAppendOpen(path);
|
|
8623
9117
|
if (fd === undefined) {
|
|
8624
9118
|
warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
|
|
@@ -8659,7 +9153,11 @@ function appendLine(path, line, warn) {
|
|
|
8659
9153
|
}
|
|
8660
9154
|
}
|
|
8661
9155
|
function createLogSink(overrides = {}) {
|
|
8662
|
-
const deps = {
|
|
9156
|
+
const deps = {
|
|
9157
|
+
...defaultDeps(),
|
|
9158
|
+
resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
|
|
9159
|
+
...overrides
|
|
9160
|
+
};
|
|
8663
9161
|
const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
|
|
8664
9162
|
const processId = randomUUID2();
|
|
8665
9163
|
let seq = 0;
|
|
@@ -8679,6 +9177,19 @@ function createLogSink(overrides = {}) {
|
|
|
8679
9177
|
}
|
|
8680
9178
|
return doctrineCache;
|
|
8681
9179
|
};
|
|
9180
|
+
const readerIsReal = overrides.resolveBranchIssue === undefined;
|
|
9181
|
+
let ownBranchIssue;
|
|
9182
|
+
const branchIssueOnce = (repo) => {
|
|
9183
|
+
if (!branchIssueFallbackEnabled)
|
|
9184
|
+
return Promise.resolve(null);
|
|
9185
|
+
const slug = safeRepoSlug(repo);
|
|
9186
|
+
const read = () => deps.resolveBranchIssue(slug);
|
|
9187
|
+
if (readerIsReal)
|
|
9188
|
+
return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
|
|
9189
|
+
if (ownBranchIssue === undefined)
|
|
9190
|
+
ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
|
|
9191
|
+
return ownBranchIssue;
|
|
9192
|
+
};
|
|
8682
9193
|
let resolveRepoCache;
|
|
8683
9194
|
const resolveRepoOnce = () => {
|
|
8684
9195
|
if (resolveRepoCache === undefined)
|
|
@@ -8701,6 +9212,7 @@ function createLogSink(overrides = {}) {
|
|
|
8701
9212
|
};
|
|
8702
9213
|
let drainChain = Promise.resolve();
|
|
8703
9214
|
const pendingWrites = new Set;
|
|
9215
|
+
let writeChain = Promise.resolve();
|
|
8704
9216
|
const scheduleWebhookDrain = (issue, url, headers) => {
|
|
8705
9217
|
drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
|
|
8706
9218
|
return;
|
|
@@ -8723,7 +9235,14 @@ function createLogSink(overrides = {}) {
|
|
|
8723
9235
|
attempt: env.VINAYA_ATTEMPT,
|
|
8724
9236
|
parent: env.VINAYA_PARENT_EVENT
|
|
8725
9237
|
};
|
|
8726
|
-
const
|
|
9238
|
+
const write = async () => {
|
|
9239
|
+
const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
|
|
9240
|
+
if (resolvedDestination.kind === "none") {
|
|
9241
|
+
warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
|
|
9242
|
+
`);
|
|
9243
|
+
return;
|
|
9244
|
+
}
|
|
9245
|
+
const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
|
|
8727
9246
|
const header = buildHeader({
|
|
8728
9247
|
now,
|
|
8729
9248
|
runId,
|
|
@@ -8734,15 +9253,11 @@ function createLogSink(overrides = {}) {
|
|
|
8734
9253
|
host,
|
|
8735
9254
|
hostname: deps.hostname(),
|
|
8736
9255
|
env: envFields,
|
|
9256
|
+
branchIssue,
|
|
8737
9257
|
eventId: randomUUID2(),
|
|
8738
9258
|
processId,
|
|
8739
9259
|
inputVersions: deps.inputVersions()
|
|
8740
9260
|
});
|
|
8741
|
-
if (resolvedDestination.kind === "none") {
|
|
8742
|
-
warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
|
|
8743
|
-
`);
|
|
8744
|
-
return;
|
|
8745
|
-
}
|
|
8746
9261
|
const full = { ...e, ...header };
|
|
8747
9262
|
const parsed = LogEventSchema.safeParse(full);
|
|
8748
9263
|
if (!parsed.success) {
|
|
@@ -8759,10 +9274,12 @@ function createLogSink(overrides = {}) {
|
|
|
8759
9274
|
} else {
|
|
8760
9275
|
appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
|
|
8761
9276
|
}
|
|
8762
|
-
}
|
|
9277
|
+
};
|
|
9278
|
+
const written = writeChain.then(write).catch((err) => {
|
|
8763
9279
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8764
9280
|
`);
|
|
8765
9281
|
});
|
|
9282
|
+
writeChain = written;
|
|
8766
9283
|
pendingWrites.add(written);
|
|
8767
9284
|
written.finally(() => pendingWrites.delete(written));
|
|
8768
9285
|
} catch (err) {
|
|
@@ -8838,7 +9355,7 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
8838
9355
|
function fileDiffAgainst(ref, path) {
|
|
8839
9356
|
let out;
|
|
8840
9357
|
try {
|
|
8841
|
-
out =
|
|
9358
|
+
out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
8842
9359
|
encoding: "utf8",
|
|
8843
9360
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8844
9361
|
}).trim();
|
|
@@ -8849,7 +9366,7 @@ function fileDiffAgainst(ref, path) {
|
|
|
8849
9366
|
}
|
|
8850
9367
|
function revParse(ref) {
|
|
8851
9368
|
try {
|
|
8852
|
-
return
|
|
9369
|
+
return execFileSync6("git", ["rev-parse", "--verify", ref], {
|
|
8853
9370
|
encoding: "utf8",
|
|
8854
9371
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8855
9372
|
}).trim();
|
|
@@ -8859,7 +9376,7 @@ function revParse(ref) {
|
|
|
8859
9376
|
}
|
|
8860
9377
|
function repoRoot() {
|
|
8861
9378
|
try {
|
|
8862
|
-
return
|
|
9379
|
+
return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
|
|
8863
9380
|
encoding: "utf8",
|
|
8864
9381
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8865
9382
|
}).trim();
|
|
@@ -8870,7 +9387,7 @@ function repoRoot() {
|
|
|
8870
9387
|
function changedFiles(base) {
|
|
8871
9388
|
let out;
|
|
8872
9389
|
try {
|
|
8873
|
-
out =
|
|
9390
|
+
out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
8874
9391
|
encoding: "utf8",
|
|
8875
9392
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8876
9393
|
}).trim();
|
|
@@ -8895,7 +9412,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
|
|
|
8895
9412
|
const relPaths = changedFiles(ref);
|
|
8896
9413
|
if (relPaths === null)
|
|
8897
9414
|
continue;
|
|
8898
|
-
return { base: ref, root, files: relPaths.map((p) =>
|
|
9415
|
+
return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
|
|
8899
9416
|
}
|
|
8900
9417
|
return null;
|
|
8901
9418
|
}
|
|
@@ -8937,14 +9454,14 @@ function isTestFile(path) {
|
|
|
8937
9454
|
function collectAllPaths(dir, out = []) {
|
|
8938
9455
|
let entries;
|
|
8939
9456
|
try {
|
|
8940
|
-
entries =
|
|
9457
|
+
entries = readdirSync3(dir);
|
|
8941
9458
|
} catch {
|
|
8942
9459
|
return out;
|
|
8943
9460
|
}
|
|
8944
9461
|
for (const name of entries) {
|
|
8945
9462
|
if (EXCLUDED_DIRS.has(name))
|
|
8946
9463
|
continue;
|
|
8947
|
-
const full =
|
|
9464
|
+
const full = join10(dir, name);
|
|
8948
9465
|
let isDir;
|
|
8949
9466
|
try {
|
|
8950
9467
|
isDir = statSync2(full).isDirectory();
|
|
@@ -8960,7 +9477,7 @@ function collectAllPaths(dir, out = []) {
|
|
|
8960
9477
|
function main() {
|
|
8961
9478
|
const allPaths = WORKSPACE_DIRS.flatMap((d) => collectAllPaths(d)).map((p) => p.split("\\").join("/"));
|
|
8962
9479
|
const knownPaths = new Set(allPaths);
|
|
8963
|
-
const sourceFiles = allPaths.filter((p) => SOURCE_EXTENSIONS.some((ext) => p.endsWith(ext))).filter((p) => !isTestFile(p)).map((p) => ({ path: p, content:
|
|
9480
|
+
const sourceFiles = allPaths.filter((p) => SOURCE_EXTENSIONS.some((ext) => p.endsWith(ext))).filter((p) => !isTestFile(p)).map((p) => ({ path: p, content: readFileSync7(p, "utf8") }));
|
|
8964
9481
|
const findings = findWorkspaceEscapes(sourceFiles, knownPaths, WORKSPACE_DIRS);
|
|
8965
9482
|
const reportable = findingsInThisDiff(findings);
|
|
8966
9483
|
console.log(`${CHECK_NAME}: ${sourceFiles.length} source file(s) scanned under ${WORKSPACE_DIRS.join("/")}; ${findings.length} finding(s), ${reportable.length} in this diff`);
|