@attalabs/vinaya 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/aeg-root/contracts/principal-operator.md +18 -5
- package/aeg-root/roles/developer/reference.md +3 -3
- package/aeg-root/roles/operator.md +69 -16
- package/aeg-root/roles/planner/reference.md +1 -1
- package/aeg-root/roles/tranche-archivist.md +1 -0
- package/aeg-root/skills/aeg-context-packets/SKILL.md +1 -1
- package/aeg-root/skills/aeg-context-packets/examples/operator-start.md +1 -1
- package/aeg-root/templates/pr-report-template.md +7 -2
- package/dist/checks/bin/check-body-bare-digits.js +340 -101
- package/dist/checks/bin/check-branch-topology.js +184 -105
- package/dist/checks/bin/check-brief-shape.js +333 -94
- package/dist/checks/bin/check-changeset-coverage.js +1028 -248
- package/dist/checks/bin/check-ci-shard-coverage.js +82 -0
- package/dist/checks/bin/check-closes-n.js +184 -105
- package/dist/checks/bin/check-coherence.js +345 -145
- package/dist/checks/bin/check-dead-branch-push.js +179 -59
- package/dist/checks/bin/check-dispatch-readiness.js +350 -150
- package/dist/checks/bin/check-doc-coverage-push.js +1011 -231
- package/dist/checks/bin/check-doc-coverage.js +1015 -235
- package/dist/checks/bin/check-doctrine-no-procedures.js +333 -94
- package/dist/checks/bin/check-doctrine-portability.js +1013 -233
- package/dist/checks/bin/check-evidence-fresh.js +1010 -222
- package/dist/checks/bin/check-exec-bits.js +1009 -229
- package/dist/checks/bin/check-first-push-dispatch.js +343 -145
- package/dist/checks/bin/check-issue-assignment.js +186 -107
- package/dist/checks/bin/check-issue-milestone-attach.js +176 -56
- package/dist/checks/bin/check-issue-objectives-numbering.js +176 -56
- package/dist/checks/bin/check-issue-parts-coverage.js +176 -56
- package/dist/checks/bin/check-issue-surface-globs.js +363 -143
- package/dist/checks/bin/check-issue-title-grammar.js +176 -56
- package/dist/checks/bin/check-issue-tranche-label.js +176 -56
- package/dist/checks/bin/check-main-branch-refusal.js +176 -56
- package/dist/checks/bin/check-no-disk-state.js +176 -56
- package/dist/checks/bin/check-pr-premise-reassert.js +333 -92
- package/dist/checks/bin/check-pr-report-density.js +176 -56
- package/dist/checks/bin/check-principal-test-plan-wait.js +176 -54
- package/dist/checks/bin/check-quoted-command.js +999 -217
- package/dist/checks/bin/check-reader-resolvable-prose.js +1011 -229
- package/dist/checks/bin/check-registry-gates.js +186 -56
- package/dist/checks/bin/check-retired-vocabulary.js +997 -215
- package/dist/checks/bin/check-review-gate.js +403 -203
- package/dist/checks/bin/check-single-plan-pr.js +176 -56
- package/dist/checks/bin/check-surface-scope.js +184 -105
- package/dist/checks/bin/check-test-plan.js +176 -54
- package/dist/checks/bin/check-token-collection-wired.js +182 -57
- package/dist/checks/bin/check-token-report.js +178 -58
- package/dist/checks/bin/check-workspace-escape.js +1011 -229
- package/dist/index.js +5971 -3489
- package/dist/lib/pre-push-cache-test-run.js +4431 -0
- package/dist/lib/pre-push-select-tests.js +799 -110
- package/package.json +3 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/actions.ts +10 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/archive-task.ts +42 -17
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/baseline-capture.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/branch-topology-gate.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +554 -95
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +264 -44
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/claude-code-transcript.ts +9 -9
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +211 -30
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/consumer-enumeration.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +75 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +961 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +212 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/outcomes.ts +135 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +394 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-audit.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-guard.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/derive-section7.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +514 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +110 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +123 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +240 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/diagram-model.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/direct-main-push.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +65 -22
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +238 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-owners.ts +14 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/docs-coherence.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/legacy-anchors.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/node-route.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/surfaced-manifest.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-no-procedures.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ensure-label.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/first-push-dispatch-gate.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +14 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +379 -11
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +3 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +1450 -33
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/local-anchor-coverage.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +119 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +75 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/redact.ts +87 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +801 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +373 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/metering-io-guard.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/milestone-validation.ts +2 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/no-disk-state.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +288 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-token-report.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-tranche.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +30 -16
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-tier.ts +17 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/premise-check.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/quoted-command.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +267 -19
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +91 -24
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-scaffold.ts +6 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/report-tokens.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +239 -110
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +384 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +184 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +65 -18
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +76 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/single-plan-pr.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/state-machine-model.ts +40 -27
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/symbol-collisions.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +38 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +488 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +7 -9
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-section.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/types.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +314 -56
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +2 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/workspace-escape.ts +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__1agj1ww._.js → [externals]__0cki-x_._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +6 -6
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0r7e54g._.js → [root-of-the-server]__18paley._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1r47dr7._.js → _08onyya._.js} +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +5 -5
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 1ce2dj27_cgbj.js} +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 22s44f5k3ecmj.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/34hhdtbp20krb.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0hstap0._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2t_rfsztmwu6y.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3ua4rm5f-a9k6.js +0 -1
- /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_ssgManifest.js +0 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
2
|
|
|
5
3
|
// src/checks/bin/check-doctrine-portability.ts
|
|
6
|
-
import { execFileSync as
|
|
7
|
-
import { readdirSync, readFileSync as
|
|
8
|
-
import { join as
|
|
4
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
5
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync6, statSync as statSync2 } from "node:fs";
|
|
6
|
+
import { join as join9 } from "node:path";
|
|
9
7
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
10
8
|
var GATE_AUDIENCE = {
|
|
11
9
|
"check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
|
|
@@ -1039,7 +1037,7 @@ function withDefaults(oldDefaults, newDefaults) {
|
|
|
1039
1037
|
var endpoint = withDefaults(null, DEFAULTS);
|
|
1040
1038
|
|
|
1041
1039
|
// ../../node_modules/fast-content-type-parse/index.js
|
|
1042
|
-
var NullObject = function
|
|
1040
|
+
var NullObject = function NullObject() {};
|
|
1043
1041
|
NullObject.prototype = Object.create(null);
|
|
1044
1042
|
var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
1045
1043
|
var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
|
|
@@ -1133,8 +1131,8 @@ function isPlainObject2(value) {
|
|
|
1133
1131
|
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
1134
1132
|
}
|
|
1135
1133
|
async function fetchWrapper(requestOptions) {
|
|
1136
|
-
const
|
|
1137
|
-
if (!
|
|
1134
|
+
const fetch2 = requestOptions.request?.fetch || globalThis.fetch;
|
|
1135
|
+
if (!fetch2) {
|
|
1138
1136
|
throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");
|
|
1139
1137
|
}
|
|
1140
1138
|
const log = requestOptions.request?.log || console;
|
|
@@ -1146,7 +1144,7 @@ async function fetchWrapper(requestOptions) {
|
|
|
1146
1144
|
]));
|
|
1147
1145
|
let fetchResponse;
|
|
1148
1146
|
try {
|
|
1149
|
-
fetchResponse = await
|
|
1147
|
+
fetchResponse = await fetch2(requestOptions.url, {
|
|
1150
1148
|
method: requestOptions.method,
|
|
1151
1149
|
body,
|
|
1152
1150
|
redirect: requestOptions.request?.redirect,
|
|
@@ -1783,27 +1781,27 @@ function splitTableRow(row) {
|
|
|
1783
1781
|
return parts.map((p) => p.split(PLACEHOLDER).join("|"));
|
|
1784
1782
|
}
|
|
1785
1783
|
// ../../packages/aeg-core/src/blast-radius-domains.ts
|
|
1786
|
-
function resolveWorkspaceEntry(
|
|
1787
|
-
if (
|
|
1788
|
-
const baseDir =
|
|
1784
|
+
function resolveWorkspaceEntry(entry, listDirs) {
|
|
1785
|
+
if (entry.endsWith("/*")) {
|
|
1786
|
+
const baseDir = entry.slice(0, -2);
|
|
1789
1787
|
return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
|
|
1790
1788
|
}
|
|
1791
|
-
if (
|
|
1789
|
+
if (entry.includes("*"))
|
|
1792
1790
|
return [];
|
|
1793
|
-
return [
|
|
1791
|
+
return [entry];
|
|
1794
1792
|
}
|
|
1795
1793
|
// ../../packages/aeg-core/src/consumer-enumeration.ts
|
|
1796
1794
|
function deriveWorkspaceMemberDirs(workspaces, listDirs) {
|
|
1797
|
-
const positive = workspaces.filter((
|
|
1798
|
-
const negative = workspaces.filter((
|
|
1795
|
+
const positive = workspaces.filter((entry) => !entry.startsWith("!"));
|
|
1796
|
+
const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
|
|
1799
1797
|
const excluded = new Set;
|
|
1800
|
-
for (const
|
|
1801
|
-
for (const member of resolveWorkspaceEntry(
|
|
1798
|
+
for (const entry of negative) {
|
|
1799
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs))
|
|
1802
1800
|
excluded.add(member);
|
|
1803
1801
|
}
|
|
1804
1802
|
const members = new Set;
|
|
1805
|
-
for (const
|
|
1806
|
-
for (const member of resolveWorkspaceEntry(
|
|
1803
|
+
for (const entry of positive) {
|
|
1804
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs)) {
|
|
1807
1805
|
if (!excluded.has(member))
|
|
1808
1806
|
members.add(member);
|
|
1809
1807
|
}
|
|
@@ -2049,12 +2047,24 @@ function extractBaseSha(comment) {
|
|
|
2049
2047
|
const m = firstThirteenLines(comment).match(BASE_SHA_PATTERN);
|
|
2050
2048
|
return m ? m[1].toLowerCase() : null;
|
|
2051
2049
|
}
|
|
2052
|
-
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;
|
|
2053
2058
|
function extractFindingSeverities(comment) {
|
|
2054
|
-
return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) =>
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
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
|
+
});
|
|
2058
2068
|
}
|
|
2059
2069
|
function extractVerdict(comments, valuePattern, missingLabel) {
|
|
2060
2070
|
const candidates = comments.filter((c) => valuePattern.test(c));
|
|
@@ -2127,15 +2137,15 @@ function summarizeTranscript(jsonl) {
|
|
|
2127
2137
|
const line = rawLine.trim();
|
|
2128
2138
|
if (!line)
|
|
2129
2139
|
continue;
|
|
2130
|
-
let
|
|
2140
|
+
let entry;
|
|
2131
2141
|
try {
|
|
2132
|
-
|
|
2142
|
+
entry = JSON.parse(line);
|
|
2133
2143
|
} catch {
|
|
2134
2144
|
continue;
|
|
2135
2145
|
}
|
|
2136
|
-
if (!
|
|
2146
|
+
if (!entry || typeof entry !== "object")
|
|
2137
2147
|
continue;
|
|
2138
|
-
const obj =
|
|
2148
|
+
const obj = entry;
|
|
2139
2149
|
if (obj.type !== "assistant")
|
|
2140
2150
|
continue;
|
|
2141
2151
|
const message = obj.message;
|
|
@@ -2468,6 +2478,12 @@ function evaluateReviewFindings(findings, scale, threshold) {
|
|
|
2468
2478
|
});
|
|
2469
2479
|
return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
|
|
2470
2480
|
}
|
|
2481
|
+
function isConsequentialFinding(finding) {
|
|
2482
|
+
return finding.state !== "resolved";
|
|
2483
|
+
}
|
|
2484
|
+
function consequentialFindings(findings) {
|
|
2485
|
+
return findings.filter((f) => isConsequentialFinding(f));
|
|
2486
|
+
}
|
|
2471
2487
|
function evaluateCodeReview(findings, policy) {
|
|
2472
2488
|
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
|
|
2473
2489
|
}
|
|
@@ -2983,7 +2999,7 @@ function isStep0Block(content) {
|
|
|
2983
2999
|
}
|
|
2984
3000
|
function checkCommandsCarryOutput(prBody) {
|
|
2985
3001
|
const errors = [];
|
|
2986
|
-
for (const [
|
|
3002
|
+
for (const [label, num] of [
|
|
2987
3003
|
["5", 5],
|
|
2988
3004
|
["6", 6]
|
|
2989
3005
|
]) {
|
|
@@ -2997,7 +3013,7 @@ function checkCommandsCarryOutput(prBody) {
|
|
|
2997
3013
|
continue;
|
|
2998
3014
|
const next = blocks[i + 1];
|
|
2999
3015
|
if (!next || isCommandBlock(next.content)) {
|
|
3000
|
-
errors.push(`brief-validation commands carry output: §${
|
|
3016
|
+
errors.push(`brief-validation commands carry output: §${label} has a command block ("${firstNonBlankLine(block.content)}") not immediately followed by a non-command output block — the very next fenced block must hold that command's actual output, not another command.`);
|
|
3001
3017
|
}
|
|
3002
3018
|
}
|
|
3003
3019
|
}
|
|
@@ -3434,8 +3450,8 @@ function stripPartBackticks(text) {
|
|
|
3434
3450
|
function partWordCount(text) {
|
|
3435
3451
|
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
3436
3452
|
}
|
|
3437
|
-
function looksLikeFilePath(
|
|
3438
|
-
const stripped =
|
|
3453
|
+
function looksLikeFilePath(entry) {
|
|
3454
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3439
3455
|
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3440
3456
|
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3441
3457
|
return extMatch !== null && extMatch.index > 0;
|
|
@@ -3921,14 +3937,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3921
3937
|
const referenced = extractClosesReferences(prBody);
|
|
3922
3938
|
if (taskIssueRefs) {
|
|
3923
3939
|
for (const n of referenced) {
|
|
3924
|
-
const
|
|
3925
|
-
if (!
|
|
3940
|
+
const ref = taskIssueRefs.get(n);
|
|
3941
|
+
if (!ref)
|
|
3926
3942
|
continue;
|
|
3927
|
-
const expectedBranch = `task/${
|
|
3943
|
+
const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
|
|
3928
3944
|
if (branch !== expectedBranch) {
|
|
3929
3945
|
return {
|
|
3930
3946
|
ok: false,
|
|
3931
|
-
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${
|
|
3947
|
+
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${ref.taskId} of tranche "${ref.trancheSlug}") but is not named "${expectedBranch}" — rename the branch and re-push, or if this work is intentionally outside AEG's dispatch flow, remove the Closes reference.`
|
|
3932
3948
|
};
|
|
3933
3949
|
}
|
|
3934
3950
|
}
|
|
@@ -3937,15 +3953,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3937
3953
|
if (!ref)
|
|
3938
3954
|
return { ok: true };
|
|
3939
3955
|
if (ref.kind === "issue") {
|
|
3940
|
-
const
|
|
3941
|
-
if (!referenced.has(
|
|
3956
|
+
const expectedIssue = ref.issueNumber;
|
|
3957
|
+
if (!referenced.has(expectedIssue)) {
|
|
3942
3958
|
return {
|
|
3943
3959
|
ok: false,
|
|
3944
|
-
expectedIssue
|
|
3945
|
-
message: `closes-n: PR body does not contain \`Closes #${
|
|
3960
|
+
expectedIssue,
|
|
3961
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
3946
3962
|
};
|
|
3947
3963
|
}
|
|
3948
|
-
return { ok: true, expectedIssue
|
|
3964
|
+
return { ok: true, expectedIssue };
|
|
3949
3965
|
}
|
|
3950
3966
|
const trancheSlug = ref.tranche;
|
|
3951
3967
|
const taskId = ref.taskId;
|
|
@@ -3991,8 +4007,8 @@ function extractIssue(body) {
|
|
|
3991
4007
|
const anchorNums = closesRefs(anchored);
|
|
3992
4008
|
if (anchorNums.length === 0)
|
|
3993
4009
|
return { issue: null, extraIssues: bodyNums, outsideHeader: false };
|
|
3994
|
-
const
|
|
3995
|
-
return { issue
|
|
4010
|
+
const issue = anchorNums[0];
|
|
4011
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
|
|
3996
4012
|
}
|
|
3997
4013
|
const headerNums = closesRefs(headerRegion(stripped));
|
|
3998
4014
|
if (bodyNums.length === 0)
|
|
@@ -4061,15 +4077,15 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4061
4077
|
const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
|
|
4062
4078
|
const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
|
|
4063
4079
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4064
|
-
const
|
|
4080
|
+
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4065
4081
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
4066
4082
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4067
4083
|
return {
|
|
4068
|
-
bound: head && base && briefHashBound &&
|
|
4084
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
4069
4085
|
head,
|
|
4070
4086
|
base,
|
|
4071
4087
|
briefHash: briefHashBound,
|
|
4072
|
-
objectivesVersion
|
|
4088
|
+
objectivesVersion,
|
|
4073
4089
|
rulingOrdinal,
|
|
4074
4090
|
policyDigest: policyDigestBound
|
|
4075
4091
|
};
|
|
@@ -4100,8 +4116,8 @@ function checkReviewGate(input) {
|
|
|
4100
4116
|
let codeReviewPolicyEvaluation;
|
|
4101
4117
|
let securityPolicyEvaluation;
|
|
4102
4118
|
try {
|
|
4103
|
-
codeReviewPolicyEvaluation = evaluateCodeReview(codeReview.findingSeverities, policy);
|
|
4104
|
-
securityPolicyEvaluation = evaluateSecurityReview(security.findingSeverities, policy);
|
|
4119
|
+
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
|
|
4120
|
+
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
|
|
4105
4121
|
} catch (err) {
|
|
4106
4122
|
return {
|
|
4107
4123
|
verdict: "fail",
|
|
@@ -5182,11 +5198,27 @@ var ObservedSchema = z.object({
|
|
|
5182
5198
|
var TaskStatusInputSchema = z.object({
|
|
5183
5199
|
task: TaskToolRefSchema.optional()
|
|
5184
5200
|
}).merge(PageRequestSchema).strict();
|
|
5201
|
+
var TaskConfidenceSchema = z.object({
|
|
5202
|
+
round: z.number().int().positive(),
|
|
5203
|
+
percent: z.number().int().min(0).max(100).nullable(),
|
|
5204
|
+
source: z.enum(["stated", "published-summary"])
|
|
5205
|
+
}).strict();
|
|
5206
|
+
var TaskPhaseHistorySchema = z.object({
|
|
5207
|
+
typicalPhaseMinutes: z.number().nonnegative(),
|
|
5208
|
+
typicalPhaseSamples: z.number().int().positive()
|
|
5209
|
+
}).strict();
|
|
5185
5210
|
var TaskStatusItemSchema = z.object({
|
|
5186
5211
|
task: TaskToolRefSchema,
|
|
5187
5212
|
issue: z.number().int().positive(),
|
|
5188
5213
|
pr: z.number().int().positive().nullable(),
|
|
5189
|
-
state: z.string()
|
|
5214
|
+
state: z.string(),
|
|
5215
|
+
round: z.number().int().positive().nullable().optional(),
|
|
5216
|
+
phase: z.string().min(1).nullable().optional(),
|
|
5217
|
+
minutesInPhase: z.number().nonnegative().nullable().optional(),
|
|
5218
|
+
phaseIsCurrent: z.boolean().nullable().optional(),
|
|
5219
|
+
lastConfidence: TaskConfidenceSchema.nullable().optional(),
|
|
5220
|
+
lastConfidenceUnread: z.boolean().optional(),
|
|
5221
|
+
phaseHistory: TaskPhaseHistorySchema.nullable().optional()
|
|
5190
5222
|
}).merge(ObservedSchema);
|
|
5191
5223
|
var TaskStatusResultSchema = z.object({
|
|
5192
5224
|
items: z.array(TaskStatusItemSchema),
|
|
@@ -5198,7 +5230,7 @@ var EscalationInputsSchema = z.object({
|
|
|
5198
5230
|
round: z.number().int().nonnegative(),
|
|
5199
5231
|
head: z.string(),
|
|
5200
5232
|
branch: z.string(),
|
|
5201
|
-
prNumber: z.number().int().positive()
|
|
5233
|
+
prNumber: z.number().int().positive().nullable()
|
|
5202
5234
|
});
|
|
5203
5235
|
var EscalationEvidenceSchema = z.object({
|
|
5204
5236
|
round: z.number().int().nonnegative(),
|
|
@@ -5234,13 +5266,45 @@ var TaskEscalationReadResultSchema = z.object({
|
|
|
5234
5266
|
items: z.array(TaskEscalationPacketSchema),
|
|
5235
5267
|
nextCursor: z.string().nullable()
|
|
5236
5268
|
}).merge(ObservedSchema);
|
|
5237
|
-
var
|
|
5238
|
-
|
|
5239
|
-
|
|
5269
|
+
var TaskPrCheckSchema = z.object({
|
|
5270
|
+
name: z.string(),
|
|
5271
|
+
required: z.boolean(),
|
|
5272
|
+
status: z.string(),
|
|
5273
|
+
conclusion: z.string().nullable(),
|
|
5274
|
+
detailsUrl: z.string().nullable(),
|
|
5275
|
+
failureSummary: z.string().nullable()
|
|
5276
|
+
});
|
|
5277
|
+
var TaskPrVerdictSchema = z.object({
|
|
5278
|
+
role: z.enum(["code-review", "security"]),
|
|
5279
|
+
value: z.string(),
|
|
5280
|
+
judgedHead: z.string().nullable(),
|
|
5281
|
+
objectivesVersion: z.string().nullable()
|
|
5282
|
+
});
|
|
5283
|
+
var TaskPrPauseSchema = z.object({
|
|
5284
|
+
reason: z.string(),
|
|
5285
|
+
body: z.string()
|
|
5286
|
+
});
|
|
5287
|
+
var TaskPrReviewRecordSchema = z.object({
|
|
5288
|
+
verdicts: z.array(TaskPrVerdictSchema),
|
|
5289
|
+
roundMarkers: z.array(z.number().int().nonnegative()),
|
|
5290
|
+
summaryTable: z.string().nullable(),
|
|
5291
|
+
pause: TaskPrPauseSchema.nullable()
|
|
5292
|
+
});
|
|
5293
|
+
var TaskPrReadInputSchema = z.object({
|
|
5294
|
+
task: TaskToolRefSchema,
|
|
5295
|
+
pr: z.number().int().positive().optional()
|
|
5240
5296
|
}).strict();
|
|
5297
|
+
var TaskPrReadResultSchema = z.object({
|
|
5298
|
+
task: TaskToolRefSchema,
|
|
5299
|
+
issue: z.number().int().positive(),
|
|
5300
|
+
pr: z.number().int().positive(),
|
|
5301
|
+
head: z.string().nullable(),
|
|
5302
|
+
checks: z.array(TaskPrCheckSchema),
|
|
5303
|
+
review: TaskPrReviewRecordSchema
|
|
5304
|
+
}).merge(ObservedSchema);
|
|
5241
5305
|
var TaskStartResultSchema = z.object({
|
|
5242
5306
|
requestId: z.string().min(1),
|
|
5243
|
-
run:
|
|
5307
|
+
run: TaskToolRefSchema,
|
|
5244
5308
|
started: z.boolean(),
|
|
5245
5309
|
startedAt: z.string(),
|
|
5246
5310
|
mode: z.literal("attended")
|
|
@@ -5254,7 +5318,7 @@ var TaskCancelInputSchema = z.object({
|
|
|
5254
5318
|
}).strict();
|
|
5255
5319
|
var TaskResumeResultSchema = z.object({
|
|
5256
5320
|
task: z.number().int().positive(),
|
|
5257
|
-
pr: z.number().int().positive(),
|
|
5321
|
+
pr: z.number().int().positive().nullable(),
|
|
5258
5322
|
escalationId: z.string().min(1),
|
|
5259
5323
|
outcome: z.enum(["started", "already_resumed"]),
|
|
5260
5324
|
authenticatedBy: z.string().min(1),
|
|
@@ -5263,7 +5327,7 @@ var TaskResumeResultSchema = z.object({
|
|
|
5263
5327
|
var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
|
|
5264
5328
|
var TaskCancelResultSchema = z.object({
|
|
5265
5329
|
task: z.number().int().positive(),
|
|
5266
|
-
pr: z.number().int().positive(),
|
|
5330
|
+
pr: z.number().int().positive().nullable(),
|
|
5267
5331
|
escalationId: z.string().min(1),
|
|
5268
5332
|
outcome: TaskCancelOutcomeSchema,
|
|
5269
5333
|
authenticatedBy: z.string().min(1),
|
|
@@ -5274,6 +5338,7 @@ var TASK_TOOL_NAMES = [
|
|
|
5274
5338
|
"task_start",
|
|
5275
5339
|
"task_status",
|
|
5276
5340
|
"task_escalation_read",
|
|
5341
|
+
"task_pr_read",
|
|
5277
5342
|
"task_resume",
|
|
5278
5343
|
"task_cancel"
|
|
5279
5344
|
];
|
|
@@ -5501,6 +5566,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
|
|
|
5501
5566
|
}
|
|
5502
5567
|
return findings;
|
|
5503
5568
|
}
|
|
5569
|
+
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5570
|
+
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5571
|
+
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
5572
|
+
var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
|
|
5504
5573
|
// ../../packages/aeg-core/src/log/envelope.ts
|
|
5505
5574
|
import { createHash as createHash5 } from "node:crypto";
|
|
5506
5575
|
|
|
@@ -6039,6 +6108,7 @@ function redact(value, home) {
|
|
|
6039
6108
|
return value;
|
|
6040
6109
|
}
|
|
6041
6110
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6111
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2];
|
|
6042
6112
|
function metaOf(obj) {
|
|
6043
6113
|
if (obj === null || typeof obj !== "object")
|
|
6044
6114
|
return null;
|
|
@@ -6061,11 +6131,61 @@ function recordIdentity(obj) {
|
|
|
6061
6131
|
}
|
|
6062
6132
|
return null;
|
|
6063
6133
|
}
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6134
|
+
function schemaVersionOf(obj) {
|
|
6135
|
+
const meta = metaOf(obj);
|
|
6136
|
+
const schema = meta?.schema;
|
|
6137
|
+
return typeof schema === "number" ? schema : null;
|
|
6138
|
+
}
|
|
6139
|
+
function isKnownSchema(version) {
|
|
6140
|
+
return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
|
|
6141
|
+
}
|
|
6142
|
+
function classifyStoredLine(raw, home) {
|
|
6143
|
+
let obj;
|
|
6144
|
+
try {
|
|
6145
|
+
obj = JSON.parse(raw);
|
|
6146
|
+
} catch {
|
|
6147
|
+
return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
|
|
6148
|
+
}
|
|
6149
|
+
const version = schemaVersionOf(obj);
|
|
6150
|
+
if (version === null) {
|
|
6151
|
+
return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
|
|
6152
|
+
}
|
|
6153
|
+
if (!isKnownSchema(version)) {
|
|
6154
|
+
return {
|
|
6155
|
+
status: "unknown_version",
|
|
6156
|
+
identity: recordIdentity(obj),
|
|
6157
|
+
schema: version,
|
|
6158
|
+
raw,
|
|
6159
|
+
reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
|
|
6160
|
+
};
|
|
6161
|
+
}
|
|
6162
|
+
const result = LogEventSchema.safeParse(obj);
|
|
6163
|
+
if (!result.success) {
|
|
6164
|
+
return {
|
|
6165
|
+
status: "invalid",
|
|
6166
|
+
identity: recordIdentity(obj),
|
|
6167
|
+
raw,
|
|
6168
|
+
reason: result.error.issues[0]?.message ?? "schema violation"
|
|
6169
|
+
};
|
|
6170
|
+
}
|
|
6171
|
+
const event = result.data;
|
|
6172
|
+
const identity = recordIdentity(event);
|
|
6173
|
+
if (identity === null) {
|
|
6174
|
+
return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
|
|
6175
|
+
}
|
|
6176
|
+
const redacted = redact(event, home);
|
|
6177
|
+
const provenance = version === 2 ? event.meta.provenance ?? null : null;
|
|
6178
|
+
return {
|
|
6179
|
+
status: "ok",
|
|
6180
|
+
identity,
|
|
6181
|
+
runId: event.meta.run_id,
|
|
6182
|
+
seq: event.meta.seq,
|
|
6183
|
+
schema: version,
|
|
6184
|
+
provenance,
|
|
6185
|
+
event,
|
|
6186
|
+
postLine: JSON.stringify(redacted)
|
|
6187
|
+
};
|
|
6188
|
+
}
|
|
6069
6189
|
// ../../packages/aeg-core/src/control-store/records.ts
|
|
6070
6190
|
import { z as z3 } from "zod";
|
|
6071
6191
|
var isoTimestamp = z3.string().min(1);
|
|
@@ -6196,7 +6316,8 @@ var ResolutionRecordSchema = z3.object({
|
|
|
6196
6316
|
consumedAt: isoTimestamp
|
|
6197
6317
|
}).strict();
|
|
6198
6318
|
// src/lib/config.ts
|
|
6199
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6319
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
6320
|
+
import { promisify as promisify4 } from "node:util";
|
|
6200
6321
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
|
|
6201
6322
|
import { homedir } from "node:os";
|
|
6202
6323
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
@@ -6223,10 +6344,10 @@ var CheckEntrySchema = z4.object({
|
|
|
6223
6344
|
ownWorkflow: z4.boolean().optional(),
|
|
6224
6345
|
principalOwed: z4.literal(true).optional(),
|
|
6225
6346
|
validates: z4.enum(["body", "issue"]).optional()
|
|
6226
|
-
}).superRefine((
|
|
6227
|
-
if (!
|
|
6347
|
+
}).superRefine((entry, ctx) => {
|
|
6348
|
+
if (!entry.env)
|
|
6228
6349
|
return;
|
|
6229
|
-
for (const [key, value] of Object.entries(
|
|
6350
|
+
for (const [key, value] of Object.entries(entry.env)) {
|
|
6230
6351
|
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
6231
6352
|
continue;
|
|
6232
6353
|
const members = value.anyOf;
|
|
@@ -6383,18 +6504,19 @@ var VinayaConfigSchema = z4.object({
|
|
|
6383
6504
|
});
|
|
6384
6505
|
}
|
|
6385
6506
|
}).optional(),
|
|
6386
|
-
logPublish: z4.
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
}).refine((v) => v.
|
|
6395
|
-
message: "
|
|
6396
|
-
}).
|
|
6397
|
-
|
|
6507
|
+
logPublish: z4.unknown().refine((v) => v === undefined, {
|
|
6508
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
6509
|
+
}),
|
|
6510
|
+
runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
6511
|
+
logs: z4.object({
|
|
6512
|
+
folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
6513
|
+
url: z4.string().url().optional(),
|
|
6514
|
+
headers: z4.record(z4.string()).optional()
|
|
6515
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
6516
|
+
message: "logs: set at most one of folder/url"
|
|
6517
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
6518
|
+
message: "logs: headers requires url"
|
|
6519
|
+
}).optional()
|
|
6398
6520
|
});
|
|
6399
6521
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
6400
6522
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
@@ -6439,32 +6561,39 @@ function globalTokensCollectIgnoredWarning(path) {
|
|
|
6439
6561
|
function globalRuntimeDirIgnoredWarning(path) {
|
|
6440
6562
|
return `${path}: "runtimeDir" in the global config is ignored — it carries no repository segment, so a machine-wide value would collapse every repository's task folders into one tree. Declare it from a repo-local vinaya.config.json.`;
|
|
6441
6563
|
}
|
|
6564
|
+
var emittedGlobalKeyWarnings = new Set;
|
|
6565
|
+
function warnGlobalKeyIgnoredOnce(message) {
|
|
6566
|
+
if (emittedGlobalKeyWarnings.has(message))
|
|
6567
|
+
return;
|
|
6568
|
+
emittedGlobalKeyWarnings.add(message);
|
|
6569
|
+
console.error(`⚠ ${message}`);
|
|
6570
|
+
}
|
|
6442
6571
|
function stripGlobalOnlyKeys(config, path) {
|
|
6443
6572
|
if (path !== GLOBAL_CONFIG_PATH)
|
|
6444
6573
|
return config;
|
|
6445
6574
|
let result = config;
|
|
6446
6575
|
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
6447
|
-
|
|
6576
|
+
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
6448
6577
|
result = { ...result, checks: undefined };
|
|
6449
6578
|
}
|
|
6450
6579
|
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
6451
|
-
|
|
6580
|
+
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
6452
6581
|
result = { ...result, roles: undefined };
|
|
6453
6582
|
}
|
|
6454
6583
|
if (result.principals && result.principals.length > 0) {
|
|
6455
|
-
|
|
6584
|
+
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
6456
6585
|
result = { ...result, principals: undefined };
|
|
6457
6586
|
}
|
|
6458
6587
|
if (result.releaseActor) {
|
|
6459
|
-
|
|
6588
|
+
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
6460
6589
|
result = { ...result, releaseActor: undefined };
|
|
6461
6590
|
}
|
|
6462
6591
|
if (result.tokens) {
|
|
6463
|
-
|
|
6592
|
+
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
6464
6593
|
result = { ...result, tokens: undefined };
|
|
6465
6594
|
}
|
|
6466
6595
|
if (result.runtimeDir) {
|
|
6467
|
-
|
|
6596
|
+
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
6468
6597
|
result = { ...result, runtimeDir: undefined };
|
|
6469
6598
|
}
|
|
6470
6599
|
return result;
|
|
@@ -6497,26 +6626,102 @@ function resolveReviewPolicy(config) {
|
|
|
6497
6626
|
maxRounds
|
|
6498
6627
|
};
|
|
6499
6628
|
}
|
|
6500
|
-
function
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6629
|
+
function resolveRuntimeDirSetting(config) {
|
|
6630
|
+
return config?.runtimeDir ?? null;
|
|
6631
|
+
}
|
|
6632
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
6633
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
6634
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
6635
|
+
}
|
|
6636
|
+
function resolveLogsSetting(config) {
|
|
6637
|
+
const raw = config?.logs;
|
|
6638
|
+
if (!raw)
|
|
6639
|
+
return null;
|
|
6640
|
+
if (raw.url !== undefined)
|
|
6641
|
+
return { url: raw.url, headers: raw.headers };
|
|
6642
|
+
if (raw.folder !== undefined)
|
|
6643
|
+
return { folder: raw.folder };
|
|
6644
|
+
return null;
|
|
6645
|
+
}
|
|
6646
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
6647
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
6648
|
+
if (!anchored)
|
|
6649
|
+
return null;
|
|
6650
|
+
if ("url" in local)
|
|
6651
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
6652
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
6653
|
+
}
|
|
6654
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
6655
|
+
if (!headers)
|
|
6656
|
+
return;
|
|
6657
|
+
const resolved = {};
|
|
6658
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
6659
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
6507
6660
|
}
|
|
6661
|
+
return resolved;
|
|
6662
|
+
}
|
|
6663
|
+
function trustAnchorRepo() {
|
|
6664
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6665
|
+
if (fromRunner)
|
|
6666
|
+
return fromRunner;
|
|
6508
6667
|
try {
|
|
6509
6668
|
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
6510
6669
|
encoding: "utf-8",
|
|
6511
6670
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6512
|
-
})
|
|
6513
|
-
|
|
6514
|
-
|
|
6671
|
+
});
|
|
6672
|
+
return trustAnchorRepoFromRemoteUrl(url);
|
|
6673
|
+
} catch {
|
|
6674
|
+
return null;
|
|
6675
|
+
}
|
|
6676
|
+
}
|
|
6677
|
+
async function trustAnchorRepoAsync() {
|
|
6678
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6679
|
+
if (fromRunner)
|
|
6680
|
+
return fromRunner;
|
|
6681
|
+
try {
|
|
6682
|
+
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
6683
|
+
encoding: "utf-8",
|
|
6684
|
+
timeout: 1e4
|
|
6685
|
+
});
|
|
6686
|
+
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
6515
6687
|
} catch {
|
|
6516
6688
|
return null;
|
|
6517
6689
|
}
|
|
6518
6690
|
}
|
|
6691
|
+
function wellFormedRepoSlug(slug) {
|
|
6692
|
+
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
6693
|
+
}
|
|
6694
|
+
function trustAnchorRepoFromRunner() {
|
|
6695
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
6696
|
+
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
6697
|
+
}
|
|
6698
|
+
function trustAnchorRepoFromRemoteUrl(url) {
|
|
6699
|
+
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
6700
|
+
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
6701
|
+
}
|
|
6702
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
6703
|
+
function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
6704
|
+
const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
|
|
6705
|
+
if (!ref)
|
|
6706
|
+
return null;
|
|
6707
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
6708
|
+
return null;
|
|
6709
|
+
if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
|
|
6710
|
+
return null;
|
|
6711
|
+
return ref;
|
|
6712
|
+
}
|
|
6713
|
+
function readTrustAnchorConfigAtRef(ref) {
|
|
6714
|
+
const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6715
|
+
encoding: "utf-8",
|
|
6716
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
6717
|
+
timeout: 1e4
|
|
6718
|
+
});
|
|
6719
|
+
return Buffer.from(raw, "utf-8").toString("base64");
|
|
6720
|
+
}
|
|
6519
6721
|
function ghFetchTrustAnchorConfig() {
|
|
6722
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6723
|
+
if (probeRef)
|
|
6724
|
+
return readTrustAnchorConfigAtRef(probeRef);
|
|
6520
6725
|
const repo = trustAnchorRepo();
|
|
6521
6726
|
if (!repo)
|
|
6522
6727
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
@@ -6525,6 +6730,21 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6525
6730
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6526
6731
|
});
|
|
6527
6732
|
}
|
|
6733
|
+
async function ghFetchTrustAnchorConfigAsync() {
|
|
6734
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6735
|
+
if (probeRef) {
|
|
6736
|
+
const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6737
|
+
encoding: "utf-8",
|
|
6738
|
+
timeout: 1e4
|
|
6739
|
+
});
|
|
6740
|
+
return Buffer.from(stdout, "utf-8").toString("base64");
|
|
6741
|
+
}
|
|
6742
|
+
const repo = await trustAnchorRepoAsync();
|
|
6743
|
+
if (!repo)
|
|
6744
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6745
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
|
|
6746
|
+
return stdout;
|
|
6747
|
+
}
|
|
6528
6748
|
function firstLine(err) {
|
|
6529
6749
|
return err?.message?.split(`
|
|
6530
6750
|
`)[0] ?? "unknown error";
|
|
@@ -6539,16 +6759,35 @@ function isMissingFileError(err) {
|
|
|
6539
6759
|
return /\b404\b|not found/i.test(haystack);
|
|
6540
6760
|
}
|
|
6541
6761
|
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
6542
|
-
const warn = (why) => process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
|
|
6543
|
-
`);
|
|
6544
6762
|
let base64;
|
|
6545
6763
|
try {
|
|
6546
|
-
base64 = fetcher()
|
|
6764
|
+
base64 = fetcher();
|
|
6547
6765
|
} catch (err) {
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6766
|
+
return trustAnchorFetchFailed(err);
|
|
6767
|
+
}
|
|
6768
|
+
return parseTrustAnchorContent(base64);
|
|
6769
|
+
}
|
|
6770
|
+
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
6771
|
+
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
6772
|
+
let base64;
|
|
6773
|
+
try {
|
|
6774
|
+
base64 = await fetcher();
|
|
6775
|
+
} catch (err) {
|
|
6776
|
+
return trustAnchorFetchFailed(err, warn);
|
|
6551
6777
|
}
|
|
6778
|
+
return parseTrustAnchorContent(base64, warn);
|
|
6779
|
+
}
|
|
6780
|
+
function warnTrustAnchorFallback(why) {
|
|
6781
|
+
process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
|
|
6782
|
+
`);
|
|
6783
|
+
}
|
|
6784
|
+
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
6785
|
+
if (!isMissingFileError(err))
|
|
6786
|
+
warn(firstLine(err));
|
|
6787
|
+
return null;
|
|
6788
|
+
}
|
|
6789
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
6790
|
+
const base64 = content.trim();
|
|
6552
6791
|
if (!base64)
|
|
6553
6792
|
return null;
|
|
6554
6793
|
try {
|
|
@@ -6577,11 +6816,13 @@ function loadConfig() {
|
|
|
6577
6816
|
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
6578
6817
|
|
|
6579
6818
|
// src/lib/diff-evidence.ts
|
|
6580
|
-
import { execFileSync as
|
|
6581
|
-
import { join as
|
|
6819
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
6820
|
+
import { join as join8, relative, resolve as resolve2 } from "node:path";
|
|
6582
6821
|
|
|
6583
6822
|
// src/lib/brief-assembly.ts
|
|
6584
6823
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
6824
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
|
|
6825
|
+
import { join as join3 } from "node:path";
|
|
6585
6826
|
|
|
6586
6827
|
// ../../packages/sources/src/commands.ts
|
|
6587
6828
|
var COMMANDS = [
|
|
@@ -6734,10 +6975,10 @@ var COMMANDS = [
|
|
|
6734
6975
|
}
|
|
6735
6976
|
],
|
|
6736
6977
|
details: [
|
|
6737
|
-
"Composes `task brief`'s own preparation (`prepareTask`) with `dev-review-loop`
|
|
6978
|
+
"Composes `task brief`'s own preparation (`prepareTask`) with the watching driver (`runDriverLoop`, `dev-review-loop.ts`) — nothing else. Preparation starts no agent; the loop's own round 1 reads the frozen brief off the Issue and is the only place a developer is ever dispatched from a fresh task, so exactly one developer is started by construction.",
|
|
6738
6979
|
"A brief already frozen on the Issue is reused, never re-posted — the second `task dispatch`/`task brief` call this composes around does not fail the whole run, it just skips straight to running the loop. A task whose Issue refuses preparation (a missing brief section, an unmet dispatch gate) is refused before any agent starts, with nothing posted.",
|
|
6739
|
-
"Refuses when the frozen brief's developer branch already has an open pull request —
|
|
6740
|
-
"Exit and printed summary distinguish a published
|
|
6980
|
+
"Refuses when the frozen brief's developer branch already has an open pull request AND a driver is still live for it — a driver that crashed or was killed leaves its PR behind, and this command is the one that revives it, in any state, pause held or not.",
|
|
6981
|
+
"issue-711 O4: a pause never ends this process — it keeps running and watches the pull request, continuing on its own once a newer Principal ruling appears (or, for an `'infrastructure'`/`'stale_driver'` pause, after a bounded backoff), with no `--resume` command needed for the ordinary case. Exit and printed summary distinguish a published pull request OR a watched pause's own genuine end — merged, closed, or an operator's own `--cancel` (exit `0` either way, the PR URL) — from the one pause this process can never watch (no pull request exists yet — exit `1`, with the exact `vinaya task run <tranche> <n>` command to continue by hand), a usage/argv error (exit `2`), and any other failure (exit `3`)."
|
|
6741
6982
|
],
|
|
6742
6983
|
status: "shipped"
|
|
6743
6984
|
},
|
|
@@ -6776,7 +7017,7 @@ var COMMANDS = [
|
|
|
6776
7017
|
details: [
|
|
6777
7018
|
"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.",
|
|
6778
7019
|
"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.",
|
|
6779
|
-
"`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."
|
|
7020
|
+
"`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."
|
|
6780
7021
|
],
|
|
6781
7022
|
status: "shipped"
|
|
6782
7023
|
},
|
|
@@ -6906,48 +7147,6 @@ var COMMANDS = [
|
|
|
6906
7147
|
],
|
|
6907
7148
|
status: "shipped"
|
|
6908
7149
|
},
|
|
6909
|
-
{
|
|
6910
|
-
name: "log flush",
|
|
6911
|
-
description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
|
|
6912
|
-
flags: [
|
|
6913
|
-
{ flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
|
|
6914
|
-
{
|
|
6915
|
-
flag: "--pr",
|
|
6916
|
-
description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
|
|
6917
|
-
},
|
|
6918
|
-
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
6919
|
-
],
|
|
6920
|
-
details: [
|
|
6921
|
-
"Exactly one of `--issue`/`--pr` is required. `--pr` resolves the Issue from the PR body's `Closes #N` line — the same anchor every gate reads — and refuses with a check error naming the missing line when the body carries none.",
|
|
6922
|
-
"Splits the outbox first at `run_id` boundaries (a maximal run of consecutive lines sharing one `run_id`, never a global group-by, so an interleaved outbox never produces a range spanning a gap), then at `FORGE_COMMENT_MAX_CHARS` (65536) within each run. Each comment opens with `<!-- aeg:log:<run_id>:<seq_from>-<seq_to> -->` on its own line, then one fenced `ndjson` block, one outbox line per line, verbatim. A single line too large to fit alone is refused by name, never split across two comments.",
|
|
6923
|
-
"Logs its own `forge_write` line — `validated` before posting, `written` (with every returned comment id) after the last post succeeds, or `refused` (with gh's error) on any failure — through the same `log()` every other family uses, into the same outbox, before truncating. The outbox is truncated only to the lines confirmed posted; a failed chunk's lines, and anything appended to the outbox during the flush (including the flush's own `validated`/`written`/`refused` line), always survive to ride the next flush."
|
|
6924
|
-
],
|
|
6925
|
-
status: "shipped"
|
|
6926
|
-
},
|
|
6927
|
-
{
|
|
6928
|
-
name: "log export-artifact",
|
|
6929
|
-
description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
|
|
6930
|
-
flags: [],
|
|
6931
|
-
details: [
|
|
6932
|
-
"Concatenates every `*.ndjson` file under `~/.vinaya/outbox/` into `<dest>`, verbatim — no filtering, no second redaction pass (lines are already redacted at `log()`'s own write boundary). Writes nothing when the outbox is empty, and exits 0 either way: no gate events this run is a legitimate outcome, never a failure.",
|
|
6933
|
-
"Runs inside the generated `vinaya-checks.yml` job, which holds no forge-write credential — this command never calls the forge. Both this step and the `actions/upload-artifact` step after it run `if: always()`, so a cancelled or failed job still exports whatever partial outbox it has."
|
|
6934
|
-
],
|
|
6935
|
-
status: "shipped"
|
|
6936
|
-
},
|
|
6937
|
-
{
|
|
6938
|
-
name: "log collect-artifact",
|
|
6939
|
-
description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
|
|
6940
|
-
flags: [
|
|
6941
|
-
{ flag: "--pr", description: "The pull request this artifact belongs to" },
|
|
6942
|
-
{ flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
|
|
6943
|
-
],
|
|
6944
|
-
details: [
|
|
6945
|
-
"Runs inside the generated `vinaya-task-log-collector.yml` workflow — a `workflow_run`-triggered job on the default branch, holding the write credential the task-path job that produced the artifact never gets. `<path>` is already downloaded by that workflow, scoped to a specific, API-verified run id — a provenance guarantee this command never re-derives from the artifact bytes.",
|
|
6946
|
-
"Never executes, imports, or evaluates the artifact's content: every line is read as text and validated (schema, an 8 MiB whole-artifact size cap, redaction, and a repo cross-check) before anything is trusted. A rejected line becomes a named gap — printed, never a silent drop — and the artifact is never partially trusted past that check into executing anything.",
|
|
6947
|
-
"The valid, re-redacted survivors are appended into the same local outbox `vinaya log flush` would read for that PR's Issue, then published through the existing `flushOutbox` unmodified — reusing its chunking, its `<!-- aeg:log:… -->` marker, and its idempotent-retry read, rather than a second publisher. A retried collector run (a fresh runner, the same forge state) therefore dedupes for free: the marker already on the forge is acknowledged, never re-posted."
|
|
6948
|
-
],
|
|
6949
|
-
status: "shipped"
|
|
6950
|
-
},
|
|
6951
7150
|
{
|
|
6952
7151
|
name: "milestone create",
|
|
6953
7152
|
description: "Create a GitHub Milestone from a validated body",
|
|
@@ -7277,7 +7476,7 @@ var COMMANDS = [
|
|
|
7277
7476
|
{ flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
|
|
7278
7477
|
{
|
|
7279
7478
|
flag: "--pr",
|
|
7280
|
-
description: "
|
|
7479
|
+
description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
|
|
7281
7480
|
},
|
|
7282
7481
|
{ flag: "--round", description: "Round number, for a dispatch inside a review loop" },
|
|
7283
7482
|
{
|
|
@@ -7289,7 +7488,7 @@ var COMMANDS = [
|
|
|
7289
7488
|
details: [
|
|
7290
7489
|
"Sets `VINAYA_RUN_ID`/`VINAYA_ROLE`/`VINAYA_TASK`/`VINAYA_ROUND` on the child only — never on this process's own environment — and refuses by name, before any spawn attempt, when the named vendor binary is absent from `PATH` or present but not executable.",
|
|
7291
7490
|
"Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, or `refused`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
|
|
7292
|
-
"
|
|
7491
|
+
"Runs no flush of its own after the dispatch returns: every log line `dispatchRole` emits reaches its configured `logs` destination live, as it is emitted, so there is nothing left to ship in a trailing step. `--task`/`--pr` are attribution only, and remain mutually exclusive.",
|
|
7293
7492
|
"A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude/gemini: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`; `gemini ... --resume <id> ...`) in place of its first-dispatch args."
|
|
7294
7493
|
],
|
|
7295
7494
|
status: "shipped"
|
|
@@ -7309,7 +7508,8 @@ var COMMANDS = [
|
|
|
7309
7508
|
"Dispatches the developer through `dispatchRole` with the brief read from the Issue, waits for the PR it opens, then runs `assessRound` (`@attalabs/aeg-core`) — the entire policy — against observations this command reads from the forge: the head via `git ls-remote` only (never `gh pr view headRefOid`, which can lag a push), CI conclusion via the check-runs API (never run locally), and ruling comments matching `<!-- aeg:principal:ruling:<pr>-<k> -->`.",
|
|
7310
7509
|
"Nothing is posted to the PR before the policy decides `publish`: each round's reviewer and security verdicts are dispatched fresh (never a resumed session) through `dispatchRole`, rendered through `review post`'s own render functions, and written to a local file under the outbox — never `gh pr comment`/`gh pr review`. Posting the held verdicts is a separate, later task.",
|
|
7311
7510
|
"The developer's session is resumed every round via `dispatchRole`'s `resumeId` — never a fresh session — for every vendor; a round whose resume fails for a vendor that resumed successfully the round before stops the loop rather than silently falling back to a fresh developer session.",
|
|
7312
|
-
"Every dispatch and round transition is a log line through the Vinaya Log,
|
|
7511
|
+
"Every dispatch and round transition is a log line through the Vinaya Log, delivered live to its configured `logs` destination as it is emitted — never a tracker comment.",
|
|
7512
|
+
"issue-711 O4: this command — `--task <n>`, `--resume <pr>`, `--cancel <pr>` alike — stays `task run`'s own one-shot debug/direct entry; the watching driver that survives a pause and continues on its own is `task run`'s (see that command's own entry)."
|
|
7313
7513
|
],
|
|
7314
7514
|
status: "shipped"
|
|
7315
7515
|
}
|
|
@@ -7446,25 +7646,6 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
7446
7646
|
};
|
|
7447
7647
|
}
|
|
7448
7648
|
|
|
7449
|
-
// src/lib/brief-assembly.ts
|
|
7450
|
-
function git(args) {
|
|
7451
|
-
try {
|
|
7452
|
-
return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7453
|
-
} catch {
|
|
7454
|
-
return "";
|
|
7455
|
-
}
|
|
7456
|
-
}
|
|
7457
|
-
function expandGlob(glob) {
|
|
7458
|
-
const out = git(["ls-files", "--", glob]);
|
|
7459
|
-
return out.split(`
|
|
7460
|
-
`).map((s) => s.trim()).filter(Boolean);
|
|
7461
|
-
}
|
|
7462
|
-
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
7463
|
-
|
|
7464
|
-
// src/checks/registry.ts
|
|
7465
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
7466
|
-
import { join as join3 } from "node:path";
|
|
7467
|
-
|
|
7468
7649
|
// src/lib/package-root.ts
|
|
7469
7650
|
import { existsSync as existsSync2 } from "node:fs";
|
|
7470
7651
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
@@ -7482,13 +7663,33 @@ function packageRoot(moduleUrl) {
|
|
|
7482
7663
|
return dir;
|
|
7483
7664
|
}
|
|
7484
7665
|
|
|
7666
|
+
// src/lib/brief-assembly.ts
|
|
7667
|
+
var PACKAGE_ROOT = packageRoot(import.meta.url);
|
|
7668
|
+
var PACKAGED_TEMPLATE_PATH = join3(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
|
|
7669
|
+
var TEMPLATE_PATH = existsSync3(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join3(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
7670
|
+
function git(args) {
|
|
7671
|
+
try {
|
|
7672
|
+
return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7673
|
+
} catch {
|
|
7674
|
+
return "";
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
function expandGlob(glob) {
|
|
7678
|
+
const out = git(["ls-files", "--", glob]);
|
|
7679
|
+
return out.split(`
|
|
7680
|
+
`).map((s) => s.trim()).filter(Boolean);
|
|
7681
|
+
}
|
|
7682
|
+
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
7683
|
+
|
|
7485
7684
|
// src/checks/registry.ts
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
var
|
|
7685
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
7686
|
+
import { join as join4 } from "node:path";
|
|
7687
|
+
var DIST_BIN_DIR = join4(packageRoot(import.meta.url), "dist", "checks", "bin");
|
|
7688
|
+
var SRC_BIN_DIR = join4(packageRoot(import.meta.url), "src", "checks", "bin");
|
|
7689
|
+
var BIN_DIR = existsSync4(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
|
|
7489
7690
|
var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
|
|
7490
7691
|
function bin(name) {
|
|
7491
|
-
return
|
|
7692
|
+
return join4(BIN_DIR, `${name}${BIN_EXT}`);
|
|
7492
7693
|
}
|
|
7493
7694
|
var REGISTRY = [
|
|
7494
7695
|
[
|
|
@@ -7900,6 +8101,16 @@ var REGISTRY = [
|
|
|
7900
8101
|
},
|
|
7901
8102
|
0
|
|
7902
8103
|
],
|
|
8104
|
+
[
|
|
8105
|
+
{
|
|
8106
|
+
name: "ci-shard-coverage",
|
|
8107
|
+
run: bin("check-ci-shard-coverage"),
|
|
8108
|
+
scope: "diff",
|
|
8109
|
+
timeoutMs: 15000,
|
|
8110
|
+
env: {}
|
|
8111
|
+
},
|
|
8112
|
+
0
|
|
8113
|
+
],
|
|
7903
8114
|
[
|
|
7904
8115
|
{
|
|
7905
8116
|
name: "workspace-escape",
|
|
@@ -8037,42 +8248,541 @@ function coreCheckRegistry() {
|
|
|
8037
8248
|
var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.name, ring]));
|
|
8038
8249
|
|
|
8039
8250
|
// src/lib/log-sink.ts
|
|
8040
|
-
import {
|
|
8041
|
-
import { randomUUID } from "node:crypto";
|
|
8251
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
8252
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
8253
|
+
import {
|
|
8254
|
+
closeSync as closeSync3,
|
|
8255
|
+
constants as fsConstants3,
|
|
8256
|
+
existsSync as existsSync6,
|
|
8257
|
+
fstatSync as fstatSync2,
|
|
8258
|
+
mkdirSync as mkdirSync3,
|
|
8259
|
+
openSync as openSync3,
|
|
8260
|
+
readFileSync as readFileSync5,
|
|
8261
|
+
renameSync as renameSync2,
|
|
8262
|
+
writeSync as writeSync2
|
|
8263
|
+
} from "node:fs";
|
|
8264
|
+
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
8265
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
8266
|
+
import { promisify as promisify5 } from "node:util";
|
|
8267
|
+
|
|
8268
|
+
// src/lib/run-paths.ts
|
|
8269
|
+
import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
8270
|
+
import { dirname as dirname3, join as join5, resolve as resolvePath } from "node:path";
|
|
8271
|
+
var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8272
|
+
function isSafeRepoSegment(segment) {
|
|
8273
|
+
return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
|
|
8274
|
+
}
|
|
8275
|
+
function repoSegment(repo) {
|
|
8276
|
+
if (!repo || !isSafeRepoSegment(repo.owner) || !isSafeRepoSegment(repo.repo))
|
|
8277
|
+
return "unresolved";
|
|
8278
|
+
return `${repo.owner}-${repo.repo}`;
|
|
8279
|
+
}
|
|
8280
|
+
function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
|
|
8281
|
+
return join5(home, "runtime", repoSegment(repo));
|
|
8282
|
+
}
|
|
8283
|
+
function resolveRuntimeDir(input) {
|
|
8284
|
+
const local = resolveRuntimeDirSetting(input.localConfig);
|
|
8285
|
+
if (local === null)
|
|
8286
|
+
return defaultRuntimeDir(input.repo, input.home);
|
|
8287
|
+
if (isInsideRepo(local, input.repoRoot))
|
|
8288
|
+
return defaultRuntimeDir(input.repo, input.home);
|
|
8289
|
+
if (!input.unattended)
|
|
8290
|
+
return local;
|
|
8291
|
+
const anchored = resolveTrustAnchorRuntimeDir(local, input.trustAnchorConfig ?? null);
|
|
8292
|
+
return anchored ?? defaultRuntimeDir(input.repo, input.home);
|
|
8293
|
+
}
|
|
8294
|
+
function isInsideRepo(candidate, repoRoot) {
|
|
8295
|
+
if (!repoRoot)
|
|
8296
|
+
return false;
|
|
8297
|
+
const root = resolvePath(repoRoot);
|
|
8298
|
+
const target = resolvePath(candidate);
|
|
8299
|
+
return target === root || target.startsWith(`${root}/`);
|
|
8300
|
+
}
|
|
8301
|
+
var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
|
|
8302
|
+
var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
|
|
8303
|
+
function isUnattendedProcess(env = process.env) {
|
|
8304
|
+
return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
|
|
8305
|
+
}
|
|
8306
|
+
var memoized = null;
|
|
8307
|
+
async function runtimeDirForRepoAsync(repo) {
|
|
8308
|
+
const key = repoSegment(repo);
|
|
8309
|
+
if (memoized?.key === key)
|
|
8310
|
+
return memoized.value;
|
|
8311
|
+
const inputs = runtimeDirInputs();
|
|
8312
|
+
if (typeof inputs === "string")
|
|
8313
|
+
return inputs;
|
|
8314
|
+
const value = resolveRuntimeDir({
|
|
8315
|
+
repo,
|
|
8316
|
+
...inputs.base,
|
|
8317
|
+
trustAnchorConfig: inputs.needsAnchor ? await loadTrustAnchorConfigAsync() : null
|
|
8318
|
+
});
|
|
8319
|
+
memoized = { key, value };
|
|
8320
|
+
return value;
|
|
8321
|
+
}
|
|
8322
|
+
function runtimeDirInputs() {
|
|
8323
|
+
const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
|
|
8324
|
+
if (handedDown)
|
|
8325
|
+
return handedDown;
|
|
8326
|
+
const localConfig = loadConfig();
|
|
8327
|
+
const unattended = isUnattendedProcess();
|
|
8328
|
+
return {
|
|
8329
|
+
base: { localConfig, unattended, repoRoot: repoRootSync() },
|
|
8330
|
+
needsAnchor: unattended && resolveRuntimeDirSetting(localConfig) !== null
|
|
8331
|
+
};
|
|
8332
|
+
}
|
|
8333
|
+
function repoRootSync(start = process.cwd()) {
|
|
8334
|
+
let dir;
|
|
8335
|
+
try {
|
|
8336
|
+
dir = realpathSync2(start);
|
|
8337
|
+
} catch {
|
|
8338
|
+
return null;
|
|
8339
|
+
}
|
|
8340
|
+
for (;; ) {
|
|
8341
|
+
if (existsSync5(join5(dir, ".git")))
|
|
8342
|
+
return dir;
|
|
8343
|
+
const parent = dirname3(dir);
|
|
8344
|
+
if (parent === dir)
|
|
8345
|
+
return null;
|
|
8346
|
+
dir = parent;
|
|
8347
|
+
}
|
|
8348
|
+
}
|
|
8349
|
+
|
|
8350
|
+
// src/lib/log-webhook-drain.ts
|
|
8042
8351
|
import {
|
|
8043
8352
|
closeSync as closeSync2,
|
|
8044
8353
|
constants as fsConstants2,
|
|
8045
|
-
|
|
8046
|
-
fstatSync as fstatSync2,
|
|
8354
|
+
lstatSync,
|
|
8047
8355
|
mkdirSync as mkdirSync2,
|
|
8048
8356
|
openSync as openSync2,
|
|
8049
|
-
|
|
8357
|
+
linkSync,
|
|
8358
|
+
readFileSync as readFileSync4,
|
|
8050
8359
|
renameSync,
|
|
8360
|
+
statSync,
|
|
8361
|
+
unlinkSync,
|
|
8362
|
+
utimesSync,
|
|
8363
|
+
writeFileSync as writeFileSync2,
|
|
8051
8364
|
writeSync
|
|
8052
8365
|
} from "node:fs";
|
|
8053
|
-
import {
|
|
8054
|
-
import {
|
|
8055
|
-
|
|
8366
|
+
import { randomUUID } from "node:crypto";
|
|
8367
|
+
import { homedir as homedir2 } from "node:os";
|
|
8368
|
+
import { dirname as dirname4, join as join6 } from "node:path";
|
|
8369
|
+
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
8370
|
+
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
8371
|
+
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8372
|
+
function isSafeRepoSegment2(segment) {
|
|
8373
|
+
return SAFE_PATH_SEGMENT2.test(segment) && !segment.includes("..");
|
|
8374
|
+
}
|
|
8375
|
+
function isErrnoCode(err, code) {
|
|
8376
|
+
return typeof err === "object" && err !== null && err.code === code;
|
|
8377
|
+
}
|
|
8056
8378
|
function isEnoent(err) {
|
|
8379
|
+
return isErrnoCode(err, "ENOENT");
|
|
8380
|
+
}
|
|
8381
|
+
var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
|
|
8382
|
+
function tryCreateLock(lockPath, token) {
|
|
8383
|
+
try {
|
|
8384
|
+
mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
|
|
8385
|
+
const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
|
|
8386
|
+
try {
|
|
8387
|
+
writeSync(fd, `${token}
|
|
8388
|
+
`);
|
|
8389
|
+
} finally {
|
|
8390
|
+
closeSync2(fd);
|
|
8391
|
+
}
|
|
8392
|
+
return true;
|
|
8393
|
+
} catch (err) {
|
|
8394
|
+
if (isErrnoCode(err, "EEXIST"))
|
|
8395
|
+
return false;
|
|
8396
|
+
throw err;
|
|
8397
|
+
}
|
|
8398
|
+
}
|
|
8399
|
+
function acquireDrainLock(lockPath) {
|
|
8400
|
+
const token = `${process.pid}:${randomUUID()}`;
|
|
8401
|
+
if (tryCreateLock(lockPath, token))
|
|
8402
|
+
return token;
|
|
8403
|
+
let observedMtimeMs;
|
|
8404
|
+
try {
|
|
8405
|
+
observedMtimeMs = statSync(lockPath).mtimeMs;
|
|
8406
|
+
} catch (err) {
|
|
8407
|
+
if (!isEnoent(err))
|
|
8408
|
+
throw err;
|
|
8409
|
+
return tryCreateLock(lockPath, token) ? token : null;
|
|
8410
|
+
}
|
|
8411
|
+
if (Date.now() - observedMtimeMs <= WEBHOOK_DRAIN_LOCK_STALE_MS)
|
|
8412
|
+
return null;
|
|
8413
|
+
const claimed = `${lockPath}.claimed-${randomUUID()}`;
|
|
8414
|
+
try {
|
|
8415
|
+
renameSync(lockPath, claimed);
|
|
8416
|
+
} catch (err) {
|
|
8417
|
+
if (isEnoent(err))
|
|
8418
|
+
return null;
|
|
8419
|
+
throw err;
|
|
8420
|
+
}
|
|
8421
|
+
let claimedMtimeMs = null;
|
|
8422
|
+
try {
|
|
8423
|
+
claimedMtimeMs = statSync(claimed).mtimeMs;
|
|
8424
|
+
} catch (err) {
|
|
8425
|
+
if (!isEnoent(err))
|
|
8426
|
+
throw err;
|
|
8427
|
+
}
|
|
8428
|
+
if (claimedMtimeMs !== observedMtimeMs) {
|
|
8429
|
+
try {
|
|
8430
|
+
linkSync(claimed, lockPath);
|
|
8431
|
+
} catch (err) {
|
|
8432
|
+
if (!isErrnoCode(err, "EEXIST"))
|
|
8433
|
+
throw err;
|
|
8434
|
+
}
|
|
8435
|
+
try {
|
|
8436
|
+
unlinkSync(claimed);
|
|
8437
|
+
} catch (err) {
|
|
8438
|
+
if (!isEnoent(err))
|
|
8439
|
+
throw err;
|
|
8440
|
+
}
|
|
8441
|
+
return null;
|
|
8442
|
+
}
|
|
8443
|
+
unlinkSync(claimed);
|
|
8444
|
+
return tryCreateLock(lockPath, token) ? token : null;
|
|
8445
|
+
}
|
|
8446
|
+
function renewDrainLock(lockPath, token) {
|
|
8447
|
+
let holder;
|
|
8448
|
+
try {
|
|
8449
|
+
holder = readFileSync4(lockPath, "utf8").trim();
|
|
8450
|
+
} catch (err) {
|
|
8451
|
+
if (!isEnoent(err))
|
|
8452
|
+
throw err;
|
|
8453
|
+
return false;
|
|
8454
|
+
}
|
|
8455
|
+
if (holder !== token)
|
|
8456
|
+
return false;
|
|
8457
|
+
const now = new Date;
|
|
8458
|
+
try {
|
|
8459
|
+
utimesSync(lockPath, now, now);
|
|
8460
|
+
} catch (err) {
|
|
8461
|
+
if (!isEnoent(err))
|
|
8462
|
+
throw err;
|
|
8463
|
+
return false;
|
|
8464
|
+
}
|
|
8465
|
+
return true;
|
|
8466
|
+
}
|
|
8467
|
+
function releaseDrainLock(lockPath, token) {
|
|
8468
|
+
try {
|
|
8469
|
+
const holder = readFileSync4(lockPath, "utf8").trim();
|
|
8470
|
+
if (holder !== token)
|
|
8471
|
+
return;
|
|
8472
|
+
unlinkSync(lockPath);
|
|
8473
|
+
} catch (err) {
|
|
8474
|
+
if (!isEnoent(err))
|
|
8475
|
+
throw err;
|
|
8476
|
+
}
|
|
8477
|
+
}
|
|
8478
|
+
|
|
8479
|
+
class WebhookDrainError extends Error {
|
|
8480
|
+
code;
|
|
8481
|
+
constructor(code, message) {
|
|
8482
|
+
super(message);
|
|
8483
|
+
this.code = code;
|
|
8484
|
+
}
|
|
8485
|
+
}
|
|
8486
|
+
function backupPathFor(queuePath) {
|
|
8487
|
+
return queuePath.replace(/\.ndjson$/, ".1.ndjson");
|
|
8488
|
+
}
|
|
8489
|
+
function drainingPathFor(queuePath) {
|
|
8490
|
+
return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
|
|
8491
|
+
}
|
|
8492
|
+
function rejectedPathFor(queuePath) {
|
|
8493
|
+
return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
|
|
8494
|
+
}
|
|
8495
|
+
var rejectionWarnedThisProcess = false;
|
|
8496
|
+
function warnRejectionOnce(message) {
|
|
8497
|
+
if (rejectionWarnedThisProcess)
|
|
8498
|
+
return;
|
|
8499
|
+
rejectionWarnedThisProcess = true;
|
|
8500
|
+
try {
|
|
8501
|
+
process.stderr.write(message);
|
|
8502
|
+
} catch {}
|
|
8503
|
+
}
|
|
8504
|
+
function queueLines(buf) {
|
|
8505
|
+
const lines = [];
|
|
8506
|
+
let start = 0;
|
|
8507
|
+
for (let i = 0;i < buf.byteLength; i++) {
|
|
8508
|
+
if (buf[i] !== 10)
|
|
8509
|
+
continue;
|
|
8510
|
+
if (i > start)
|
|
8511
|
+
lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
|
|
8512
|
+
start = i + 1;
|
|
8513
|
+
}
|
|
8514
|
+
if (start < buf.byteLength)
|
|
8515
|
+
lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
|
|
8516
|
+
return lines;
|
|
8517
|
+
}
|
|
8518
|
+
function removeQueueHead(path, cut) {
|
|
8519
|
+
const remaining = readFileSync4(path);
|
|
8520
|
+
writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
|
|
8521
|
+
}
|
|
8522
|
+
function queueBucketSize(path) {
|
|
8523
|
+
let lstat;
|
|
8524
|
+
try {
|
|
8525
|
+
lstat = lstatSync(path);
|
|
8526
|
+
} catch (err) {
|
|
8527
|
+
if (!isEnoent(err))
|
|
8528
|
+
throw err;
|
|
8529
|
+
}
|
|
8530
|
+
if (lstat === undefined)
|
|
8531
|
+
return null;
|
|
8532
|
+
if (!lstat.isFile()) {
|
|
8533
|
+
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}`);
|
|
8534
|
+
}
|
|
8535
|
+
return Number(lstat.size);
|
|
8536
|
+
}
|
|
8537
|
+
function readQueueFile(path) {
|
|
8538
|
+
if (queueBucketSize(path) === null)
|
|
8539
|
+
return null;
|
|
8540
|
+
return readFileSync4(path);
|
|
8541
|
+
}
|
|
8542
|
+
function rejectLine(rejectedPath, reason, status, identity, raw) {
|
|
8543
|
+
const record = JSON.stringify({
|
|
8544
|
+
rejected_at: new Date().toISOString(),
|
|
8545
|
+
status,
|
|
8546
|
+
reason,
|
|
8547
|
+
identity,
|
|
8548
|
+
bytes: Buffer.byteLength(raw, "utf8"),
|
|
8549
|
+
raw
|
|
8550
|
+
});
|
|
8551
|
+
const failure = appendHardenedLine(rejectedPath, `${record}
|
|
8552
|
+
`);
|
|
8553
|
+
if (failure !== null) {
|
|
8554
|
+
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`);
|
|
8555
|
+
}
|
|
8556
|
+
warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
|
|
8557
|
+
`);
|
|
8558
|
+
}
|
|
8559
|
+
async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
|
|
8560
|
+
const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
|
|
8561
|
+
let response;
|
|
8562
|
+
try {
|
|
8563
|
+
response = await fetch(webhookUrl, {
|
|
8564
|
+
method: "POST",
|
|
8565
|
+
headers: { "content-type": "application/x-ndjson", ...headers },
|
|
8566
|
+
body,
|
|
8567
|
+
signal: AbortSignal.timeout(fetchTimeoutMs)
|
|
8568
|
+
});
|
|
8569
|
+
} catch (err) {
|
|
8570
|
+
const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
|
|
8571
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
|
|
8572
|
+
}
|
|
8573
|
+
if (!response.ok) {
|
|
8574
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
|
|
8575
|
+
}
|
|
8576
|
+
}
|
|
8577
|
+
async function drainQueueFile(args) {
|
|
8578
|
+
const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
|
|
8579
|
+
const buf = readQueueFile(path);
|
|
8580
|
+
if (buf === null || buf.byteLength === 0)
|
|
8581
|
+
return;
|
|
8582
|
+
const lines = queueLines(buf);
|
|
8583
|
+
if (lines.length === 0) {
|
|
8584
|
+
removeQueueHead(path, buf.byteLength);
|
|
8585
|
+
return;
|
|
8586
|
+
}
|
|
8587
|
+
let removed = 0;
|
|
8588
|
+
let pendingEnd = 0;
|
|
8589
|
+
let chunk = [];
|
|
8590
|
+
let chunkBytes = 0;
|
|
8591
|
+
const deliverChunk = async () => {
|
|
8592
|
+
const body = `${chunk.join(`
|
|
8593
|
+
`)}
|
|
8594
|
+
`;
|
|
8595
|
+
args.keepLock();
|
|
8596
|
+
await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
|
|
8597
|
+
totals.chunks += 1;
|
|
8598
|
+
totals.lineCount += chunk.length;
|
|
8599
|
+
totals.bytes += Buffer.byteLength(body, "utf8");
|
|
8600
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8601
|
+
removed = pendingEnd;
|
|
8602
|
+
chunk = [];
|
|
8603
|
+
chunkBytes = 0;
|
|
8604
|
+
};
|
|
8605
|
+
const setAside = async (reason, status, identity, line) => {
|
|
8606
|
+
if (chunk.length > 0)
|
|
8607
|
+
await deliverChunk();
|
|
8608
|
+
rejectLine(rejectedPath, reason, status, identity, line.raw);
|
|
8609
|
+
totals.rejected += 1;
|
|
8610
|
+
pendingEnd = line.end;
|
|
8611
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8612
|
+
removed = pendingEnd;
|
|
8613
|
+
};
|
|
8614
|
+
for (const line of lines) {
|
|
8615
|
+
const record = classifyStoredLine(line.raw, homedir2());
|
|
8616
|
+
if (record.status !== "ok") {
|
|
8617
|
+
await setAside(record.reason, record.status, record.identity, line);
|
|
8618
|
+
continue;
|
|
8619
|
+
}
|
|
8620
|
+
const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
|
|
8621
|
+
if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
|
|
8622
|
+
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);
|
|
8623
|
+
continue;
|
|
8624
|
+
}
|
|
8625
|
+
if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
|
|
8626
|
+
await deliverChunk();
|
|
8627
|
+
chunk.push(record.postLine);
|
|
8628
|
+
chunkBytes += lineBytes;
|
|
8629
|
+
pendingEnd = line.end;
|
|
8630
|
+
}
|
|
8631
|
+
pendingEnd = buf.byteLength;
|
|
8632
|
+
if (chunk.length > 0) {
|
|
8633
|
+
await deliverChunk();
|
|
8634
|
+
return;
|
|
8635
|
+
}
|
|
8636
|
+
if (pendingEnd > removed)
|
|
8637
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8638
|
+
}
|
|
8639
|
+
async function drainRenamedAside(args, livePath, source) {
|
|
8640
|
+
args.keepLock();
|
|
8641
|
+
const draining = drainingPathFor(livePath);
|
|
8642
|
+
try {
|
|
8643
|
+
renameSync(source, draining);
|
|
8644
|
+
} catch (err) {
|
|
8645
|
+
if (isEnoent(err))
|
|
8646
|
+
return;
|
|
8647
|
+
throw err;
|
|
8648
|
+
}
|
|
8649
|
+
await drainQueueFile({ ...args, path: draining });
|
|
8650
|
+
unlinkSync(draining);
|
|
8651
|
+
}
|
|
8652
|
+
async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
|
|
8653
|
+
const resolved = await resolveRepo();
|
|
8654
|
+
const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
|
|
8655
|
+
const outboxRoot = () => join6(GLOBAL_VINAYA_HOME, "outbox");
|
|
8656
|
+
const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
|
|
8657
|
+
const lockPath = `${path}.flush-lock`;
|
|
8658
|
+
const lockToken = acquireDrainLock(lockPath);
|
|
8659
|
+
const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
|
|
8660
|
+
if (lockToken === null)
|
|
8661
|
+
return { flushed: false, ...totals };
|
|
8662
|
+
try {
|
|
8663
|
+
const keepLock = () => {
|
|
8664
|
+
if (renewDrainLock(lockPath, lockToken))
|
|
8665
|
+
return;
|
|
8666
|
+
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`);
|
|
8667
|
+
};
|
|
8668
|
+
const shared = {
|
|
8669
|
+
rejectedPath: rejectedPathFor(path),
|
|
8670
|
+
webhookUrl,
|
|
8671
|
+
headers,
|
|
8672
|
+
fetchTimeoutMs,
|
|
8673
|
+
totals,
|
|
8674
|
+
keepLock
|
|
8675
|
+
};
|
|
8676
|
+
const draining = drainingPathFor(path);
|
|
8677
|
+
if (queueBucketSize(draining) !== null) {
|
|
8678
|
+
keepLock();
|
|
8679
|
+
await drainQueueFile({ ...shared, path: draining });
|
|
8680
|
+
unlinkSync(draining);
|
|
8681
|
+
}
|
|
8682
|
+
await drainRenamedAside(shared, path, backupPathFor(path));
|
|
8683
|
+
await drainRenamedAside(shared, path, path);
|
|
8684
|
+
return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
|
|
8685
|
+
} finally {
|
|
8686
|
+
releaseDrainLock(lockPath, lockToken);
|
|
8687
|
+
}
|
|
8688
|
+
}
|
|
8689
|
+
|
|
8690
|
+
// src/lib/log-sink.ts
|
|
8691
|
+
var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
|
|
8692
|
+
var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
|
|
8693
|
+
function withDeadline(work, ms, fallback) {
|
|
8694
|
+
return new Promise((resolve) => {
|
|
8695
|
+
const timer = setTimeout(() => resolve(fallback), ms);
|
|
8696
|
+
timer.unref?.();
|
|
8697
|
+
work.then((value) => {
|
|
8698
|
+
clearTimeout(timer);
|
|
8699
|
+
resolve(value);
|
|
8700
|
+
}, () => {
|
|
8701
|
+
clearTimeout(timer);
|
|
8702
|
+
resolve(fallback);
|
|
8703
|
+
});
|
|
8704
|
+
});
|
|
8705
|
+
}
|
|
8706
|
+
async function safeLoadTrustAnchorConfig() {
|
|
8707
|
+
return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
8708
|
+
}
|
|
8709
|
+
function logsCredentialMissing(headers, env) {
|
|
8710
|
+
if (!headers)
|
|
8711
|
+
return false;
|
|
8712
|
+
const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
8713
|
+
for (const value of Object.values(headers)) {
|
|
8714
|
+
for (const match of value.matchAll(varPattern)) {
|
|
8715
|
+
if (!env[match[1]])
|
|
8716
|
+
return true;
|
|
8717
|
+
}
|
|
8718
|
+
}
|
|
8719
|
+
return false;
|
|
8720
|
+
}
|
|
8721
|
+
function resolveLogDestinationFrom(input) {
|
|
8722
|
+
const local = resolveLogsSetting(input.localConfig);
|
|
8723
|
+
let effective = null;
|
|
8724
|
+
if (input.unattended) {
|
|
8725
|
+
effective = local ? resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig) : resolveLogsSetting(input.trustAnchorConfig);
|
|
8726
|
+
} else {
|
|
8727
|
+
effective = local;
|
|
8728
|
+
}
|
|
8729
|
+
if (hostFromEnv(input.env) === "ci") {
|
|
8730
|
+
if (effective && "url" in effective) {
|
|
8731
|
+
if (logsCredentialMissing(effective.headers, input.env)) {
|
|
8732
|
+
return {
|
|
8733
|
+
kind: "none",
|
|
8734
|
+
reason: "a logs.url server destination is configured, but this job holds no delivery credential (a fork pull request, or a missing repository secret)"
|
|
8735
|
+
};
|
|
8736
|
+
}
|
|
8737
|
+
return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
|
|
8738
|
+
}
|
|
8739
|
+
return {
|
|
8740
|
+
kind: "none",
|
|
8741
|
+
reason: "no server destination is configured for CI delivery (vinaya.config.json logs.url)"
|
|
8742
|
+
};
|
|
8743
|
+
}
|
|
8744
|
+
if (effective && "url" in effective) {
|
|
8745
|
+
return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
|
|
8746
|
+
}
|
|
8747
|
+
if (effective && "folder" in effective && isInsideRepo(effective.folder, input.repoRoot)) {
|
|
8748
|
+
effective = null;
|
|
8749
|
+
}
|
|
8750
|
+
const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
|
|
8751
|
+
return { kind: "folder", folder };
|
|
8752
|
+
}
|
|
8753
|
+
var processTrustAnchorOnce;
|
|
8754
|
+
function processTrustAnchor() {
|
|
8755
|
+
if (processTrustAnchorOnce === undefined)
|
|
8756
|
+
processTrustAnchorOnce = safeLoadTrustAnchorConfig();
|
|
8757
|
+
return processTrustAnchorOnce;
|
|
8758
|
+
}
|
|
8759
|
+
async function defaultResolveLogDestination(repo, env) {
|
|
8760
|
+
const localConfig = loadConfig();
|
|
8761
|
+
const unattended = isUnattendedProcess(process.env);
|
|
8762
|
+
return resolveLogDestinationFrom({
|
|
8763
|
+
localConfig,
|
|
8764
|
+
trustAnchorConfig: unattended ? await processTrustAnchor() : null,
|
|
8765
|
+
unattended,
|
|
8766
|
+
env,
|
|
8767
|
+
defaultFolder: join7(await runtimeDirForRepoAsync(repo), "logs"),
|
|
8768
|
+
repoRoot: repoRootSync()
|
|
8769
|
+
});
|
|
8770
|
+
}
|
|
8771
|
+
function isEnoent2(err) {
|
|
8057
8772
|
return typeof err === "object" && err !== null && err.code === "ENOENT";
|
|
8058
8773
|
}
|
|
8059
|
-
|
|
8774
|
+
var execFileAsync5 = promisify5(execFile5);
|
|
8775
|
+
async function resolveDoctrine(cwd, vinayaVersion) {
|
|
8060
8776
|
let toplevel;
|
|
8061
8777
|
try {
|
|
8062
|
-
toplevel =
|
|
8063
|
-
encoding: "utf8",
|
|
8064
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
8065
|
-
}).trim();
|
|
8778
|
+
toplevel = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], { encoding: "utf8" })).stdout.trim();
|
|
8066
8779
|
} catch (err) {
|
|
8067
|
-
return
|
|
8780
|
+
return isEnoent2(err) ? "unknown" : vinayaVersion;
|
|
8068
8781
|
}
|
|
8069
|
-
if (!
|
|
8782
|
+
if (!existsSync6(join7(toplevel, "aeg-root", "roles")))
|
|
8070
8783
|
return vinayaVersion;
|
|
8071
8784
|
try {
|
|
8072
|
-
const sha =
|
|
8073
|
-
encoding: "utf8",
|
|
8074
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
8075
|
-
}).trim();
|
|
8785
|
+
const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
|
|
8076
8786
|
return `aeg-root@${sha}`;
|
|
8077
8787
|
} catch {
|
|
8078
8788
|
return vinayaVersion;
|
|
@@ -8080,20 +8790,20 @@ function resolveDoctrine(cwd, vinayaVersion) {
|
|
|
8080
8790
|
}
|
|
8081
8791
|
function readVinayaVersion() {
|
|
8082
8792
|
try {
|
|
8083
|
-
const pkg = JSON.parse(
|
|
8793
|
+
const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
8084
8794
|
return pkg.version ?? "unknown";
|
|
8085
8795
|
} catch {
|
|
8086
8796
|
return "unknown";
|
|
8087
8797
|
}
|
|
8088
8798
|
}
|
|
8089
|
-
var
|
|
8090
|
-
function
|
|
8091
|
-
return
|
|
8799
|
+
var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8800
|
+
function isSafeRepoSegment3(segment) {
|
|
8801
|
+
return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
|
|
8092
8802
|
}
|
|
8093
8803
|
function outboxPathFor(deps, repo, issue) {
|
|
8094
8804
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
8095
8805
|
const fileName = `${issue ?? "none"}.ndjson`;
|
|
8096
|
-
return
|
|
8806
|
+
return join7(deps.outboxRoot(), dirName, fileName);
|
|
8097
8807
|
}
|
|
8098
8808
|
function hostFromEnv(env) {
|
|
8099
8809
|
if (env.GITHUB_ACTIONS)
|
|
@@ -8104,36 +8814,60 @@ function hostFromEnv(env) {
|
|
|
8104
8814
|
return "loop";
|
|
8105
8815
|
return "cli";
|
|
8106
8816
|
}
|
|
8817
|
+
var warnedThisProcess = false;
|
|
8818
|
+
function defaultStderr(message) {
|
|
8819
|
+
if (warnedThisProcess)
|
|
8820
|
+
return;
|
|
8821
|
+
warnedThisProcess = true;
|
|
8822
|
+
process.stderr.write(message);
|
|
8823
|
+
}
|
|
8107
8824
|
function defaultDeps() {
|
|
8108
8825
|
return {
|
|
8109
|
-
outboxRoot: () =>
|
|
8110
|
-
home: () =>
|
|
8826
|
+
outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
|
|
8827
|
+
home: () => homedir3(),
|
|
8111
8828
|
hostname: () => osHostname(),
|
|
8112
8829
|
cwd: () => process.cwd(),
|
|
8113
8830
|
now: () => new Date,
|
|
8114
8831
|
env: () => process.env,
|
|
8115
8832
|
resolveRepo: () => resolveRepo(),
|
|
8116
8833
|
vinayaVersion: () => readVinayaVersion(),
|
|
8117
|
-
stderr:
|
|
8118
|
-
process.stderr.write(message);
|
|
8119
|
-
},
|
|
8834
|
+
stderr: defaultStderr,
|
|
8120
8835
|
inputVersions: () => {
|
|
8121
8836
|
return;
|
|
8122
|
-
}
|
|
8837
|
+
},
|
|
8838
|
+
resolveLogDestination: defaultResolveLogDestination
|
|
8123
8839
|
};
|
|
8124
8840
|
}
|
|
8125
|
-
var APPEND_OPEN_FLAGS =
|
|
8841
|
+
var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
|
|
8126
8842
|
function guardedAppendOpen(path) {
|
|
8127
8843
|
try {
|
|
8128
|
-
return
|
|
8844
|
+
return openSync3(path, APPEND_OPEN_FLAGS, 384);
|
|
8129
8845
|
} catch {
|
|
8130
8846
|
return;
|
|
8131
8847
|
}
|
|
8132
8848
|
}
|
|
8849
|
+
function appendHardenedLine(path, line) {
|
|
8850
|
+
try {
|
|
8851
|
+
mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
|
|
8852
|
+
const fd = guardedAppendOpen(path);
|
|
8853
|
+
if (fd === undefined)
|
|
8854
|
+
return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
|
|
8855
|
+
try {
|
|
8856
|
+
if (!fstatSync2(fd).isFile())
|
|
8857
|
+
return `target is not a regular file: ${path}`;
|
|
8858
|
+
writeSync2(fd, line);
|
|
8859
|
+
} finally {
|
|
8860
|
+
closeSync3(fd);
|
|
8861
|
+
}
|
|
8862
|
+
return null;
|
|
8863
|
+
} catch (err) {
|
|
8864
|
+
return err instanceof Error ? err.message : String(err);
|
|
8865
|
+
}
|
|
8866
|
+
}
|
|
8133
8867
|
function reportRotationOverflow(backupPath, warn) {
|
|
8134
8868
|
let raw;
|
|
8135
8869
|
try {
|
|
8136
|
-
raw =
|
|
8870
|
+
raw = readFileSync5(backupPath, "utf8");
|
|
8137
8871
|
} catch {
|
|
8138
8872
|
return;
|
|
8139
8873
|
}
|
|
@@ -8156,7 +8890,7 @@ function reportRotationOverflow(backupPath, warn) {
|
|
|
8156
8890
|
}
|
|
8157
8891
|
function appendLine(path, line, warn) {
|
|
8158
8892
|
try {
|
|
8159
|
-
|
|
8893
|
+
mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
|
|
8160
8894
|
let fd = guardedAppendOpen(path);
|
|
8161
8895
|
if (fd === undefined) {
|
|
8162
8896
|
warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
|
|
@@ -8172,11 +8906,11 @@ function appendLine(path, line, warn) {
|
|
|
8172
8906
|
return;
|
|
8173
8907
|
}
|
|
8174
8908
|
if (stat.size > OUTBOX_MAX_BYTES) {
|
|
8175
|
-
|
|
8909
|
+
closeSync3(fd);
|
|
8176
8910
|
closed = true;
|
|
8177
8911
|
const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
|
|
8178
8912
|
reportRotationOverflow(backupPath, warn);
|
|
8179
|
-
|
|
8913
|
+
renameSync2(path, backupPath);
|
|
8180
8914
|
const rotated = guardedAppendOpen(path);
|
|
8181
8915
|
if (rotated === undefined) {
|
|
8182
8916
|
warn(`vinaya: log outbox target could not be reopened after rotation — refusing: ${path}
|
|
@@ -8186,10 +8920,10 @@ function appendLine(path, line, warn) {
|
|
|
8186
8920
|
fd = rotated;
|
|
8187
8921
|
closed = false;
|
|
8188
8922
|
}
|
|
8189
|
-
|
|
8923
|
+
writeSync2(fd, line);
|
|
8190
8924
|
} finally {
|
|
8191
8925
|
if (!closed)
|
|
8192
|
-
|
|
8926
|
+
closeSync3(fd);
|
|
8193
8927
|
}
|
|
8194
8928
|
} catch (err) {
|
|
8195
8929
|
warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
|
|
@@ -8198,8 +8932,8 @@ function appendLine(path, line, warn) {
|
|
|
8198
8932
|
}
|
|
8199
8933
|
function createLogSink(overrides = {}) {
|
|
8200
8934
|
const deps = { ...defaultDeps(), ...overrides };
|
|
8201
|
-
const runId = deps.env().VINAYA_RUN_ID ||
|
|
8202
|
-
const processId =
|
|
8935
|
+
const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
|
|
8936
|
+
const processId = randomUUID2();
|
|
8203
8937
|
let seq = 0;
|
|
8204
8938
|
let warned = false;
|
|
8205
8939
|
const warnOnce = (message) => {
|
|
@@ -8212,8 +8946,9 @@ function createLogSink(overrides = {}) {
|
|
|
8212
8946
|
};
|
|
8213
8947
|
let doctrineCache;
|
|
8214
8948
|
const doctrine = () => {
|
|
8215
|
-
if (doctrineCache === undefined)
|
|
8216
|
-
doctrineCache = resolveDoctrine(deps.cwd(), deps.vinayaVersion());
|
|
8949
|
+
if (doctrineCache === undefined) {
|
|
8950
|
+
doctrineCache = withDeadline(resolveDoctrine(deps.cwd(), deps.vinayaVersion()), LOG_CONTEXT_LOOKUP_DEADLINE_MS, deps.vinayaVersion());
|
|
8951
|
+
}
|
|
8217
8952
|
return doctrineCache;
|
|
8218
8953
|
};
|
|
8219
8954
|
let resolveRepoCache;
|
|
@@ -8222,6 +8957,30 @@ function createLogSink(overrides = {}) {
|
|
|
8222
8957
|
resolveRepoCache = deps.resolveRepo();
|
|
8223
8958
|
return resolveRepoCache;
|
|
8224
8959
|
};
|
|
8960
|
+
let contextCache;
|
|
8961
|
+
const context = () => {
|
|
8962
|
+
if (contextCache === undefined) {
|
|
8963
|
+
const env = deps.env();
|
|
8964
|
+
contextCache = Promise.all([
|
|
8965
|
+
withDeadline(resolveRepoOnce(), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null),
|
|
8966
|
+
doctrine()
|
|
8967
|
+
]).then(async ([resolved, doctrineValue]) => {
|
|
8968
|
+
const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
|
|
8969
|
+
return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
|
|
8970
|
+
});
|
|
8971
|
+
}
|
|
8972
|
+
return contextCache;
|
|
8973
|
+
};
|
|
8974
|
+
let drainChain = Promise.resolve();
|
|
8975
|
+
const pendingWrites = new Set;
|
|
8976
|
+
const scheduleWebhookDrain = (issue, url, headers) => {
|
|
8977
|
+
drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
|
|
8978
|
+
return;
|
|
8979
|
+
}).catch((err) => {
|
|
8980
|
+
warnOnce(`vinaya: log delivery to ${url} failed — queued in the local outbox, retried on the next event: ${err instanceof Error ? err.message : String(err)}
|
|
8981
|
+
`);
|
|
8982
|
+
});
|
|
8983
|
+
};
|
|
8225
8984
|
function log(e) {
|
|
8226
8985
|
try {
|
|
8227
8986
|
const env = deps.env();
|
|
@@ -8236,22 +8995,26 @@ function createLogSink(overrides = {}) {
|
|
|
8236
8995
|
attempt: env.VINAYA_ATTEMPT,
|
|
8237
8996
|
parent: env.VINAYA_PARENT_EVENT
|
|
8238
8997
|
};
|
|
8239
|
-
|
|
8240
|
-
const repo = resolved && isSafeRepoSegment(resolved.owner) && isSafeRepoSegment(resolved.repo) ? resolved : null;
|
|
8998
|
+
const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
|
|
8241
8999
|
const header = buildHeader({
|
|
8242
9000
|
now,
|
|
8243
9001
|
runId,
|
|
8244
9002
|
seq: mySeq,
|
|
8245
9003
|
repo: repo ? `${repo.owner}/${repo.repo}` : null,
|
|
8246
9004
|
vinaya: deps.vinayaVersion(),
|
|
8247
|
-
doctrine:
|
|
9005
|
+
doctrine: doctrineValue,
|
|
8248
9006
|
host,
|
|
8249
9007
|
hostname: deps.hostname(),
|
|
8250
9008
|
env: envFields,
|
|
8251
|
-
eventId:
|
|
9009
|
+
eventId: randomUUID2(),
|
|
8252
9010
|
processId,
|
|
8253
9011
|
inputVersions: deps.inputVersions()
|
|
8254
9012
|
});
|
|
9013
|
+
if (resolvedDestination.kind === "none") {
|
|
9014
|
+
warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
|
|
9015
|
+
`);
|
|
9016
|
+
return;
|
|
9017
|
+
}
|
|
8255
9018
|
const full = { ...e, ...header };
|
|
8256
9019
|
const parsed = LogEventSchema.safeParse(full);
|
|
8257
9020
|
if (!parsed.success) {
|
|
@@ -8261,25 +9024,42 @@ function createLogSink(overrides = {}) {
|
|
|
8261
9024
|
}
|
|
8262
9025
|
const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
|
|
8263
9026
|
`;
|
|
8264
|
-
|
|
9027
|
+
const destination = resolvedDestination;
|
|
9028
|
+
if (destination.kind === "server") {
|
|
9029
|
+
appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
|
|
9030
|
+
scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
|
|
9031
|
+
} else {
|
|
9032
|
+
appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
|
|
9033
|
+
}
|
|
8265
9034
|
}).catch((err) => {
|
|
8266
9035
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8267
9036
|
`);
|
|
8268
9037
|
});
|
|
9038
|
+
pendingWrites.add(written);
|
|
9039
|
+
written.finally(() => pendingWrites.delete(written));
|
|
8269
9040
|
} catch (err) {
|
|
8270
9041
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8271
9042
|
`);
|
|
8272
9043
|
}
|
|
8273
9044
|
}
|
|
8274
9045
|
const warmup = () => {
|
|
8275
|
-
doctrine();
|
|
8276
9046
|
const originalWarn = console.warn;
|
|
8277
9047
|
console.warn = () => {};
|
|
8278
9048
|
resolveRepoOnce().finally(() => {
|
|
8279
9049
|
console.warn = originalWarn;
|
|
8280
9050
|
});
|
|
9051
|
+
context().catch(() => {
|
|
9052
|
+
return;
|
|
9053
|
+
});
|
|
9054
|
+
};
|
|
9055
|
+
const drain = async () => {
|
|
9056
|
+
if (pendingWrites.size > 0)
|
|
9057
|
+
await Promise.allSettled(Array.from(pendingWrites));
|
|
9058
|
+
await drainChain.catch(() => {
|
|
9059
|
+
return;
|
|
9060
|
+
});
|
|
8281
9061
|
};
|
|
8282
|
-
return { log, runId, warmup };
|
|
9062
|
+
return { log, runId, warmup, drain };
|
|
8283
9063
|
}
|
|
8284
9064
|
var defaultSink = createLogSink();
|
|
8285
9065
|
|
|
@@ -8330,7 +9110,7 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
8330
9110
|
function fileDiffAgainst(ref, path) {
|
|
8331
9111
|
let out;
|
|
8332
9112
|
try {
|
|
8333
|
-
out =
|
|
9113
|
+
out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
8334
9114
|
encoding: "utf8",
|
|
8335
9115
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8336
9116
|
}).trim();
|
|
@@ -8341,7 +9121,7 @@ function fileDiffAgainst(ref, path) {
|
|
|
8341
9121
|
}
|
|
8342
9122
|
function revParse(ref) {
|
|
8343
9123
|
try {
|
|
8344
|
-
return
|
|
9124
|
+
return execFileSync5("git", ["rev-parse", "--verify", ref], {
|
|
8345
9125
|
encoding: "utf8",
|
|
8346
9126
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8347
9127
|
}).trim();
|
|
@@ -8351,7 +9131,7 @@ function revParse(ref) {
|
|
|
8351
9131
|
}
|
|
8352
9132
|
function repoRoot() {
|
|
8353
9133
|
try {
|
|
8354
|
-
return
|
|
9134
|
+
return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
|
|
8355
9135
|
encoding: "utf8",
|
|
8356
9136
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8357
9137
|
}).trim();
|
|
@@ -8362,7 +9142,7 @@ function repoRoot() {
|
|
|
8362
9142
|
function changedFiles(base) {
|
|
8363
9143
|
let out;
|
|
8364
9144
|
try {
|
|
8365
|
-
out =
|
|
9145
|
+
out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
8366
9146
|
encoding: "utf8",
|
|
8367
9147
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8368
9148
|
}).trim();
|
|
@@ -8387,7 +9167,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
|
|
|
8387
9167
|
const relPaths = changedFiles(ref);
|
|
8388
9168
|
if (relPaths === null)
|
|
8389
9169
|
continue;
|
|
8390
|
-
return { base: ref, root, files: relPaths.map((p) =>
|
|
9170
|
+
return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
|
|
8391
9171
|
}
|
|
8392
9172
|
return null;
|
|
8393
9173
|
}
|
|
@@ -8424,7 +9204,7 @@ var DOCTRINE_ROOT = loadConfig()?.proseGates?.doctrineRoot ?? "aeg-root";
|
|
|
8424
9204
|
var SHIPS_PREFIX2 = `${DOCTRINE_ROOT}/`;
|
|
8425
9205
|
function git2(args) {
|
|
8426
9206
|
try {
|
|
8427
|
-
return
|
|
9207
|
+
return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
8428
9208
|
} catch {
|
|
8429
9209
|
return "";
|
|
8430
9210
|
}
|
|
@@ -8432,15 +9212,15 @@ function git2(args) {
|
|
|
8432
9212
|
function collectWorkingTree(dir, out = []) {
|
|
8433
9213
|
let entries;
|
|
8434
9214
|
try {
|
|
8435
|
-
entries =
|
|
9215
|
+
entries = readdirSync2(dir);
|
|
8436
9216
|
} catch {
|
|
8437
9217
|
return out;
|
|
8438
9218
|
}
|
|
8439
9219
|
for (const name of entries) {
|
|
8440
|
-
const full =
|
|
9220
|
+
const full = join9(dir, name);
|
|
8441
9221
|
let isDir;
|
|
8442
9222
|
try {
|
|
8443
|
-
isDir =
|
|
9223
|
+
isDir = statSync2(full).isDirectory();
|
|
8444
9224
|
} catch {
|
|
8445
9225
|
continue;
|
|
8446
9226
|
}
|
|
@@ -8455,7 +9235,7 @@ function collectWorkingTree(dir, out = []) {
|
|
|
8455
9235
|
return out;
|
|
8456
9236
|
}
|
|
8457
9237
|
function readWorkingTree(paths) {
|
|
8458
|
-
return paths.map((p) => ({ path: p, content:
|
|
9238
|
+
return paths.map((p) => ({ path: p, content: readFileSync6(p, "utf8") }));
|
|
8459
9239
|
}
|
|
8460
9240
|
function collectAtRef(ref, dir) {
|
|
8461
9241
|
const listing = git2(["ls-tree", "-r", "--name-only", ref, "--", dir]);
|