@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,10 +1,8 @@
|
|
|
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-doc-coverage-push.ts
|
|
6
|
-
import { execFileSync as
|
|
7
|
-
import { existsSync as
|
|
4
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
5
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
|
|
8
6
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
9
7
|
var GATE_AUDIENCE = {
|
|
10
8
|
"check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
|
|
@@ -1038,7 +1036,7 @@ function withDefaults(oldDefaults, newDefaults) {
|
|
|
1038
1036
|
var endpoint = withDefaults(null, DEFAULTS);
|
|
1039
1037
|
|
|
1040
1038
|
// ../../node_modules/fast-content-type-parse/index.js
|
|
1041
|
-
var NullObject = function
|
|
1039
|
+
var NullObject = function NullObject() {};
|
|
1042
1040
|
NullObject.prototype = Object.create(null);
|
|
1043
1041
|
var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
1044
1042
|
var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
|
|
@@ -1132,8 +1130,8 @@ function isPlainObject2(value) {
|
|
|
1132
1130
|
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
1133
1131
|
}
|
|
1134
1132
|
async function fetchWrapper(requestOptions) {
|
|
1135
|
-
const
|
|
1136
|
-
if (!
|
|
1133
|
+
const fetch2 = requestOptions.request?.fetch || globalThis.fetch;
|
|
1134
|
+
if (!fetch2) {
|
|
1137
1135
|
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");
|
|
1138
1136
|
}
|
|
1139
1137
|
const log = requestOptions.request?.log || console;
|
|
@@ -1145,7 +1143,7 @@ async function fetchWrapper(requestOptions) {
|
|
|
1145
1143
|
]));
|
|
1146
1144
|
let fetchResponse;
|
|
1147
1145
|
try {
|
|
1148
|
-
fetchResponse = await
|
|
1146
|
+
fetchResponse = await fetch2(requestOptions.url, {
|
|
1149
1147
|
method: requestOptions.method,
|
|
1150
1148
|
body,
|
|
1151
1149
|
redirect: requestOptions.request?.redirect,
|
|
@@ -1782,27 +1780,27 @@ function splitTableRow(row) {
|
|
|
1782
1780
|
return parts.map((p) => p.split(PLACEHOLDER).join("|"));
|
|
1783
1781
|
}
|
|
1784
1782
|
// ../../packages/aeg-core/src/blast-radius-domains.ts
|
|
1785
|
-
function resolveWorkspaceEntry(
|
|
1786
|
-
if (
|
|
1787
|
-
const baseDir =
|
|
1783
|
+
function resolveWorkspaceEntry(entry, listDirs) {
|
|
1784
|
+
if (entry.endsWith("/*")) {
|
|
1785
|
+
const baseDir = entry.slice(0, -2);
|
|
1788
1786
|
return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
|
|
1789
1787
|
}
|
|
1790
|
-
if (
|
|
1788
|
+
if (entry.includes("*"))
|
|
1791
1789
|
return [];
|
|
1792
|
-
return [
|
|
1790
|
+
return [entry];
|
|
1793
1791
|
}
|
|
1794
1792
|
// ../../packages/aeg-core/src/consumer-enumeration.ts
|
|
1795
1793
|
function deriveWorkspaceMemberDirs(workspaces, listDirs) {
|
|
1796
|
-
const positive = workspaces.filter((
|
|
1797
|
-
const negative = workspaces.filter((
|
|
1794
|
+
const positive = workspaces.filter((entry) => !entry.startsWith("!"));
|
|
1795
|
+
const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
|
|
1798
1796
|
const excluded = new Set;
|
|
1799
|
-
for (const
|
|
1800
|
-
for (const member of resolveWorkspaceEntry(
|
|
1797
|
+
for (const entry of negative) {
|
|
1798
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs))
|
|
1801
1799
|
excluded.add(member);
|
|
1802
1800
|
}
|
|
1803
1801
|
const members = new Set;
|
|
1804
|
-
for (const
|
|
1805
|
-
for (const member of resolveWorkspaceEntry(
|
|
1802
|
+
for (const entry of positive) {
|
|
1803
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs)) {
|
|
1806
1804
|
if (!excluded.has(member))
|
|
1807
1805
|
members.add(member);
|
|
1808
1806
|
}
|
|
@@ -2048,12 +2046,24 @@ function extractBaseSha(comment) {
|
|
|
2048
2046
|
const m = firstThirteenLines(comment).match(BASE_SHA_PATTERN);
|
|
2049
2047
|
return m ? m[1].toLowerCase() : null;
|
|
2050
2048
|
}
|
|
2051
|
-
var
|
|
2049
|
+
var FINDING_DESCRIPTION_STATE = /^F(\d+)(?:\s+\S+)?(?:\s+(open|fix-claimed|reproduced|resolved))?:/;
|
|
2050
|
+
function parseFindingState(description) {
|
|
2051
|
+
const m = FINDING_DESCRIPTION_STATE.exec(description.trim());
|
|
2052
|
+
if (!m)
|
|
2053
|
+
return { id: null, state: null };
|
|
2054
|
+
return { id: `F${m[1]}`, state: m[2] ?? null };
|
|
2055
|
+
}
|
|
2056
|
+
var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—(?:\s+(.*))?$/gm;
|
|
2052
2057
|
function extractFindingSeverities(comment) {
|
|
2053
|
-
return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) =>
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2058
|
+
return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => {
|
|
2059
|
+
const { id, state } = parseFindingState(m[3] ?? "");
|
|
2060
|
+
return {
|
|
2061
|
+
severity: m[1],
|
|
2062
|
+
location: m[2],
|
|
2063
|
+
id,
|
|
2064
|
+
state
|
|
2065
|
+
};
|
|
2066
|
+
});
|
|
2057
2067
|
}
|
|
2058
2068
|
function extractVerdict(comments, valuePattern, missingLabel) {
|
|
2059
2069
|
const candidates = comments.filter((c) => valuePattern.test(c));
|
|
@@ -2126,15 +2136,15 @@ function summarizeTranscript(jsonl) {
|
|
|
2126
2136
|
const line = rawLine.trim();
|
|
2127
2137
|
if (!line)
|
|
2128
2138
|
continue;
|
|
2129
|
-
let
|
|
2139
|
+
let entry;
|
|
2130
2140
|
try {
|
|
2131
|
-
|
|
2141
|
+
entry = JSON.parse(line);
|
|
2132
2142
|
} catch {
|
|
2133
2143
|
continue;
|
|
2134
2144
|
}
|
|
2135
|
-
if (!
|
|
2145
|
+
if (!entry || typeof entry !== "object")
|
|
2136
2146
|
continue;
|
|
2137
|
-
const obj =
|
|
2147
|
+
const obj = entry;
|
|
2138
2148
|
if (obj.type !== "assistant")
|
|
2139
2149
|
continue;
|
|
2140
2150
|
const message = obj.message;
|
|
@@ -2467,6 +2477,12 @@ function evaluateReviewFindings(findings, scale, threshold) {
|
|
|
2467
2477
|
});
|
|
2468
2478
|
return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
|
|
2469
2479
|
}
|
|
2480
|
+
function isConsequentialFinding(finding) {
|
|
2481
|
+
return finding.state !== "resolved";
|
|
2482
|
+
}
|
|
2483
|
+
function consequentialFindings(findings) {
|
|
2484
|
+
return findings.filter((f) => isConsequentialFinding(f));
|
|
2485
|
+
}
|
|
2470
2486
|
function evaluateCodeReview(findings, policy) {
|
|
2471
2487
|
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
|
|
2472
2488
|
}
|
|
@@ -2982,7 +2998,7 @@ function isStep0Block(content) {
|
|
|
2982
2998
|
}
|
|
2983
2999
|
function checkCommandsCarryOutput(prBody) {
|
|
2984
3000
|
const errors = [];
|
|
2985
|
-
for (const [
|
|
3001
|
+
for (const [label, num] of [
|
|
2986
3002
|
["5", 5],
|
|
2987
3003
|
["6", 6]
|
|
2988
3004
|
]) {
|
|
@@ -2996,7 +3012,7 @@ function checkCommandsCarryOutput(prBody) {
|
|
|
2996
3012
|
continue;
|
|
2997
3013
|
const next = blocks[i + 1];
|
|
2998
3014
|
if (!next || isCommandBlock(next.content)) {
|
|
2999
|
-
errors.push(`brief-validation commands carry output: §${
|
|
3015
|
+
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.`);
|
|
3000
3016
|
}
|
|
3001
3017
|
}
|
|
3002
3018
|
}
|
|
@@ -3433,8 +3449,8 @@ function stripPartBackticks(text) {
|
|
|
3433
3449
|
function partWordCount(text) {
|
|
3434
3450
|
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
3435
3451
|
}
|
|
3436
|
-
function looksLikeFilePath(
|
|
3437
|
-
const stripped =
|
|
3452
|
+
function looksLikeFilePath(entry) {
|
|
3453
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3438
3454
|
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3439
3455
|
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3440
3456
|
return extMatch !== null && extMatch.index > 0;
|
|
@@ -3920,14 +3936,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3920
3936
|
const referenced = extractClosesReferences(prBody);
|
|
3921
3937
|
if (taskIssueRefs) {
|
|
3922
3938
|
for (const n of referenced) {
|
|
3923
|
-
const
|
|
3924
|
-
if (!
|
|
3939
|
+
const ref = taskIssueRefs.get(n);
|
|
3940
|
+
if (!ref)
|
|
3925
3941
|
continue;
|
|
3926
|
-
const expectedBranch = `task/${
|
|
3942
|
+
const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
|
|
3927
3943
|
if (branch !== expectedBranch) {
|
|
3928
3944
|
return {
|
|
3929
3945
|
ok: false,
|
|
3930
|
-
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${
|
|
3946
|
+
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.`
|
|
3931
3947
|
};
|
|
3932
3948
|
}
|
|
3933
3949
|
}
|
|
@@ -3936,15 +3952,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3936
3952
|
if (!ref)
|
|
3937
3953
|
return { ok: true };
|
|
3938
3954
|
if (ref.kind === "issue") {
|
|
3939
|
-
const
|
|
3940
|
-
if (!referenced.has(
|
|
3955
|
+
const expectedIssue = ref.issueNumber;
|
|
3956
|
+
if (!referenced.has(expectedIssue)) {
|
|
3941
3957
|
return {
|
|
3942
3958
|
ok: false,
|
|
3943
|
-
expectedIssue
|
|
3944
|
-
message: `closes-n: PR body does not contain \`Closes #${
|
|
3959
|
+
expectedIssue,
|
|
3960
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
3945
3961
|
};
|
|
3946
3962
|
}
|
|
3947
|
-
return { ok: true, expectedIssue
|
|
3963
|
+
return { ok: true, expectedIssue };
|
|
3948
3964
|
}
|
|
3949
3965
|
const trancheSlug = ref.tranche;
|
|
3950
3966
|
const taskId = ref.taskId;
|
|
@@ -3990,8 +4006,8 @@ function extractIssue(body) {
|
|
|
3990
4006
|
const anchorNums = closesRefs(anchored);
|
|
3991
4007
|
if (anchorNums.length === 0)
|
|
3992
4008
|
return { issue: null, extraIssues: bodyNums, outsideHeader: false };
|
|
3993
|
-
const
|
|
3994
|
-
return { issue
|
|
4009
|
+
const issue = anchorNums[0];
|
|
4010
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
|
|
3995
4011
|
}
|
|
3996
4012
|
const headerNums = closesRefs(headerRegion(stripped));
|
|
3997
4013
|
if (bodyNums.length === 0)
|
|
@@ -4060,15 +4076,15 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4060
4076
|
const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
|
|
4061
4077
|
const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
|
|
4062
4078
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4063
|
-
const
|
|
4079
|
+
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4064
4080
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
4065
4081
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4066
4082
|
return {
|
|
4067
|
-
bound: head && base && briefHashBound &&
|
|
4083
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
4068
4084
|
head,
|
|
4069
4085
|
base,
|
|
4070
4086
|
briefHash: briefHashBound,
|
|
4071
|
-
objectivesVersion
|
|
4087
|
+
objectivesVersion,
|
|
4072
4088
|
rulingOrdinal,
|
|
4073
4089
|
policyDigest: policyDigestBound
|
|
4074
4090
|
};
|
|
@@ -4099,8 +4115,8 @@ function checkReviewGate(input) {
|
|
|
4099
4115
|
let codeReviewPolicyEvaluation;
|
|
4100
4116
|
let securityPolicyEvaluation;
|
|
4101
4117
|
try {
|
|
4102
|
-
codeReviewPolicyEvaluation = evaluateCodeReview(codeReview.findingSeverities, policy);
|
|
4103
|
-
securityPolicyEvaluation = evaluateSecurityReview(security.findingSeverities, policy);
|
|
4118
|
+
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
|
|
4119
|
+
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
|
|
4104
4120
|
} catch (err) {
|
|
4105
4121
|
return {
|
|
4106
4122
|
verdict: "fail",
|
|
@@ -5181,11 +5197,27 @@ var ObservedSchema = z.object({
|
|
|
5181
5197
|
var TaskStatusInputSchema = z.object({
|
|
5182
5198
|
task: TaskToolRefSchema.optional()
|
|
5183
5199
|
}).merge(PageRequestSchema).strict();
|
|
5200
|
+
var TaskConfidenceSchema = z.object({
|
|
5201
|
+
round: z.number().int().positive(),
|
|
5202
|
+
percent: z.number().int().min(0).max(100).nullable(),
|
|
5203
|
+
source: z.enum(["stated", "published-summary"])
|
|
5204
|
+
}).strict();
|
|
5205
|
+
var TaskPhaseHistorySchema = z.object({
|
|
5206
|
+
typicalPhaseMinutes: z.number().nonnegative(),
|
|
5207
|
+
typicalPhaseSamples: z.number().int().positive()
|
|
5208
|
+
}).strict();
|
|
5184
5209
|
var TaskStatusItemSchema = z.object({
|
|
5185
5210
|
task: TaskToolRefSchema,
|
|
5186
5211
|
issue: z.number().int().positive(),
|
|
5187
5212
|
pr: z.number().int().positive().nullable(),
|
|
5188
|
-
state: z.string()
|
|
5213
|
+
state: z.string(),
|
|
5214
|
+
round: z.number().int().positive().nullable().optional(),
|
|
5215
|
+
phase: z.string().min(1).nullable().optional(),
|
|
5216
|
+
minutesInPhase: z.number().nonnegative().nullable().optional(),
|
|
5217
|
+
phaseIsCurrent: z.boolean().nullable().optional(),
|
|
5218
|
+
lastConfidence: TaskConfidenceSchema.nullable().optional(),
|
|
5219
|
+
lastConfidenceUnread: z.boolean().optional(),
|
|
5220
|
+
phaseHistory: TaskPhaseHistorySchema.nullable().optional()
|
|
5189
5221
|
}).merge(ObservedSchema);
|
|
5190
5222
|
var TaskStatusResultSchema = z.object({
|
|
5191
5223
|
items: z.array(TaskStatusItemSchema),
|
|
@@ -5197,7 +5229,7 @@ var EscalationInputsSchema = z.object({
|
|
|
5197
5229
|
round: z.number().int().nonnegative(),
|
|
5198
5230
|
head: z.string(),
|
|
5199
5231
|
branch: z.string(),
|
|
5200
|
-
prNumber: z.number().int().positive()
|
|
5232
|
+
prNumber: z.number().int().positive().nullable()
|
|
5201
5233
|
});
|
|
5202
5234
|
var EscalationEvidenceSchema = z.object({
|
|
5203
5235
|
round: z.number().int().nonnegative(),
|
|
@@ -5233,13 +5265,45 @@ var TaskEscalationReadResultSchema = z.object({
|
|
|
5233
5265
|
items: z.array(TaskEscalationPacketSchema),
|
|
5234
5266
|
nextCursor: z.string().nullable()
|
|
5235
5267
|
}).merge(ObservedSchema);
|
|
5236
|
-
var
|
|
5237
|
-
|
|
5238
|
-
|
|
5268
|
+
var TaskPrCheckSchema = z.object({
|
|
5269
|
+
name: z.string(),
|
|
5270
|
+
required: z.boolean(),
|
|
5271
|
+
status: z.string(),
|
|
5272
|
+
conclusion: z.string().nullable(),
|
|
5273
|
+
detailsUrl: z.string().nullable(),
|
|
5274
|
+
failureSummary: z.string().nullable()
|
|
5275
|
+
});
|
|
5276
|
+
var TaskPrVerdictSchema = z.object({
|
|
5277
|
+
role: z.enum(["code-review", "security"]),
|
|
5278
|
+
value: z.string(),
|
|
5279
|
+
judgedHead: z.string().nullable(),
|
|
5280
|
+
objectivesVersion: z.string().nullable()
|
|
5281
|
+
});
|
|
5282
|
+
var TaskPrPauseSchema = z.object({
|
|
5283
|
+
reason: z.string(),
|
|
5284
|
+
body: z.string()
|
|
5285
|
+
});
|
|
5286
|
+
var TaskPrReviewRecordSchema = z.object({
|
|
5287
|
+
verdicts: z.array(TaskPrVerdictSchema),
|
|
5288
|
+
roundMarkers: z.array(z.number().int().nonnegative()),
|
|
5289
|
+
summaryTable: z.string().nullable(),
|
|
5290
|
+
pause: TaskPrPauseSchema.nullable()
|
|
5291
|
+
});
|
|
5292
|
+
var TaskPrReadInputSchema = z.object({
|
|
5293
|
+
task: TaskToolRefSchema,
|
|
5294
|
+
pr: z.number().int().positive().optional()
|
|
5239
5295
|
}).strict();
|
|
5296
|
+
var TaskPrReadResultSchema = z.object({
|
|
5297
|
+
task: TaskToolRefSchema,
|
|
5298
|
+
issue: z.number().int().positive(),
|
|
5299
|
+
pr: z.number().int().positive(),
|
|
5300
|
+
head: z.string().nullable(),
|
|
5301
|
+
checks: z.array(TaskPrCheckSchema),
|
|
5302
|
+
review: TaskPrReviewRecordSchema
|
|
5303
|
+
}).merge(ObservedSchema);
|
|
5240
5304
|
var TaskStartResultSchema = z.object({
|
|
5241
5305
|
requestId: z.string().min(1),
|
|
5242
|
-
run:
|
|
5306
|
+
run: TaskToolRefSchema,
|
|
5243
5307
|
started: z.boolean(),
|
|
5244
5308
|
startedAt: z.string(),
|
|
5245
5309
|
mode: z.literal("attended")
|
|
@@ -5253,7 +5317,7 @@ var TaskCancelInputSchema = z.object({
|
|
|
5253
5317
|
}).strict();
|
|
5254
5318
|
var TaskResumeResultSchema = z.object({
|
|
5255
5319
|
task: z.number().int().positive(),
|
|
5256
|
-
pr: z.number().int().positive(),
|
|
5320
|
+
pr: z.number().int().positive().nullable(),
|
|
5257
5321
|
escalationId: z.string().min(1),
|
|
5258
5322
|
outcome: z.enum(["started", "already_resumed"]),
|
|
5259
5323
|
authenticatedBy: z.string().min(1),
|
|
@@ -5262,7 +5326,7 @@ var TaskResumeResultSchema = z.object({
|
|
|
5262
5326
|
var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
|
|
5263
5327
|
var TaskCancelResultSchema = z.object({
|
|
5264
5328
|
task: z.number().int().positive(),
|
|
5265
|
-
pr: z.number().int().positive(),
|
|
5329
|
+
pr: z.number().int().positive().nullable(),
|
|
5266
5330
|
escalationId: z.string().min(1),
|
|
5267
5331
|
outcome: TaskCancelOutcomeSchema,
|
|
5268
5332
|
authenticatedBy: z.string().min(1),
|
|
@@ -5273,6 +5337,7 @@ var TASK_TOOL_NAMES = [
|
|
|
5273
5337
|
"task_start",
|
|
5274
5338
|
"task_status",
|
|
5275
5339
|
"task_escalation_read",
|
|
5340
|
+
"task_pr_read",
|
|
5276
5341
|
"task_resume",
|
|
5277
5342
|
"task_cancel"
|
|
5278
5343
|
];
|
|
@@ -5500,6 +5565,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
|
|
|
5500
5565
|
}
|
|
5501
5566
|
return findings;
|
|
5502
5567
|
}
|
|
5568
|
+
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5569
|
+
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5570
|
+
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
5571
|
+
var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
|
|
5503
5572
|
// ../../packages/aeg-core/src/log/envelope.ts
|
|
5504
5573
|
import { createHash as createHash5 } from "node:crypto";
|
|
5505
5574
|
|
|
@@ -6038,6 +6107,7 @@ function redact(value, home) {
|
|
|
6038
6107
|
return value;
|
|
6039
6108
|
}
|
|
6040
6109
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6110
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2];
|
|
6041
6111
|
function metaOf(obj) {
|
|
6042
6112
|
if (obj === null || typeof obj !== "object")
|
|
6043
6113
|
return null;
|
|
@@ -6060,11 +6130,61 @@ function recordIdentity(obj) {
|
|
|
6060
6130
|
}
|
|
6061
6131
|
return null;
|
|
6062
6132
|
}
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6133
|
+
function schemaVersionOf(obj) {
|
|
6134
|
+
const meta = metaOf(obj);
|
|
6135
|
+
const schema = meta?.schema;
|
|
6136
|
+
return typeof schema === "number" ? schema : null;
|
|
6137
|
+
}
|
|
6138
|
+
function isKnownSchema(version) {
|
|
6139
|
+
return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
|
|
6140
|
+
}
|
|
6141
|
+
function classifyStoredLine(raw, home) {
|
|
6142
|
+
let obj;
|
|
6143
|
+
try {
|
|
6144
|
+
obj = JSON.parse(raw);
|
|
6145
|
+
} catch {
|
|
6146
|
+
return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
|
|
6147
|
+
}
|
|
6148
|
+
const version = schemaVersionOf(obj);
|
|
6149
|
+
if (version === null) {
|
|
6150
|
+
return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
|
|
6151
|
+
}
|
|
6152
|
+
if (!isKnownSchema(version)) {
|
|
6153
|
+
return {
|
|
6154
|
+
status: "unknown_version",
|
|
6155
|
+
identity: recordIdentity(obj),
|
|
6156
|
+
schema: version,
|
|
6157
|
+
raw,
|
|
6158
|
+
reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
|
|
6159
|
+
};
|
|
6160
|
+
}
|
|
6161
|
+
const result = LogEventSchema.safeParse(obj);
|
|
6162
|
+
if (!result.success) {
|
|
6163
|
+
return {
|
|
6164
|
+
status: "invalid",
|
|
6165
|
+
identity: recordIdentity(obj),
|
|
6166
|
+
raw,
|
|
6167
|
+
reason: result.error.issues[0]?.message ?? "schema violation"
|
|
6168
|
+
};
|
|
6169
|
+
}
|
|
6170
|
+
const event = result.data;
|
|
6171
|
+
const identity = recordIdentity(event);
|
|
6172
|
+
if (identity === null) {
|
|
6173
|
+
return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
|
|
6174
|
+
}
|
|
6175
|
+
const redacted = redact(event, home);
|
|
6176
|
+
const provenance = version === 2 ? event.meta.provenance ?? null : null;
|
|
6177
|
+
return {
|
|
6178
|
+
status: "ok",
|
|
6179
|
+
identity,
|
|
6180
|
+
runId: event.meta.run_id,
|
|
6181
|
+
seq: event.meta.seq,
|
|
6182
|
+
schema: version,
|
|
6183
|
+
provenance,
|
|
6184
|
+
event,
|
|
6185
|
+
postLine: JSON.stringify(redacted)
|
|
6186
|
+
};
|
|
6187
|
+
}
|
|
6068
6188
|
// ../../packages/aeg-core/src/control-store/records.ts
|
|
6069
6189
|
import { z as z3 } from "zod";
|
|
6070
6190
|
var isoTimestamp = z3.string().min(1);
|
|
@@ -6195,11 +6315,12 @@ var ResolutionRecordSchema = z3.object({
|
|
|
6195
6315
|
consumedAt: isoTimestamp
|
|
6196
6316
|
}).strict();
|
|
6197
6317
|
// src/lib/diff-evidence.ts
|
|
6198
|
-
import { execFileSync as
|
|
6199
|
-
import { join as
|
|
6318
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
6319
|
+
import { join as join8, relative, resolve as resolve2 } from "node:path";
|
|
6200
6320
|
|
|
6201
6321
|
// src/lib/config.ts
|
|
6202
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6322
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
6323
|
+
import { promisify as promisify4 } from "node:util";
|
|
6203
6324
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
|
|
6204
6325
|
import { homedir } from "node:os";
|
|
6205
6326
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
@@ -6226,10 +6347,10 @@ var CheckEntrySchema = z4.object({
|
|
|
6226
6347
|
ownWorkflow: z4.boolean().optional(),
|
|
6227
6348
|
principalOwed: z4.literal(true).optional(),
|
|
6228
6349
|
validates: z4.enum(["body", "issue"]).optional()
|
|
6229
|
-
}).superRefine((
|
|
6230
|
-
if (!
|
|
6350
|
+
}).superRefine((entry, ctx) => {
|
|
6351
|
+
if (!entry.env)
|
|
6231
6352
|
return;
|
|
6232
|
-
for (const [key, value] of Object.entries(
|
|
6353
|
+
for (const [key, value] of Object.entries(entry.env)) {
|
|
6233
6354
|
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
6234
6355
|
continue;
|
|
6235
6356
|
const members = value.anyOf;
|
|
@@ -6386,18 +6507,19 @@ var VinayaConfigSchema = z4.object({
|
|
|
6386
6507
|
});
|
|
6387
6508
|
}
|
|
6388
6509
|
}).optional(),
|
|
6389
|
-
logPublish: z4.
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
}).refine((v) => v.
|
|
6398
|
-
message: "
|
|
6399
|
-
}).
|
|
6400
|
-
|
|
6510
|
+
logPublish: z4.unknown().refine((v) => v === undefined, {
|
|
6511
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
6512
|
+
}),
|
|
6513
|
+
runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
6514
|
+
logs: z4.object({
|
|
6515
|
+
folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
6516
|
+
url: z4.string().url().optional(),
|
|
6517
|
+
headers: z4.record(z4.string()).optional()
|
|
6518
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
6519
|
+
message: "logs: set at most one of folder/url"
|
|
6520
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
6521
|
+
message: "logs: headers requires url"
|
|
6522
|
+
}).optional()
|
|
6401
6523
|
});
|
|
6402
6524
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
6403
6525
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
@@ -6442,32 +6564,39 @@ function globalTokensCollectIgnoredWarning(path) {
|
|
|
6442
6564
|
function globalRuntimeDirIgnoredWarning(path) {
|
|
6443
6565
|
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.`;
|
|
6444
6566
|
}
|
|
6567
|
+
var emittedGlobalKeyWarnings = new Set;
|
|
6568
|
+
function warnGlobalKeyIgnoredOnce(message) {
|
|
6569
|
+
if (emittedGlobalKeyWarnings.has(message))
|
|
6570
|
+
return;
|
|
6571
|
+
emittedGlobalKeyWarnings.add(message);
|
|
6572
|
+
console.error(`⚠ ${message}`);
|
|
6573
|
+
}
|
|
6445
6574
|
function stripGlobalOnlyKeys(config, path) {
|
|
6446
6575
|
if (path !== GLOBAL_CONFIG_PATH)
|
|
6447
6576
|
return config;
|
|
6448
6577
|
let result = config;
|
|
6449
6578
|
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
6450
|
-
|
|
6579
|
+
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
6451
6580
|
result = { ...result, checks: undefined };
|
|
6452
6581
|
}
|
|
6453
6582
|
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
6454
|
-
|
|
6583
|
+
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
6455
6584
|
result = { ...result, roles: undefined };
|
|
6456
6585
|
}
|
|
6457
6586
|
if (result.principals && result.principals.length > 0) {
|
|
6458
|
-
|
|
6587
|
+
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
6459
6588
|
result = { ...result, principals: undefined };
|
|
6460
6589
|
}
|
|
6461
6590
|
if (result.releaseActor) {
|
|
6462
|
-
|
|
6591
|
+
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
6463
6592
|
result = { ...result, releaseActor: undefined };
|
|
6464
6593
|
}
|
|
6465
6594
|
if (result.tokens) {
|
|
6466
|
-
|
|
6595
|
+
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
6467
6596
|
result = { ...result, tokens: undefined };
|
|
6468
6597
|
}
|
|
6469
6598
|
if (result.runtimeDir) {
|
|
6470
|
-
|
|
6599
|
+
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
6471
6600
|
result = { ...result, runtimeDir: undefined };
|
|
6472
6601
|
}
|
|
6473
6602
|
return result;
|
|
@@ -6500,26 +6629,102 @@ function resolveReviewPolicy(config) {
|
|
|
6500
6629
|
maxRounds
|
|
6501
6630
|
};
|
|
6502
6631
|
}
|
|
6503
|
-
function
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6632
|
+
function resolveRuntimeDirSetting(config) {
|
|
6633
|
+
return config?.runtimeDir ?? null;
|
|
6634
|
+
}
|
|
6635
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
6636
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
6637
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
6638
|
+
}
|
|
6639
|
+
function resolveLogsSetting(config) {
|
|
6640
|
+
const raw = config?.logs;
|
|
6641
|
+
if (!raw)
|
|
6642
|
+
return null;
|
|
6643
|
+
if (raw.url !== undefined)
|
|
6644
|
+
return { url: raw.url, headers: raw.headers };
|
|
6645
|
+
if (raw.folder !== undefined)
|
|
6646
|
+
return { folder: raw.folder };
|
|
6647
|
+
return null;
|
|
6648
|
+
}
|
|
6649
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
6650
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
6651
|
+
if (!anchored)
|
|
6652
|
+
return null;
|
|
6653
|
+
if ("url" in local)
|
|
6654
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
6655
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
6656
|
+
}
|
|
6657
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
6658
|
+
if (!headers)
|
|
6659
|
+
return;
|
|
6660
|
+
const resolved = {};
|
|
6661
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
6662
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
6510
6663
|
}
|
|
6664
|
+
return resolved;
|
|
6665
|
+
}
|
|
6666
|
+
function trustAnchorRepo() {
|
|
6667
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6668
|
+
if (fromRunner)
|
|
6669
|
+
return fromRunner;
|
|
6511
6670
|
try {
|
|
6512
6671
|
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
6513
6672
|
encoding: "utf-8",
|
|
6514
6673
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6515
|
-
})
|
|
6516
|
-
|
|
6517
|
-
return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
|
|
6674
|
+
});
|
|
6675
|
+
return trustAnchorRepoFromRemoteUrl(url);
|
|
6518
6676
|
} catch {
|
|
6519
6677
|
return null;
|
|
6520
6678
|
}
|
|
6521
6679
|
}
|
|
6680
|
+
async function trustAnchorRepoAsync() {
|
|
6681
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6682
|
+
if (fromRunner)
|
|
6683
|
+
return fromRunner;
|
|
6684
|
+
try {
|
|
6685
|
+
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
6686
|
+
encoding: "utf-8",
|
|
6687
|
+
timeout: 1e4
|
|
6688
|
+
});
|
|
6689
|
+
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
6690
|
+
} catch {
|
|
6691
|
+
return null;
|
|
6692
|
+
}
|
|
6693
|
+
}
|
|
6694
|
+
function wellFormedRepoSlug(slug) {
|
|
6695
|
+
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
6696
|
+
}
|
|
6697
|
+
function trustAnchorRepoFromRunner() {
|
|
6698
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
6699
|
+
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
6700
|
+
}
|
|
6701
|
+
function trustAnchorRepoFromRemoteUrl(url) {
|
|
6702
|
+
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
6703
|
+
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
6704
|
+
}
|
|
6705
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
6706
|
+
function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
6707
|
+
const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
|
|
6708
|
+
if (!ref)
|
|
6709
|
+
return null;
|
|
6710
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
6711
|
+
return null;
|
|
6712
|
+
if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
|
|
6713
|
+
return null;
|
|
6714
|
+
return ref;
|
|
6715
|
+
}
|
|
6716
|
+
function readTrustAnchorConfigAtRef(ref) {
|
|
6717
|
+
const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6718
|
+
encoding: "utf-8",
|
|
6719
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
6720
|
+
timeout: 1e4
|
|
6721
|
+
});
|
|
6722
|
+
return Buffer.from(raw, "utf-8").toString("base64");
|
|
6723
|
+
}
|
|
6522
6724
|
function ghFetchTrustAnchorConfig() {
|
|
6725
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6726
|
+
if (probeRef)
|
|
6727
|
+
return readTrustAnchorConfigAtRef(probeRef);
|
|
6523
6728
|
const repo = trustAnchorRepo();
|
|
6524
6729
|
if (!repo)
|
|
6525
6730
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
@@ -6528,6 +6733,21 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6528
6733
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6529
6734
|
});
|
|
6530
6735
|
}
|
|
6736
|
+
async function ghFetchTrustAnchorConfigAsync() {
|
|
6737
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6738
|
+
if (probeRef) {
|
|
6739
|
+
const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6740
|
+
encoding: "utf-8",
|
|
6741
|
+
timeout: 1e4
|
|
6742
|
+
});
|
|
6743
|
+
return Buffer.from(stdout, "utf-8").toString("base64");
|
|
6744
|
+
}
|
|
6745
|
+
const repo = await trustAnchorRepoAsync();
|
|
6746
|
+
if (!repo)
|
|
6747
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6748
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
|
|
6749
|
+
return stdout;
|
|
6750
|
+
}
|
|
6531
6751
|
function firstLine(err) {
|
|
6532
6752
|
return err?.message?.split(`
|
|
6533
6753
|
`)[0] ?? "unknown error";
|
|
@@ -6542,16 +6762,35 @@ function isMissingFileError(err) {
|
|
|
6542
6762
|
return /\b404\b|not found/i.test(haystack);
|
|
6543
6763
|
}
|
|
6544
6764
|
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
6545
|
-
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.
|
|
6546
|
-
`);
|
|
6547
6765
|
let base64;
|
|
6548
6766
|
try {
|
|
6549
|
-
base64 = fetcher()
|
|
6767
|
+
base64 = fetcher();
|
|
6550
6768
|
} catch (err) {
|
|
6551
|
-
|
|
6552
|
-
warn(firstLine(err));
|
|
6553
|
-
return null;
|
|
6769
|
+
return trustAnchorFetchFailed(err);
|
|
6554
6770
|
}
|
|
6771
|
+
return parseTrustAnchorContent(base64);
|
|
6772
|
+
}
|
|
6773
|
+
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
6774
|
+
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
6775
|
+
let base64;
|
|
6776
|
+
try {
|
|
6777
|
+
base64 = await fetcher();
|
|
6778
|
+
} catch (err) {
|
|
6779
|
+
return trustAnchorFetchFailed(err, warn);
|
|
6780
|
+
}
|
|
6781
|
+
return parseTrustAnchorContent(base64, warn);
|
|
6782
|
+
}
|
|
6783
|
+
function warnTrustAnchorFallback(why) {
|
|
6784
|
+
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.
|
|
6785
|
+
`);
|
|
6786
|
+
}
|
|
6787
|
+
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
6788
|
+
if (!isMissingFileError(err))
|
|
6789
|
+
warn(firstLine(err));
|
|
6790
|
+
return null;
|
|
6791
|
+
}
|
|
6792
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
6793
|
+
const base64 = content.trim();
|
|
6555
6794
|
if (!base64)
|
|
6556
6795
|
return null;
|
|
6557
6796
|
try {
|
|
@@ -6581,6 +6820,8 @@ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.j
|
|
|
6581
6820
|
|
|
6582
6821
|
// src/lib/brief-assembly.ts
|
|
6583
6822
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
6823
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
|
|
6824
|
+
import { join as join3 } from "node:path";
|
|
6584
6825
|
|
|
6585
6826
|
// ../../packages/sources/src/commands.ts
|
|
6586
6827
|
var COMMANDS = [
|
|
@@ -6733,10 +6974,10 @@ var COMMANDS = [
|
|
|
6733
6974
|
}
|
|
6734
6975
|
],
|
|
6735
6976
|
details: [
|
|
6736
|
-
"Composes `task brief`'s own preparation (`prepareTask`) with `dev-review-loop`
|
|
6977
|
+
"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.",
|
|
6737
6978
|
"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.",
|
|
6738
|
-
"Refuses when the frozen brief's developer branch already has an open pull request —
|
|
6739
|
-
"Exit and printed summary distinguish a published
|
|
6979
|
+
"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.",
|
|
6980
|
+
"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`)."
|
|
6740
6981
|
],
|
|
6741
6982
|
status: "shipped"
|
|
6742
6983
|
},
|
|
@@ -6775,7 +7016,7 @@ var COMMANDS = [
|
|
|
6775
7016
|
details: [
|
|
6776
7017
|
"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.",
|
|
6777
7018
|
"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.",
|
|
6778
|
-
"`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."
|
|
7019
|
+
"`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."
|
|
6779
7020
|
],
|
|
6780
7021
|
status: "shipped"
|
|
6781
7022
|
},
|
|
@@ -6905,48 +7146,6 @@ var COMMANDS = [
|
|
|
6905
7146
|
],
|
|
6906
7147
|
status: "shipped"
|
|
6907
7148
|
},
|
|
6908
|
-
{
|
|
6909
|
-
name: "log flush",
|
|
6910
|
-
description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
|
|
6911
|
-
flags: [
|
|
6912
|
-
{ flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
|
|
6913
|
-
{
|
|
6914
|
-
flag: "--pr",
|
|
6915
|
-
description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
|
|
6916
|
-
},
|
|
6917
|
-
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
6918
|
-
],
|
|
6919
|
-
details: [
|
|
6920
|
-
"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.",
|
|
6921
|
-
"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.",
|
|
6922
|
-
"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."
|
|
6923
|
-
],
|
|
6924
|
-
status: "shipped"
|
|
6925
|
-
},
|
|
6926
|
-
{
|
|
6927
|
-
name: "log export-artifact",
|
|
6928
|
-
description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
|
|
6929
|
-
flags: [],
|
|
6930
|
-
details: [
|
|
6931
|
-
"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.",
|
|
6932
|
-
"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."
|
|
6933
|
-
],
|
|
6934
|
-
status: "shipped"
|
|
6935
|
-
},
|
|
6936
|
-
{
|
|
6937
|
-
name: "log collect-artifact",
|
|
6938
|
-
description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
|
|
6939
|
-
flags: [
|
|
6940
|
-
{ flag: "--pr", description: "The pull request this artifact belongs to" },
|
|
6941
|
-
{ flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
|
|
6942
|
-
],
|
|
6943
|
-
details: [
|
|
6944
|
-
"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.",
|
|
6945
|
-
"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.",
|
|
6946
|
-
"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."
|
|
6947
|
-
],
|
|
6948
|
-
status: "shipped"
|
|
6949
|
-
},
|
|
6950
7149
|
{
|
|
6951
7150
|
name: "milestone create",
|
|
6952
7151
|
description: "Create a GitHub Milestone from a validated body",
|
|
@@ -7276,7 +7475,7 @@ var COMMANDS = [
|
|
|
7276
7475
|
{ flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
|
|
7277
7476
|
{
|
|
7278
7477
|
flag: "--pr",
|
|
7279
|
-
description: "
|
|
7478
|
+
description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
|
|
7280
7479
|
},
|
|
7281
7480
|
{ flag: "--round", description: "Round number, for a dispatch inside a review loop" },
|
|
7282
7481
|
{
|
|
@@ -7288,7 +7487,7 @@ var COMMANDS = [
|
|
|
7288
7487
|
details: [
|
|
7289
7488
|
"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.",
|
|
7290
7489
|
"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`.",
|
|
7291
|
-
"
|
|
7490
|
+
"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.",
|
|
7292
7491
|
"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."
|
|
7293
7492
|
],
|
|
7294
7493
|
status: "shipped"
|
|
@@ -7308,7 +7507,8 @@ var COMMANDS = [
|
|
|
7308
7507
|
"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> -->`.",
|
|
7309
7508
|
"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.",
|
|
7310
7509
|
"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.",
|
|
7311
|
-
"Every dispatch and round transition is a log line through the Vinaya Log,
|
|
7510
|
+
"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.",
|
|
7511
|
+
"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)."
|
|
7312
7512
|
],
|
|
7313
7513
|
status: "shipped"
|
|
7314
7514
|
}
|
|
@@ -7445,25 +7645,6 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
7445
7645
|
};
|
|
7446
7646
|
}
|
|
7447
7647
|
|
|
7448
|
-
// src/lib/brief-assembly.ts
|
|
7449
|
-
function git(args) {
|
|
7450
|
-
try {
|
|
7451
|
-
return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7452
|
-
} catch {
|
|
7453
|
-
return "";
|
|
7454
|
-
}
|
|
7455
|
-
}
|
|
7456
|
-
function expandGlob(glob) {
|
|
7457
|
-
const out = git(["ls-files", "--", glob]);
|
|
7458
|
-
return out.split(`
|
|
7459
|
-
`).map((s) => s.trim()).filter(Boolean);
|
|
7460
|
-
}
|
|
7461
|
-
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
7462
|
-
|
|
7463
|
-
// src/checks/registry.ts
|
|
7464
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
7465
|
-
import { join as join3 } from "node:path";
|
|
7466
|
-
|
|
7467
7648
|
// src/lib/package-root.ts
|
|
7468
7649
|
import { existsSync as existsSync2 } from "node:fs";
|
|
7469
7650
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
@@ -7481,13 +7662,33 @@ function packageRoot(moduleUrl) {
|
|
|
7481
7662
|
return dir;
|
|
7482
7663
|
}
|
|
7483
7664
|
|
|
7665
|
+
// src/lib/brief-assembly.ts
|
|
7666
|
+
var PACKAGE_ROOT = packageRoot(import.meta.url);
|
|
7667
|
+
var PACKAGED_TEMPLATE_PATH = join3(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
|
|
7668
|
+
var TEMPLATE_PATH = existsSync3(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join3(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
7669
|
+
function git(args) {
|
|
7670
|
+
try {
|
|
7671
|
+
return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7672
|
+
} catch {
|
|
7673
|
+
return "";
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
function expandGlob(glob) {
|
|
7677
|
+
const out = git(["ls-files", "--", glob]);
|
|
7678
|
+
return out.split(`
|
|
7679
|
+
`).map((s) => s.trim()).filter(Boolean);
|
|
7680
|
+
}
|
|
7681
|
+
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
7682
|
+
|
|
7484
7683
|
// src/checks/registry.ts
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
var
|
|
7684
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
7685
|
+
import { join as join4 } from "node:path";
|
|
7686
|
+
var DIST_BIN_DIR = join4(packageRoot(import.meta.url), "dist", "checks", "bin");
|
|
7687
|
+
var SRC_BIN_DIR = join4(packageRoot(import.meta.url), "src", "checks", "bin");
|
|
7688
|
+
var BIN_DIR = existsSync4(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
|
|
7488
7689
|
var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
|
|
7489
7690
|
function bin(name) {
|
|
7490
|
-
return
|
|
7691
|
+
return join4(BIN_DIR, `${name}${BIN_EXT}`);
|
|
7491
7692
|
}
|
|
7492
7693
|
var REGISTRY = [
|
|
7493
7694
|
[
|
|
@@ -7899,6 +8100,16 @@ var REGISTRY = [
|
|
|
7899
8100
|
},
|
|
7900
8101
|
0
|
|
7901
8102
|
],
|
|
8103
|
+
[
|
|
8104
|
+
{
|
|
8105
|
+
name: "ci-shard-coverage",
|
|
8106
|
+
run: bin("check-ci-shard-coverage"),
|
|
8107
|
+
scope: "diff",
|
|
8108
|
+
timeoutMs: 15000,
|
|
8109
|
+
env: {}
|
|
8110
|
+
},
|
|
8111
|
+
0
|
|
8112
|
+
],
|
|
7902
8113
|
[
|
|
7903
8114
|
{
|
|
7904
8115
|
name: "workspace-escape",
|
|
@@ -8036,42 +8247,541 @@ function coreCheckRegistry() {
|
|
|
8036
8247
|
var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.name, ring]));
|
|
8037
8248
|
|
|
8038
8249
|
// src/lib/log-sink.ts
|
|
8039
|
-
import {
|
|
8040
|
-
import { randomUUID } from "node:crypto";
|
|
8250
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
8251
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
8252
|
+
import {
|
|
8253
|
+
closeSync as closeSync3,
|
|
8254
|
+
constants as fsConstants3,
|
|
8255
|
+
existsSync as existsSync6,
|
|
8256
|
+
fstatSync as fstatSync2,
|
|
8257
|
+
mkdirSync as mkdirSync3,
|
|
8258
|
+
openSync as openSync3,
|
|
8259
|
+
readFileSync as readFileSync5,
|
|
8260
|
+
renameSync as renameSync2,
|
|
8261
|
+
writeSync as writeSync2
|
|
8262
|
+
} from "node:fs";
|
|
8263
|
+
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
8264
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
8265
|
+
import { promisify as promisify5 } from "node:util";
|
|
8266
|
+
|
|
8267
|
+
// src/lib/run-paths.ts
|
|
8268
|
+
import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
8269
|
+
import { dirname as dirname3, join as join5, resolve as resolvePath } from "node:path";
|
|
8270
|
+
var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8271
|
+
function isSafeRepoSegment(segment) {
|
|
8272
|
+
return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
|
|
8273
|
+
}
|
|
8274
|
+
function repoSegment(repo) {
|
|
8275
|
+
if (!repo || !isSafeRepoSegment(repo.owner) || !isSafeRepoSegment(repo.repo))
|
|
8276
|
+
return "unresolved";
|
|
8277
|
+
return `${repo.owner}-${repo.repo}`;
|
|
8278
|
+
}
|
|
8279
|
+
function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
|
|
8280
|
+
return join5(home, "runtime", repoSegment(repo));
|
|
8281
|
+
}
|
|
8282
|
+
function resolveRuntimeDir(input) {
|
|
8283
|
+
const local = resolveRuntimeDirSetting(input.localConfig);
|
|
8284
|
+
if (local === null)
|
|
8285
|
+
return defaultRuntimeDir(input.repo, input.home);
|
|
8286
|
+
if (isInsideRepo(local, input.repoRoot))
|
|
8287
|
+
return defaultRuntimeDir(input.repo, input.home);
|
|
8288
|
+
if (!input.unattended)
|
|
8289
|
+
return local;
|
|
8290
|
+
const anchored = resolveTrustAnchorRuntimeDir(local, input.trustAnchorConfig ?? null);
|
|
8291
|
+
return anchored ?? defaultRuntimeDir(input.repo, input.home);
|
|
8292
|
+
}
|
|
8293
|
+
function isInsideRepo(candidate, repoRoot) {
|
|
8294
|
+
if (!repoRoot)
|
|
8295
|
+
return false;
|
|
8296
|
+
const root = resolvePath(repoRoot);
|
|
8297
|
+
const target = resolvePath(candidate);
|
|
8298
|
+
return target === root || target.startsWith(`${root}/`);
|
|
8299
|
+
}
|
|
8300
|
+
var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
|
|
8301
|
+
var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
|
|
8302
|
+
function isUnattendedProcess(env = process.env) {
|
|
8303
|
+
return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
|
|
8304
|
+
}
|
|
8305
|
+
var memoized = null;
|
|
8306
|
+
async function runtimeDirForRepoAsync(repo) {
|
|
8307
|
+
const key = repoSegment(repo);
|
|
8308
|
+
if (memoized?.key === key)
|
|
8309
|
+
return memoized.value;
|
|
8310
|
+
const inputs = runtimeDirInputs();
|
|
8311
|
+
if (typeof inputs === "string")
|
|
8312
|
+
return inputs;
|
|
8313
|
+
const value = resolveRuntimeDir({
|
|
8314
|
+
repo,
|
|
8315
|
+
...inputs.base,
|
|
8316
|
+
trustAnchorConfig: inputs.needsAnchor ? await loadTrustAnchorConfigAsync() : null
|
|
8317
|
+
});
|
|
8318
|
+
memoized = { key, value };
|
|
8319
|
+
return value;
|
|
8320
|
+
}
|
|
8321
|
+
function runtimeDirInputs() {
|
|
8322
|
+
const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
|
|
8323
|
+
if (handedDown)
|
|
8324
|
+
return handedDown;
|
|
8325
|
+
const localConfig = loadConfig();
|
|
8326
|
+
const unattended = isUnattendedProcess();
|
|
8327
|
+
return {
|
|
8328
|
+
base: { localConfig, unattended, repoRoot: repoRootSync() },
|
|
8329
|
+
needsAnchor: unattended && resolveRuntimeDirSetting(localConfig) !== null
|
|
8330
|
+
};
|
|
8331
|
+
}
|
|
8332
|
+
function repoRootSync(start = process.cwd()) {
|
|
8333
|
+
let dir;
|
|
8334
|
+
try {
|
|
8335
|
+
dir = realpathSync2(start);
|
|
8336
|
+
} catch {
|
|
8337
|
+
return null;
|
|
8338
|
+
}
|
|
8339
|
+
for (;; ) {
|
|
8340
|
+
if (existsSync5(join5(dir, ".git")))
|
|
8341
|
+
return dir;
|
|
8342
|
+
const parent = dirname3(dir);
|
|
8343
|
+
if (parent === dir)
|
|
8344
|
+
return null;
|
|
8345
|
+
dir = parent;
|
|
8346
|
+
}
|
|
8347
|
+
}
|
|
8348
|
+
|
|
8349
|
+
// src/lib/log-webhook-drain.ts
|
|
8041
8350
|
import {
|
|
8042
8351
|
closeSync as closeSync2,
|
|
8043
8352
|
constants as fsConstants2,
|
|
8044
|
-
|
|
8045
|
-
fstatSync as fstatSync2,
|
|
8353
|
+
lstatSync,
|
|
8046
8354
|
mkdirSync as mkdirSync2,
|
|
8047
8355
|
openSync as openSync2,
|
|
8048
|
-
|
|
8356
|
+
linkSync,
|
|
8357
|
+
readFileSync as readFileSync4,
|
|
8049
8358
|
renameSync,
|
|
8359
|
+
statSync,
|
|
8360
|
+
unlinkSync,
|
|
8361
|
+
utimesSync,
|
|
8362
|
+
writeFileSync as writeFileSync2,
|
|
8050
8363
|
writeSync
|
|
8051
8364
|
} from "node:fs";
|
|
8052
|
-
import {
|
|
8053
|
-
import {
|
|
8054
|
-
|
|
8365
|
+
import { randomUUID } from "node:crypto";
|
|
8366
|
+
import { homedir as homedir2 } from "node:os";
|
|
8367
|
+
import { dirname as dirname4, join as join6 } from "node:path";
|
|
8368
|
+
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
8369
|
+
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
8370
|
+
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8371
|
+
function isSafeRepoSegment2(segment) {
|
|
8372
|
+
return SAFE_PATH_SEGMENT2.test(segment) && !segment.includes("..");
|
|
8373
|
+
}
|
|
8374
|
+
function isErrnoCode(err, code) {
|
|
8375
|
+
return typeof err === "object" && err !== null && err.code === code;
|
|
8376
|
+
}
|
|
8055
8377
|
function isEnoent(err) {
|
|
8378
|
+
return isErrnoCode(err, "ENOENT");
|
|
8379
|
+
}
|
|
8380
|
+
var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
|
|
8381
|
+
function tryCreateLock(lockPath, token) {
|
|
8382
|
+
try {
|
|
8383
|
+
mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
|
|
8384
|
+
const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
|
|
8385
|
+
try {
|
|
8386
|
+
writeSync(fd, `${token}
|
|
8387
|
+
`);
|
|
8388
|
+
} finally {
|
|
8389
|
+
closeSync2(fd);
|
|
8390
|
+
}
|
|
8391
|
+
return true;
|
|
8392
|
+
} catch (err) {
|
|
8393
|
+
if (isErrnoCode(err, "EEXIST"))
|
|
8394
|
+
return false;
|
|
8395
|
+
throw err;
|
|
8396
|
+
}
|
|
8397
|
+
}
|
|
8398
|
+
function acquireDrainLock(lockPath) {
|
|
8399
|
+
const token = `${process.pid}:${randomUUID()}`;
|
|
8400
|
+
if (tryCreateLock(lockPath, token))
|
|
8401
|
+
return token;
|
|
8402
|
+
let observedMtimeMs;
|
|
8403
|
+
try {
|
|
8404
|
+
observedMtimeMs = statSync(lockPath).mtimeMs;
|
|
8405
|
+
} catch (err) {
|
|
8406
|
+
if (!isEnoent(err))
|
|
8407
|
+
throw err;
|
|
8408
|
+
return tryCreateLock(lockPath, token) ? token : null;
|
|
8409
|
+
}
|
|
8410
|
+
if (Date.now() - observedMtimeMs <= WEBHOOK_DRAIN_LOCK_STALE_MS)
|
|
8411
|
+
return null;
|
|
8412
|
+
const claimed = `${lockPath}.claimed-${randomUUID()}`;
|
|
8413
|
+
try {
|
|
8414
|
+
renameSync(lockPath, claimed);
|
|
8415
|
+
} catch (err) {
|
|
8416
|
+
if (isEnoent(err))
|
|
8417
|
+
return null;
|
|
8418
|
+
throw err;
|
|
8419
|
+
}
|
|
8420
|
+
let claimedMtimeMs = null;
|
|
8421
|
+
try {
|
|
8422
|
+
claimedMtimeMs = statSync(claimed).mtimeMs;
|
|
8423
|
+
} catch (err) {
|
|
8424
|
+
if (!isEnoent(err))
|
|
8425
|
+
throw err;
|
|
8426
|
+
}
|
|
8427
|
+
if (claimedMtimeMs !== observedMtimeMs) {
|
|
8428
|
+
try {
|
|
8429
|
+
linkSync(claimed, lockPath);
|
|
8430
|
+
} catch (err) {
|
|
8431
|
+
if (!isErrnoCode(err, "EEXIST"))
|
|
8432
|
+
throw err;
|
|
8433
|
+
}
|
|
8434
|
+
try {
|
|
8435
|
+
unlinkSync(claimed);
|
|
8436
|
+
} catch (err) {
|
|
8437
|
+
if (!isEnoent(err))
|
|
8438
|
+
throw err;
|
|
8439
|
+
}
|
|
8440
|
+
return null;
|
|
8441
|
+
}
|
|
8442
|
+
unlinkSync(claimed);
|
|
8443
|
+
return tryCreateLock(lockPath, token) ? token : null;
|
|
8444
|
+
}
|
|
8445
|
+
function renewDrainLock(lockPath, token) {
|
|
8446
|
+
let holder;
|
|
8447
|
+
try {
|
|
8448
|
+
holder = readFileSync4(lockPath, "utf8").trim();
|
|
8449
|
+
} catch (err) {
|
|
8450
|
+
if (!isEnoent(err))
|
|
8451
|
+
throw err;
|
|
8452
|
+
return false;
|
|
8453
|
+
}
|
|
8454
|
+
if (holder !== token)
|
|
8455
|
+
return false;
|
|
8456
|
+
const now = new Date;
|
|
8457
|
+
try {
|
|
8458
|
+
utimesSync(lockPath, now, now);
|
|
8459
|
+
} catch (err) {
|
|
8460
|
+
if (!isEnoent(err))
|
|
8461
|
+
throw err;
|
|
8462
|
+
return false;
|
|
8463
|
+
}
|
|
8464
|
+
return true;
|
|
8465
|
+
}
|
|
8466
|
+
function releaseDrainLock(lockPath, token) {
|
|
8467
|
+
try {
|
|
8468
|
+
const holder = readFileSync4(lockPath, "utf8").trim();
|
|
8469
|
+
if (holder !== token)
|
|
8470
|
+
return;
|
|
8471
|
+
unlinkSync(lockPath);
|
|
8472
|
+
} catch (err) {
|
|
8473
|
+
if (!isEnoent(err))
|
|
8474
|
+
throw err;
|
|
8475
|
+
}
|
|
8476
|
+
}
|
|
8477
|
+
|
|
8478
|
+
class WebhookDrainError extends Error {
|
|
8479
|
+
code;
|
|
8480
|
+
constructor(code, message) {
|
|
8481
|
+
super(message);
|
|
8482
|
+
this.code = code;
|
|
8483
|
+
}
|
|
8484
|
+
}
|
|
8485
|
+
function backupPathFor(queuePath) {
|
|
8486
|
+
return queuePath.replace(/\.ndjson$/, ".1.ndjson");
|
|
8487
|
+
}
|
|
8488
|
+
function drainingPathFor(queuePath) {
|
|
8489
|
+
return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
|
|
8490
|
+
}
|
|
8491
|
+
function rejectedPathFor(queuePath) {
|
|
8492
|
+
return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
|
|
8493
|
+
}
|
|
8494
|
+
var rejectionWarnedThisProcess = false;
|
|
8495
|
+
function warnRejectionOnce(message) {
|
|
8496
|
+
if (rejectionWarnedThisProcess)
|
|
8497
|
+
return;
|
|
8498
|
+
rejectionWarnedThisProcess = true;
|
|
8499
|
+
try {
|
|
8500
|
+
process.stderr.write(message);
|
|
8501
|
+
} catch {}
|
|
8502
|
+
}
|
|
8503
|
+
function queueLines(buf) {
|
|
8504
|
+
const lines = [];
|
|
8505
|
+
let start = 0;
|
|
8506
|
+
for (let i = 0;i < buf.byteLength; i++) {
|
|
8507
|
+
if (buf[i] !== 10)
|
|
8508
|
+
continue;
|
|
8509
|
+
if (i > start)
|
|
8510
|
+
lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
|
|
8511
|
+
start = i + 1;
|
|
8512
|
+
}
|
|
8513
|
+
if (start < buf.byteLength)
|
|
8514
|
+
lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
|
|
8515
|
+
return lines;
|
|
8516
|
+
}
|
|
8517
|
+
function removeQueueHead(path, cut) {
|
|
8518
|
+
const remaining = readFileSync4(path);
|
|
8519
|
+
writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
|
|
8520
|
+
}
|
|
8521
|
+
function queueBucketSize(path) {
|
|
8522
|
+
let lstat;
|
|
8523
|
+
try {
|
|
8524
|
+
lstat = lstatSync(path);
|
|
8525
|
+
} catch (err) {
|
|
8526
|
+
if (!isEnoent(err))
|
|
8527
|
+
throw err;
|
|
8528
|
+
}
|
|
8529
|
+
if (lstat === undefined)
|
|
8530
|
+
return null;
|
|
8531
|
+
if (!lstat.isFile()) {
|
|
8532
|
+
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}`);
|
|
8533
|
+
}
|
|
8534
|
+
return Number(lstat.size);
|
|
8535
|
+
}
|
|
8536
|
+
function readQueueFile(path) {
|
|
8537
|
+
if (queueBucketSize(path) === null)
|
|
8538
|
+
return null;
|
|
8539
|
+
return readFileSync4(path);
|
|
8540
|
+
}
|
|
8541
|
+
function rejectLine(rejectedPath, reason, status, identity, raw) {
|
|
8542
|
+
const record = JSON.stringify({
|
|
8543
|
+
rejected_at: new Date().toISOString(),
|
|
8544
|
+
status,
|
|
8545
|
+
reason,
|
|
8546
|
+
identity,
|
|
8547
|
+
bytes: Buffer.byteLength(raw, "utf8"),
|
|
8548
|
+
raw
|
|
8549
|
+
});
|
|
8550
|
+
const failure = appendHardenedLine(rejectedPath, `${record}
|
|
8551
|
+
`);
|
|
8552
|
+
if (failure !== null) {
|
|
8553
|
+
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`);
|
|
8554
|
+
}
|
|
8555
|
+
warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
|
|
8556
|
+
`);
|
|
8557
|
+
}
|
|
8558
|
+
async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
|
|
8559
|
+
const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
|
|
8560
|
+
let response;
|
|
8561
|
+
try {
|
|
8562
|
+
response = await fetch(webhookUrl, {
|
|
8563
|
+
method: "POST",
|
|
8564
|
+
headers: { "content-type": "application/x-ndjson", ...headers },
|
|
8565
|
+
body,
|
|
8566
|
+
signal: AbortSignal.timeout(fetchTimeoutMs)
|
|
8567
|
+
});
|
|
8568
|
+
} catch (err) {
|
|
8569
|
+
const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
|
|
8570
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
|
|
8571
|
+
}
|
|
8572
|
+
if (!response.ok) {
|
|
8573
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
|
|
8574
|
+
}
|
|
8575
|
+
}
|
|
8576
|
+
async function drainQueueFile(args) {
|
|
8577
|
+
const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
|
|
8578
|
+
const buf = readQueueFile(path);
|
|
8579
|
+
if (buf === null || buf.byteLength === 0)
|
|
8580
|
+
return;
|
|
8581
|
+
const lines = queueLines(buf);
|
|
8582
|
+
if (lines.length === 0) {
|
|
8583
|
+
removeQueueHead(path, buf.byteLength);
|
|
8584
|
+
return;
|
|
8585
|
+
}
|
|
8586
|
+
let removed = 0;
|
|
8587
|
+
let pendingEnd = 0;
|
|
8588
|
+
let chunk = [];
|
|
8589
|
+
let chunkBytes = 0;
|
|
8590
|
+
const deliverChunk = async () => {
|
|
8591
|
+
const body = `${chunk.join(`
|
|
8592
|
+
`)}
|
|
8593
|
+
`;
|
|
8594
|
+
args.keepLock();
|
|
8595
|
+
await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
|
|
8596
|
+
totals.chunks += 1;
|
|
8597
|
+
totals.lineCount += chunk.length;
|
|
8598
|
+
totals.bytes += Buffer.byteLength(body, "utf8");
|
|
8599
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8600
|
+
removed = pendingEnd;
|
|
8601
|
+
chunk = [];
|
|
8602
|
+
chunkBytes = 0;
|
|
8603
|
+
};
|
|
8604
|
+
const setAside = async (reason, status, identity, line) => {
|
|
8605
|
+
if (chunk.length > 0)
|
|
8606
|
+
await deliverChunk();
|
|
8607
|
+
rejectLine(rejectedPath, reason, status, identity, line.raw);
|
|
8608
|
+
totals.rejected += 1;
|
|
8609
|
+
pendingEnd = line.end;
|
|
8610
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8611
|
+
removed = pendingEnd;
|
|
8612
|
+
};
|
|
8613
|
+
for (const line of lines) {
|
|
8614
|
+
const record = classifyStoredLine(line.raw, homedir2());
|
|
8615
|
+
if (record.status !== "ok") {
|
|
8616
|
+
await setAside(record.reason, record.status, record.identity, line);
|
|
8617
|
+
continue;
|
|
8618
|
+
}
|
|
8619
|
+
const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
|
|
8620
|
+
if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
|
|
8621
|
+
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);
|
|
8622
|
+
continue;
|
|
8623
|
+
}
|
|
8624
|
+
if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
|
|
8625
|
+
await deliverChunk();
|
|
8626
|
+
chunk.push(record.postLine);
|
|
8627
|
+
chunkBytes += lineBytes;
|
|
8628
|
+
pendingEnd = line.end;
|
|
8629
|
+
}
|
|
8630
|
+
pendingEnd = buf.byteLength;
|
|
8631
|
+
if (chunk.length > 0) {
|
|
8632
|
+
await deliverChunk();
|
|
8633
|
+
return;
|
|
8634
|
+
}
|
|
8635
|
+
if (pendingEnd > removed)
|
|
8636
|
+
removeQueueHead(path, pendingEnd - removed);
|
|
8637
|
+
}
|
|
8638
|
+
async function drainRenamedAside(args, livePath, source) {
|
|
8639
|
+
args.keepLock();
|
|
8640
|
+
const draining = drainingPathFor(livePath);
|
|
8641
|
+
try {
|
|
8642
|
+
renameSync(source, draining);
|
|
8643
|
+
} catch (err) {
|
|
8644
|
+
if (isEnoent(err))
|
|
8645
|
+
return;
|
|
8646
|
+
throw err;
|
|
8647
|
+
}
|
|
8648
|
+
await drainQueueFile({ ...args, path: draining });
|
|
8649
|
+
unlinkSync(draining);
|
|
8650
|
+
}
|
|
8651
|
+
async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
|
|
8652
|
+
const resolved = await resolveRepo();
|
|
8653
|
+
const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
|
|
8654
|
+
const outboxRoot = () => join6(GLOBAL_VINAYA_HOME, "outbox");
|
|
8655
|
+
const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
|
|
8656
|
+
const lockPath = `${path}.flush-lock`;
|
|
8657
|
+
const lockToken = acquireDrainLock(lockPath);
|
|
8658
|
+
const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
|
|
8659
|
+
if (lockToken === null)
|
|
8660
|
+
return { flushed: false, ...totals };
|
|
8661
|
+
try {
|
|
8662
|
+
const keepLock = () => {
|
|
8663
|
+
if (renewDrainLock(lockPath, lockToken))
|
|
8664
|
+
return;
|
|
8665
|
+
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`);
|
|
8666
|
+
};
|
|
8667
|
+
const shared = {
|
|
8668
|
+
rejectedPath: rejectedPathFor(path),
|
|
8669
|
+
webhookUrl,
|
|
8670
|
+
headers,
|
|
8671
|
+
fetchTimeoutMs,
|
|
8672
|
+
totals,
|
|
8673
|
+
keepLock
|
|
8674
|
+
};
|
|
8675
|
+
const draining = drainingPathFor(path);
|
|
8676
|
+
if (queueBucketSize(draining) !== null) {
|
|
8677
|
+
keepLock();
|
|
8678
|
+
await drainQueueFile({ ...shared, path: draining });
|
|
8679
|
+
unlinkSync(draining);
|
|
8680
|
+
}
|
|
8681
|
+
await drainRenamedAside(shared, path, backupPathFor(path));
|
|
8682
|
+
await drainRenamedAside(shared, path, path);
|
|
8683
|
+
return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
|
|
8684
|
+
} finally {
|
|
8685
|
+
releaseDrainLock(lockPath, lockToken);
|
|
8686
|
+
}
|
|
8687
|
+
}
|
|
8688
|
+
|
|
8689
|
+
// src/lib/log-sink.ts
|
|
8690
|
+
var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
|
|
8691
|
+
var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
|
|
8692
|
+
function withDeadline(work, ms, fallback) {
|
|
8693
|
+
return new Promise((resolve) => {
|
|
8694
|
+
const timer = setTimeout(() => resolve(fallback), ms);
|
|
8695
|
+
timer.unref?.();
|
|
8696
|
+
work.then((value) => {
|
|
8697
|
+
clearTimeout(timer);
|
|
8698
|
+
resolve(value);
|
|
8699
|
+
}, () => {
|
|
8700
|
+
clearTimeout(timer);
|
|
8701
|
+
resolve(fallback);
|
|
8702
|
+
});
|
|
8703
|
+
});
|
|
8704
|
+
}
|
|
8705
|
+
async function safeLoadTrustAnchorConfig() {
|
|
8706
|
+
return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
8707
|
+
}
|
|
8708
|
+
function logsCredentialMissing(headers, env) {
|
|
8709
|
+
if (!headers)
|
|
8710
|
+
return false;
|
|
8711
|
+
const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
8712
|
+
for (const value of Object.values(headers)) {
|
|
8713
|
+
for (const match of value.matchAll(varPattern)) {
|
|
8714
|
+
if (!env[match[1]])
|
|
8715
|
+
return true;
|
|
8716
|
+
}
|
|
8717
|
+
}
|
|
8718
|
+
return false;
|
|
8719
|
+
}
|
|
8720
|
+
function resolveLogDestinationFrom(input) {
|
|
8721
|
+
const local = resolveLogsSetting(input.localConfig);
|
|
8722
|
+
let effective = null;
|
|
8723
|
+
if (input.unattended) {
|
|
8724
|
+
effective = local ? resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig) : resolveLogsSetting(input.trustAnchorConfig);
|
|
8725
|
+
} else {
|
|
8726
|
+
effective = local;
|
|
8727
|
+
}
|
|
8728
|
+
if (hostFromEnv(input.env) === "ci") {
|
|
8729
|
+
if (effective && "url" in effective) {
|
|
8730
|
+
if (logsCredentialMissing(effective.headers, input.env)) {
|
|
8731
|
+
return {
|
|
8732
|
+
kind: "none",
|
|
8733
|
+
reason: "a logs.url server destination is configured, but this job holds no delivery credential (a fork pull request, or a missing repository secret)"
|
|
8734
|
+
};
|
|
8735
|
+
}
|
|
8736
|
+
return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
|
|
8737
|
+
}
|
|
8738
|
+
return {
|
|
8739
|
+
kind: "none",
|
|
8740
|
+
reason: "no server destination is configured for CI delivery (vinaya.config.json logs.url)"
|
|
8741
|
+
};
|
|
8742
|
+
}
|
|
8743
|
+
if (effective && "url" in effective) {
|
|
8744
|
+
return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
|
|
8745
|
+
}
|
|
8746
|
+
if (effective && "folder" in effective && isInsideRepo(effective.folder, input.repoRoot)) {
|
|
8747
|
+
effective = null;
|
|
8748
|
+
}
|
|
8749
|
+
const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
|
|
8750
|
+
return { kind: "folder", folder };
|
|
8751
|
+
}
|
|
8752
|
+
var processTrustAnchorOnce;
|
|
8753
|
+
function processTrustAnchor() {
|
|
8754
|
+
if (processTrustAnchorOnce === undefined)
|
|
8755
|
+
processTrustAnchorOnce = safeLoadTrustAnchorConfig();
|
|
8756
|
+
return processTrustAnchorOnce;
|
|
8757
|
+
}
|
|
8758
|
+
async function defaultResolveLogDestination(repo, env) {
|
|
8759
|
+
const localConfig = loadConfig();
|
|
8760
|
+
const unattended = isUnattendedProcess(process.env);
|
|
8761
|
+
return resolveLogDestinationFrom({
|
|
8762
|
+
localConfig,
|
|
8763
|
+
trustAnchorConfig: unattended ? await processTrustAnchor() : null,
|
|
8764
|
+
unattended,
|
|
8765
|
+
env,
|
|
8766
|
+
defaultFolder: join7(await runtimeDirForRepoAsync(repo), "logs"),
|
|
8767
|
+
repoRoot: repoRootSync()
|
|
8768
|
+
});
|
|
8769
|
+
}
|
|
8770
|
+
function isEnoent2(err) {
|
|
8056
8771
|
return typeof err === "object" && err !== null && err.code === "ENOENT";
|
|
8057
8772
|
}
|
|
8058
|
-
|
|
8773
|
+
var execFileAsync5 = promisify5(execFile5);
|
|
8774
|
+
async function resolveDoctrine(cwd, vinayaVersion) {
|
|
8059
8775
|
let toplevel;
|
|
8060
8776
|
try {
|
|
8061
|
-
toplevel =
|
|
8062
|
-
encoding: "utf8",
|
|
8063
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
8064
|
-
}).trim();
|
|
8777
|
+
toplevel = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], { encoding: "utf8" })).stdout.trim();
|
|
8065
8778
|
} catch (err) {
|
|
8066
|
-
return
|
|
8779
|
+
return isEnoent2(err) ? "unknown" : vinayaVersion;
|
|
8067
8780
|
}
|
|
8068
|
-
if (!
|
|
8781
|
+
if (!existsSync6(join7(toplevel, "aeg-root", "roles")))
|
|
8069
8782
|
return vinayaVersion;
|
|
8070
8783
|
try {
|
|
8071
|
-
const sha =
|
|
8072
|
-
encoding: "utf8",
|
|
8073
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
8074
|
-
}).trim();
|
|
8784
|
+
const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
|
|
8075
8785
|
return `aeg-root@${sha}`;
|
|
8076
8786
|
} catch {
|
|
8077
8787
|
return vinayaVersion;
|
|
@@ -8079,20 +8789,20 @@ function resolveDoctrine(cwd, vinayaVersion) {
|
|
|
8079
8789
|
}
|
|
8080
8790
|
function readVinayaVersion() {
|
|
8081
8791
|
try {
|
|
8082
|
-
const pkg = JSON.parse(
|
|
8792
|
+
const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
8083
8793
|
return pkg.version ?? "unknown";
|
|
8084
8794
|
} catch {
|
|
8085
8795
|
return "unknown";
|
|
8086
8796
|
}
|
|
8087
8797
|
}
|
|
8088
|
-
var
|
|
8089
|
-
function
|
|
8090
|
-
return
|
|
8798
|
+
var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8799
|
+
function isSafeRepoSegment3(segment) {
|
|
8800
|
+
return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
|
|
8091
8801
|
}
|
|
8092
8802
|
function outboxPathFor(deps, repo, issue) {
|
|
8093
8803
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
8094
8804
|
const fileName = `${issue ?? "none"}.ndjson`;
|
|
8095
|
-
return
|
|
8805
|
+
return join7(deps.outboxRoot(), dirName, fileName);
|
|
8096
8806
|
}
|
|
8097
8807
|
function hostFromEnv(env) {
|
|
8098
8808
|
if (env.GITHUB_ACTIONS)
|
|
@@ -8103,36 +8813,60 @@ function hostFromEnv(env) {
|
|
|
8103
8813
|
return "loop";
|
|
8104
8814
|
return "cli";
|
|
8105
8815
|
}
|
|
8816
|
+
var warnedThisProcess = false;
|
|
8817
|
+
function defaultStderr(message) {
|
|
8818
|
+
if (warnedThisProcess)
|
|
8819
|
+
return;
|
|
8820
|
+
warnedThisProcess = true;
|
|
8821
|
+
process.stderr.write(message);
|
|
8822
|
+
}
|
|
8106
8823
|
function defaultDeps() {
|
|
8107
8824
|
return {
|
|
8108
|
-
outboxRoot: () =>
|
|
8109
|
-
home: () =>
|
|
8825
|
+
outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
|
|
8826
|
+
home: () => homedir3(),
|
|
8110
8827
|
hostname: () => osHostname(),
|
|
8111
8828
|
cwd: () => process.cwd(),
|
|
8112
8829
|
now: () => new Date,
|
|
8113
8830
|
env: () => process.env,
|
|
8114
8831
|
resolveRepo: () => resolveRepo(),
|
|
8115
8832
|
vinayaVersion: () => readVinayaVersion(),
|
|
8116
|
-
stderr:
|
|
8117
|
-
process.stderr.write(message);
|
|
8118
|
-
},
|
|
8833
|
+
stderr: defaultStderr,
|
|
8119
8834
|
inputVersions: () => {
|
|
8120
8835
|
return;
|
|
8121
|
-
}
|
|
8836
|
+
},
|
|
8837
|
+
resolveLogDestination: defaultResolveLogDestination
|
|
8122
8838
|
};
|
|
8123
8839
|
}
|
|
8124
|
-
var APPEND_OPEN_FLAGS =
|
|
8840
|
+
var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
|
|
8125
8841
|
function guardedAppendOpen(path) {
|
|
8126
8842
|
try {
|
|
8127
|
-
return
|
|
8843
|
+
return openSync3(path, APPEND_OPEN_FLAGS, 384);
|
|
8128
8844
|
} catch {
|
|
8129
8845
|
return;
|
|
8130
8846
|
}
|
|
8131
8847
|
}
|
|
8848
|
+
function appendHardenedLine(path, line) {
|
|
8849
|
+
try {
|
|
8850
|
+
mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
|
|
8851
|
+
const fd = guardedAppendOpen(path);
|
|
8852
|
+
if (fd === undefined)
|
|
8853
|
+
return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
|
|
8854
|
+
try {
|
|
8855
|
+
if (!fstatSync2(fd).isFile())
|
|
8856
|
+
return `target is not a regular file: ${path}`;
|
|
8857
|
+
writeSync2(fd, line);
|
|
8858
|
+
} finally {
|
|
8859
|
+
closeSync3(fd);
|
|
8860
|
+
}
|
|
8861
|
+
return null;
|
|
8862
|
+
} catch (err) {
|
|
8863
|
+
return err instanceof Error ? err.message : String(err);
|
|
8864
|
+
}
|
|
8865
|
+
}
|
|
8132
8866
|
function reportRotationOverflow(backupPath, warn) {
|
|
8133
8867
|
let raw;
|
|
8134
8868
|
try {
|
|
8135
|
-
raw =
|
|
8869
|
+
raw = readFileSync5(backupPath, "utf8");
|
|
8136
8870
|
} catch {
|
|
8137
8871
|
return;
|
|
8138
8872
|
}
|
|
@@ -8155,7 +8889,7 @@ function reportRotationOverflow(backupPath, warn) {
|
|
|
8155
8889
|
}
|
|
8156
8890
|
function appendLine(path, line, warn) {
|
|
8157
8891
|
try {
|
|
8158
|
-
|
|
8892
|
+
mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
|
|
8159
8893
|
let fd = guardedAppendOpen(path);
|
|
8160
8894
|
if (fd === undefined) {
|
|
8161
8895
|
warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
|
|
@@ -8171,11 +8905,11 @@ function appendLine(path, line, warn) {
|
|
|
8171
8905
|
return;
|
|
8172
8906
|
}
|
|
8173
8907
|
if (stat.size > OUTBOX_MAX_BYTES) {
|
|
8174
|
-
|
|
8908
|
+
closeSync3(fd);
|
|
8175
8909
|
closed = true;
|
|
8176
8910
|
const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
|
|
8177
8911
|
reportRotationOverflow(backupPath, warn);
|
|
8178
|
-
|
|
8912
|
+
renameSync2(path, backupPath);
|
|
8179
8913
|
const rotated = guardedAppendOpen(path);
|
|
8180
8914
|
if (rotated === undefined) {
|
|
8181
8915
|
warn(`vinaya: log outbox target could not be reopened after rotation — refusing: ${path}
|
|
@@ -8185,10 +8919,10 @@ function appendLine(path, line, warn) {
|
|
|
8185
8919
|
fd = rotated;
|
|
8186
8920
|
closed = false;
|
|
8187
8921
|
}
|
|
8188
|
-
|
|
8922
|
+
writeSync2(fd, line);
|
|
8189
8923
|
} finally {
|
|
8190
8924
|
if (!closed)
|
|
8191
|
-
|
|
8925
|
+
closeSync3(fd);
|
|
8192
8926
|
}
|
|
8193
8927
|
} catch (err) {
|
|
8194
8928
|
warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
|
|
@@ -8197,8 +8931,8 @@ function appendLine(path, line, warn) {
|
|
|
8197
8931
|
}
|
|
8198
8932
|
function createLogSink(overrides = {}) {
|
|
8199
8933
|
const deps = { ...defaultDeps(), ...overrides };
|
|
8200
|
-
const runId = deps.env().VINAYA_RUN_ID ||
|
|
8201
|
-
const processId =
|
|
8934
|
+
const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
|
|
8935
|
+
const processId = randomUUID2();
|
|
8202
8936
|
let seq = 0;
|
|
8203
8937
|
let warned = false;
|
|
8204
8938
|
const warnOnce = (message) => {
|
|
@@ -8211,8 +8945,9 @@ function createLogSink(overrides = {}) {
|
|
|
8211
8945
|
};
|
|
8212
8946
|
let doctrineCache;
|
|
8213
8947
|
const doctrine = () => {
|
|
8214
|
-
if (doctrineCache === undefined)
|
|
8215
|
-
doctrineCache = resolveDoctrine(deps.cwd(), deps.vinayaVersion());
|
|
8948
|
+
if (doctrineCache === undefined) {
|
|
8949
|
+
doctrineCache = withDeadline(resolveDoctrine(deps.cwd(), deps.vinayaVersion()), LOG_CONTEXT_LOOKUP_DEADLINE_MS, deps.vinayaVersion());
|
|
8950
|
+
}
|
|
8216
8951
|
return doctrineCache;
|
|
8217
8952
|
};
|
|
8218
8953
|
let resolveRepoCache;
|
|
@@ -8221,6 +8956,30 @@ function createLogSink(overrides = {}) {
|
|
|
8221
8956
|
resolveRepoCache = deps.resolveRepo();
|
|
8222
8957
|
return resolveRepoCache;
|
|
8223
8958
|
};
|
|
8959
|
+
let contextCache;
|
|
8960
|
+
const context = () => {
|
|
8961
|
+
if (contextCache === undefined) {
|
|
8962
|
+
const env = deps.env();
|
|
8963
|
+
contextCache = Promise.all([
|
|
8964
|
+
withDeadline(resolveRepoOnce(), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null),
|
|
8965
|
+
doctrine()
|
|
8966
|
+
]).then(async ([resolved, doctrineValue]) => {
|
|
8967
|
+
const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
|
|
8968
|
+
return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
|
|
8969
|
+
});
|
|
8970
|
+
}
|
|
8971
|
+
return contextCache;
|
|
8972
|
+
};
|
|
8973
|
+
let drainChain = Promise.resolve();
|
|
8974
|
+
const pendingWrites = new Set;
|
|
8975
|
+
const scheduleWebhookDrain = (issue, url, headers) => {
|
|
8976
|
+
drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
|
|
8977
|
+
return;
|
|
8978
|
+
}).catch((err) => {
|
|
8979
|
+
warnOnce(`vinaya: log delivery to ${url} failed — queued in the local outbox, retried on the next event: ${err instanceof Error ? err.message : String(err)}
|
|
8980
|
+
`);
|
|
8981
|
+
});
|
|
8982
|
+
};
|
|
8224
8983
|
function log(e) {
|
|
8225
8984
|
try {
|
|
8226
8985
|
const env = deps.env();
|
|
@@ -8235,22 +8994,26 @@ function createLogSink(overrides = {}) {
|
|
|
8235
8994
|
attempt: env.VINAYA_ATTEMPT,
|
|
8236
8995
|
parent: env.VINAYA_PARENT_EVENT
|
|
8237
8996
|
};
|
|
8238
|
-
|
|
8239
|
-
const repo = resolved && isSafeRepoSegment(resolved.owner) && isSafeRepoSegment(resolved.repo) ? resolved : null;
|
|
8997
|
+
const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
|
|
8240
8998
|
const header = buildHeader({
|
|
8241
8999
|
now,
|
|
8242
9000
|
runId,
|
|
8243
9001
|
seq: mySeq,
|
|
8244
9002
|
repo: repo ? `${repo.owner}/${repo.repo}` : null,
|
|
8245
9003
|
vinaya: deps.vinayaVersion(),
|
|
8246
|
-
doctrine:
|
|
9004
|
+
doctrine: doctrineValue,
|
|
8247
9005
|
host,
|
|
8248
9006
|
hostname: deps.hostname(),
|
|
8249
9007
|
env: envFields,
|
|
8250
|
-
eventId:
|
|
9008
|
+
eventId: randomUUID2(),
|
|
8251
9009
|
processId,
|
|
8252
9010
|
inputVersions: deps.inputVersions()
|
|
8253
9011
|
});
|
|
9012
|
+
if (resolvedDestination.kind === "none") {
|
|
9013
|
+
warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
|
|
9014
|
+
`);
|
|
9015
|
+
return;
|
|
9016
|
+
}
|
|
8254
9017
|
const full = { ...e, ...header };
|
|
8255
9018
|
const parsed = LogEventSchema.safeParse(full);
|
|
8256
9019
|
if (!parsed.success) {
|
|
@@ -8260,25 +9023,42 @@ function createLogSink(overrides = {}) {
|
|
|
8260
9023
|
}
|
|
8261
9024
|
const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
|
|
8262
9025
|
`;
|
|
8263
|
-
|
|
9026
|
+
const destination = resolvedDestination;
|
|
9027
|
+
if (destination.kind === "server") {
|
|
9028
|
+
appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
|
|
9029
|
+
scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
|
|
9030
|
+
} else {
|
|
9031
|
+
appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
|
|
9032
|
+
}
|
|
8264
9033
|
}).catch((err) => {
|
|
8265
9034
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8266
9035
|
`);
|
|
8267
9036
|
});
|
|
9037
|
+
pendingWrites.add(written);
|
|
9038
|
+
written.finally(() => pendingWrites.delete(written));
|
|
8268
9039
|
} catch (err) {
|
|
8269
9040
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8270
9041
|
`);
|
|
8271
9042
|
}
|
|
8272
9043
|
}
|
|
8273
9044
|
const warmup = () => {
|
|
8274
|
-
doctrine();
|
|
8275
9045
|
const originalWarn = console.warn;
|
|
8276
9046
|
console.warn = () => {};
|
|
8277
9047
|
resolveRepoOnce().finally(() => {
|
|
8278
9048
|
console.warn = originalWarn;
|
|
8279
9049
|
});
|
|
9050
|
+
context().catch(() => {
|
|
9051
|
+
return;
|
|
9052
|
+
});
|
|
9053
|
+
};
|
|
9054
|
+
const drain = async () => {
|
|
9055
|
+
if (pendingWrites.size > 0)
|
|
9056
|
+
await Promise.allSettled(Array.from(pendingWrites));
|
|
9057
|
+
await drainChain.catch(() => {
|
|
9058
|
+
return;
|
|
9059
|
+
});
|
|
8280
9060
|
};
|
|
8281
|
-
return { log, runId, warmup };
|
|
9061
|
+
return { log, runId, warmup, drain };
|
|
8282
9062
|
}
|
|
8283
9063
|
var defaultSink = createLogSink();
|
|
8284
9064
|
|
|
@@ -8329,7 +9109,7 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
8329
9109
|
function fileDiffAgainst(ref, path) {
|
|
8330
9110
|
let out;
|
|
8331
9111
|
try {
|
|
8332
|
-
out =
|
|
9112
|
+
out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
8333
9113
|
encoding: "utf8",
|
|
8334
9114
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8335
9115
|
}).trim();
|
|
@@ -8340,7 +9120,7 @@ function fileDiffAgainst(ref, path) {
|
|
|
8340
9120
|
}
|
|
8341
9121
|
function revParse(ref) {
|
|
8342
9122
|
try {
|
|
8343
|
-
return
|
|
9123
|
+
return execFileSync5("git", ["rev-parse", "--verify", ref], {
|
|
8344
9124
|
encoding: "utf8",
|
|
8345
9125
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8346
9126
|
}).trim();
|
|
@@ -8350,7 +9130,7 @@ function revParse(ref) {
|
|
|
8350
9130
|
}
|
|
8351
9131
|
function repoRoot() {
|
|
8352
9132
|
try {
|
|
8353
|
-
return
|
|
9133
|
+
return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
|
|
8354
9134
|
encoding: "utf8",
|
|
8355
9135
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8356
9136
|
}).trim();
|
|
@@ -8361,7 +9141,7 @@ function repoRoot() {
|
|
|
8361
9141
|
function changedFiles(base) {
|
|
8362
9142
|
let out;
|
|
8363
9143
|
try {
|
|
8364
|
-
out =
|
|
9144
|
+
out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
8365
9145
|
encoding: "utf8",
|
|
8366
9146
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8367
9147
|
}).trim();
|
|
@@ -8386,7 +9166,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
|
|
|
8386
9166
|
const relPaths = changedFiles(ref);
|
|
8387
9167
|
if (relPaths === null)
|
|
8388
9168
|
continue;
|
|
8389
|
-
return { base: ref, root, files: relPaths.map((p) =>
|
|
9169
|
+
return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
|
|
8390
9170
|
}
|
|
8391
9171
|
return null;
|
|
8392
9172
|
}
|
|
@@ -8421,7 +9201,7 @@ function findingsInThisDiff(findings) {
|
|
|
8421
9201
|
var CHECK_NAME = "doc-coverage-push";
|
|
8422
9202
|
function git2(args) {
|
|
8423
9203
|
try {
|
|
8424
|
-
return
|
|
9204
|
+
return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
8425
9205
|
} catch {
|
|
8426
9206
|
return "";
|
|
8427
9207
|
}
|
|
@@ -8435,7 +9215,7 @@ function resolvePrBody() {
|
|
|
8435
9215
|
return process.env.PR_BODY;
|
|
8436
9216
|
if (process.env.PR_BODY_FILE) {
|
|
8437
9217
|
try {
|
|
8438
|
-
return
|
|
9218
|
+
return readFileSync6(process.env.PR_BODY_FILE, "utf8");
|
|
8439
9219
|
} catch {
|
|
8440
9220
|
return "";
|
|
8441
9221
|
}
|
|
@@ -8470,8 +9250,8 @@ function main() {
|
|
|
8470
9250
|
}
|
|
8471
9251
|
if (changed.length === 0)
|
|
8472
9252
|
process.exit(0);
|
|
8473
|
-
const content =
|
|
8474
|
-
const result = evaluateC5(changed, content, resolvePrBody(),
|
|
9253
|
+
const content = existsSync7(DOC_OWNERS_PATH) ? readFileSync6(DOC_OWNERS_PATH, "utf8") : null;
|
|
9254
|
+
const result = evaluateC5(changed, content, resolvePrBody(), existsSync7, waiverActiveFromEnv(), (p) => fileDiffAgainst(ref, p));
|
|
8475
9255
|
for (const message of result.errors) {
|
|
8476
9256
|
emitCheckError({
|
|
8477
9257
|
schema: CHECK_SCHEMA_VERSION,
|