@attalabs/vinaya 0.36.0 → 0.38.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 +6 -6
- package/aeg-root/contracts/developer-reviewer.md +1 -1
- package/aeg-root/contracts/planner-operator.md +1 -1
- package/aeg-root/contracts/principal-operator.md +6 -6
- package/aeg-root/contracts/security-archivist.md +1 -1
- package/aeg-root/enforcement.md +14 -14
- package/aeg-root/process.md +3 -1
- package/aeg-root/roles/archivist.md +2 -2
- package/aeg-root/roles/developer/reference.md +36 -37
- package/aeg-root/roles/developer.md +9 -5
- package/aeg-root/roles/operator.md +18 -18
- package/aeg-root/roles/planner/reference.md +15 -4
- package/aeg-root/roles/principal.md +6 -1
- package/aeg-root/roles/reviewer.md +14 -6
- package/aeg-root/roles/security.md +22 -11
- package/aeg-root/roles/tranche-archivist.md +14 -2
- package/aeg-root/state-machine.md +12 -11
- package/aeg-root/templates/brief-template.md +8 -6
- package/aeg-root/templates/pr-report-template.md +1 -9
- package/aeg-root/tranche-model.md +10 -4
- package/dist/checks/bin/check-body-bare-digits.js +823 -595
- package/dist/checks/bin/check-branch-topology.js +796 -478
- package/dist/checks/bin/check-brief-shape.js +824 -596
- package/dist/checks/bin/check-changeset-coverage.js +1337 -747
- package/dist/checks/bin/check-closes-n.js +796 -478
- package/dist/checks/bin/check-coherence.js +914 -611
- package/dist/checks/bin/check-dead-branch-push.js +705 -462
- package/dist/checks/bin/check-dispatch-readiness.js +941 -624
- package/dist/checks/bin/check-doc-coverage-push.js +1332 -742
- package/dist/checks/bin/check-doc-coverage.js +1339 -742
- package/dist/checks/bin/check-doctrine-no-procedures.js +821 -593
- package/dist/checks/bin/check-doctrine-portability.js +1332 -742
- package/dist/checks/bin/check-evidence-fresh.js +1339 -918
- package/dist/checks/bin/check-exec-bits.js +1331 -741
- package/dist/checks/bin/check-first-push-dispatch.js +917 -614
- package/dist/checks/bin/check-issue-assignment.js +796 -478
- package/dist/checks/bin/check-issue-milestone-attach.js +705 -462
- package/dist/checks/bin/check-issue-objectives-numbering.js +821 -593
- package/dist/checks/bin/check-issue-parts-coverage.js +705 -462
- package/dist/checks/bin/check-issue-surface-globs.js +925 -613
- package/dist/checks/bin/check-issue-title-grammar.js +705 -462
- package/dist/checks/bin/check-issue-tranche-label.js +705 -462
- package/dist/checks/bin/check-main-branch-refusal.js +705 -462
- package/dist/checks/bin/check-no-disk-state.js +705 -462
- package/dist/checks/bin/check-pr-premise-reassert.js +821 -593
- package/dist/checks/bin/check-pr-report-density.js +705 -462
- package/dist/checks/bin/check-principal-test-plan-wait.js +705 -462
- package/dist/checks/bin/check-quoted-command.js +1816 -1228
- package/dist/checks/bin/check-reader-resolvable-prose.js +1835 -1235
- package/dist/checks/bin/check-registry-gates.js +993 -526
- package/dist/checks/bin/check-retired-vocabulary.js +1810 -1222
- package/dist/checks/bin/check-review-gate.js +832 -604
- package/dist/checks/bin/check-single-plan-pr.js +705 -462
- package/dist/checks/bin/check-surface-scope.js +796 -478
- package/dist/checks/bin/check-test-plan.js +705 -462
- package/dist/checks/bin/check-token-collection-wired.js +705 -462
- package/dist/checks/bin/check-workspace-escape.js +1332 -742
- package/dist/checks/bin/verify-dispatch.js +3849 -0
- package/dist/index.js +20876 -10091
- package/dist/lib/pre-push-cache-test-run.js +1045 -682
- package/dist/lib/pre-push-changed-files.js +16 -11
- package/dist/lib/pre-push-select-tests.js +785 -500
- package/package.json +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +7 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +71 -15
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +51 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +31 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +50 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +443 -28
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +18 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +6 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +13 -13
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +46 -110
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +169 -11
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +32 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +3 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +30 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +0 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +82 -8
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +754 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +24 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/custom.ts +157 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +44 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/executions.ts +493 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/fact-sheets.ts +111 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/generator.ts +155 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/index.ts +12 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +128 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/catches.ts +63 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/checks.ts +146 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/common.ts +137 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/completion.ts +137 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/convergence.ts +420 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/determinism.ts +65 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/index.ts +69 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/judgment.ts +132 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/labels.ts +21 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/time.ts +167 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/usage.ts +139 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +226 -15
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +7 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/cache-contract.ts +207 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/contracts.ts +105 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/engine.ts +308 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/index.ts +34 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/measured.ts +20 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/memory-cache.ts +78 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/normalize.ts +156 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/row.ts +103 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +34 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +70 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +52 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +19 -14
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +201 -24
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +5 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +46 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +15 -28
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/app-path-routes-manifest.json +0 -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/required-server-files.json +0 -5
- package/studio-standalone/apps/vinaya-studio/web/.next/routes-manifest.json +0 -6
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- 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 +1 -1
- 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/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +1 -1
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +5 -5
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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/app-paths-manifest.json +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/044u_vinaya-studio_web_src_app_studio_backlog__components_BacklogTable_tsx_0oha0bt._.js +3 -0
- 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]__1bh2awk._.js → [root-of-the-server]__038scsm._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1widio3._.js → [root-of-the-server]__03__s45._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_15gdg48._.js → [root-of-the-server]__04adkz-._.js} +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__05zwn98._.js +14 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0h9yhwx._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1wy7w66._.js → [root-of-the-server]__0jdjsxe._.js} +2 -2
- 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]__10riywf._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__13znegp._.js → [root-of-the-server]__134x-65._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__13eeix2._.js → [root-of-the-server]__1_l_l1u._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1f4bb3_._.js +3 -0
- 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]__1dky4g0._.js → [root-of-the-server]__1my83lt._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1ng2x88._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__040smoa._.js → [root-of-the-server]__1qpc6at._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +56 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_06h3wbl._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
- 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/_0gs4gvl._.js +3 -0
- 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/_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/_121lrn5._.js +3 -0
- 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/_1o4v6lb._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1q7h5mz._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1ztd4i3._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_209-ugd._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_214d71c._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_17dho0f._.js +3 -0
- 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/chunks/ssr/node_modules_next_dist_1lzmr5o._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_animate_components_index_ts_186fje1._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_index_ts_0xk1vda._.js +1 -1
- 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/09fcolor69bun.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0lcwmwzxacdie.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ojry7lrbzkfd.css +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1-acpmtfmrc35.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1giu47hrbhroj.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1shz6lwruld25.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1ytvuy1mmnc6j.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3oxhhhm_psozq.js → 21a6_5cr956wj.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2o9l0b7eqbr57.js → 2f2y8xxok8zph.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2g8mwnydod96u.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3li0ueedy-ozv.js → 2nrnuawd5fwpv.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2nw47832_uvfe.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qdxnj8wk2h0s.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3lqjwjrcvq481.js → 2xevgia1h8g0y.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3b9q75p-z5ma5.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3cv-oe7153242.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3m310lbjj4p5u.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
- package/dist/checks/bin/check-token-report.js +0 -6526
- 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/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/bin/verify-coherence.ts +0 -1089
- package/studio-standalone/_node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +0 -6
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/app-paths-manifest.json +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/build-manifest.json +0 -9
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/server-reference-manifest.json +0 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +0 -6
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.map +0 -5
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route_client-reference-manifest.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/044u_vinaya-studio_web__next-internal_server_app_api_coherence_route_actions_1rnzea1.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[externals]__0cki-x_._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +0 -15
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[turbopack]_runtime.js +0 -903
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ln09ua._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0oegopp._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__13yxbjd._.js +0 -51
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1duqmtm._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1z7dml9._.js +0 -9
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0bfs_u4._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0g8_eot._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0hrh_v-._.js +0 -181
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0i4-dea._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0o54suy._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0rxd7s0._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_151m4rz._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1a9dieq._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sxsf5q._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sy_yfr._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_219v2an._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_05ufo8i._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_form_input_tsx_0es8d8b._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_brutal_components_index_ts_0n_lcc4._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_retro_components_index_ts_0wvpm_z._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/00z3-ljjd1gj9.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0c8uwz_-m8s99.js +0 -165
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ct0c-xj0baf6.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0t5n_r4xm__t-.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vc2u252q5q6o.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/16r_o07lw0vm0.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1cah7_e5a1zvu.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1gjo9-6dz7nup.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/24tz8aro1uto4.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ef2g5fozszw7.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ka8dg687auhj.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2pf3f50gbrkyv.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qq49pct3q51-.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3et66z7glk65w.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3y6u3prmrkea-.js +0 -1
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yNZEFRSjP9BLUfdf96Eol}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yNZEFRSjP9BLUfdf96Eol}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yNZEFRSjP9BLUfdf96Eol}/_ssgManifest.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-retired-vocabulary.ts
|
|
4
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
4
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync8, statSync as statSync3 } from "node:fs";
|
|
5
5
|
import { join as join10 } from "node:path";
|
|
6
6
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
7
7
|
var GATE_AUDIENCE = {
|
|
@@ -628,6 +628,33 @@ function tasksFromIssues(issues) {
|
|
|
628
628
|
}
|
|
629
629
|
return tasks.sort((a, b) => compareTaskIds(a.id, b.id));
|
|
630
630
|
}
|
|
631
|
+
function resolveDuplicateTasks(tasks, isOpen) {
|
|
632
|
+
const byId = new Map;
|
|
633
|
+
for (const t of tasks)
|
|
634
|
+
byId.set(t.id, [...byId.get(t.id) ?? [], t]);
|
|
635
|
+
const resolved = [];
|
|
636
|
+
const conflicts = [];
|
|
637
|
+
for (const [id, group] of byId) {
|
|
638
|
+
const first = group[0];
|
|
639
|
+
if (!first)
|
|
640
|
+
continue;
|
|
641
|
+
if (group.length === 1) {
|
|
642
|
+
resolved.push(first);
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
const number = (t) => t.issue ?? 0;
|
|
646
|
+
const open = group.filter((t) => t.issue !== null && isOpen(t.issue)).sort((a, b) => number(a) - number(b));
|
|
647
|
+
if (open.length > 1) {
|
|
648
|
+
conflicts.push({ id, issues: open.map(number) });
|
|
649
|
+
resolved.push(open[0]);
|
|
650
|
+
} else if (open.length === 1) {
|
|
651
|
+
resolved.push(open[0]);
|
|
652
|
+
} else {
|
|
653
|
+
resolved.push([...group].sort((a, b) => number(b) - number(a))[0]);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
return { tasks: resolved.sort((a, b) => compareTaskIds(a.id, b.id)), conflicts };
|
|
657
|
+
}
|
|
631
658
|
async function fetchTrancheIssuesAsync(owner, repo, slug) {
|
|
632
659
|
return ghIssueListByAnyLabelAsync(owner, repo, [trancheLabel(slug)]);
|
|
633
660
|
}
|
|
@@ -1435,7 +1462,7 @@ function mapReviewDecision(decision) {
|
|
|
1435
1462
|
function buildBranchName(tranche, taskId) {
|
|
1436
1463
|
return `task/${tranche}/${taskId}`;
|
|
1437
1464
|
}
|
|
1438
|
-
async function
|
|
1465
|
+
async function fetchForgeFactsByIssue(input) {
|
|
1439
1466
|
const token = await resolveGithubToken(input.token);
|
|
1440
1467
|
if (!token) {
|
|
1441
1468
|
return {
|
|
@@ -1445,7 +1472,13 @@ async function fetchForgeFacts(input) {
|
|
|
1445
1472
|
reason: "No GitHub token available (set GITHUB_TOKEN/GH_TOKEN or `gh auth login`)."
|
|
1446
1473
|
};
|
|
1447
1474
|
}
|
|
1448
|
-
const
|
|
1475
|
+
const seen = new Set;
|
|
1476
|
+
const queriedTasks = input.tasks.filter((t) => {
|
|
1477
|
+
if (t.issue === null || seen.has(t.issue))
|
|
1478
|
+
return false;
|
|
1479
|
+
seen.add(t.issue);
|
|
1480
|
+
return true;
|
|
1481
|
+
});
|
|
1449
1482
|
if (queriedTasks.length === 0) {
|
|
1450
1483
|
return { facts: new Map, prRefs: new Map, unavailable: false };
|
|
1451
1484
|
}
|
|
@@ -1473,21 +1506,52 @@ async function fetchForgeFacts(input) {
|
|
|
1473
1506
|
};
|
|
1474
1507
|
}
|
|
1475
1508
|
for (const task of queriedTasks) {
|
|
1476
|
-
const
|
|
1477
|
-
const raw = extractRawFromResponse(response.repository, alias);
|
|
1509
|
+
const raw = extractRawFromResponse(response.repository, aliasFor(task.issue));
|
|
1478
1510
|
const mapped = mapForgeFacts(raw);
|
|
1479
1511
|
if (mapped)
|
|
1480
|
-
facts.set(task.
|
|
1512
|
+
facts.set(task.issue, mapped);
|
|
1481
1513
|
const pr = raw.pullRequest;
|
|
1482
1514
|
if (pr && typeof pr.number === "number" && typeof pr.url === "string") {
|
|
1483
|
-
prRefs.set(task.
|
|
1515
|
+
prRefs.set(task.issue, { number: pr.number, url: pr.url, state: pr.state });
|
|
1484
1516
|
}
|
|
1485
1517
|
}
|
|
1486
1518
|
return { facts, prRefs, unavailable: false };
|
|
1487
1519
|
}
|
|
1520
|
+
async function fetchForgeFacts(input) {
|
|
1521
|
+
const byIssue = await fetchForgeFactsByIssue(input);
|
|
1522
|
+
if (byIssue.unavailable) {
|
|
1523
|
+
return { facts: new Map, prRefs: new Map, unavailable: true, reason: byIssue.reason };
|
|
1524
|
+
}
|
|
1525
|
+
const facts = new Map;
|
|
1526
|
+
const prRefs = new Map;
|
|
1527
|
+
const winner = new Map;
|
|
1528
|
+
for (const task of input.tasks) {
|
|
1529
|
+
if (task.issue === null)
|
|
1530
|
+
continue;
|
|
1531
|
+
const current = winner.get(task.id);
|
|
1532
|
+
if (current === undefined || outranks(byIssue.facts, task.issue, current))
|
|
1533
|
+
winner.set(task.id, task.issue);
|
|
1534
|
+
}
|
|
1535
|
+
for (const [taskId, issue] of winner) {
|
|
1536
|
+
const f = byIssue.facts.get(issue);
|
|
1537
|
+
if (f)
|
|
1538
|
+
facts.set(taskId, f);
|
|
1539
|
+
const pr = byIssue.prRefs.get(issue);
|
|
1540
|
+
if (pr)
|
|
1541
|
+
prRefs.set(taskId, pr);
|
|
1542
|
+
}
|
|
1543
|
+
return { facts, prRefs, unavailable: false };
|
|
1544
|
+
}
|
|
1545
|
+
function outranks(facts, candidate, current) {
|
|
1546
|
+
const candidateOpen = facts.get(candidate)?.issueState === "open";
|
|
1547
|
+
const currentOpen = facts.get(current)?.issueState === "open";
|
|
1548
|
+
if (candidateOpen !== currentOpen)
|
|
1549
|
+
return candidateOpen;
|
|
1550
|
+
return candidate > current;
|
|
1551
|
+
}
|
|
1488
1552
|
function buildBatchQuery(tranche, tasks) {
|
|
1489
1553
|
const perTask = tasks.map((task) => {
|
|
1490
|
-
const a = aliasFor(task.
|
|
1554
|
+
const a = aliasFor(task.issue);
|
|
1491
1555
|
const branch = buildBranchName(tranche, task.id);
|
|
1492
1556
|
return `
|
|
1493
1557
|
${a}_issue: issue(number: ${task.issue}) {
|
|
@@ -1529,9 +1593,8 @@ function buildBatchQuery(tranche, tasks) {
|
|
|
1529
1593
|
}
|
|
1530
1594
|
}`;
|
|
1531
1595
|
}
|
|
1532
|
-
function aliasFor(
|
|
1533
|
-
|
|
1534
|
-
return `t_${sanitized}`;
|
|
1596
|
+
function aliasFor(issue) {
|
|
1597
|
+
return `i_${issue}`;
|
|
1535
1598
|
}
|
|
1536
1599
|
function extractRawFromResponse(repository, alias) {
|
|
1537
1600
|
const issue = repository[`${alias}_issue`];
|
|
@@ -1886,45 +1949,6 @@ var DERIVED_STATUSES = [
|
|
|
1886
1949
|
"incoherent"
|
|
1887
1950
|
];
|
|
1888
1951
|
var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
1889
|
-
// ../../packages/aeg-core/src/parse-ledger.ts
|
|
1890
|
-
function rowFromCells(cells) {
|
|
1891
|
-
if (cells.length < 7)
|
|
1892
|
-
return null;
|
|
1893
|
-
const phase = (cells[0] ?? "").trim();
|
|
1894
|
-
if (!phase)
|
|
1895
|
-
return null;
|
|
1896
|
-
return {
|
|
1897
|
-
phase,
|
|
1898
|
-
role: (cells[1] ?? "").trim(),
|
|
1899
|
-
agentModel: (cells[2] ?? "").trim(),
|
|
1900
|
-
tokensIn: parseIntCell(cells[3] ?? ""),
|
|
1901
|
-
tokensOut: parseIntCell(cells[4] ?? ""),
|
|
1902
|
-
cost: parseCostCell(cells[5] ?? ""),
|
|
1903
|
-
date: (cells[6] ?? "").trim()
|
|
1904
|
-
};
|
|
1905
|
-
}
|
|
1906
|
-
function parseIntCell(cell) {
|
|
1907
|
-
const trimmed = cell.replace(/`/g, "").trim();
|
|
1908
|
-
if (!trimmed || isEmDashOrDash(trimmed))
|
|
1909
|
-
return null;
|
|
1910
|
-
const normalized = trimmed.replace(/[,_\s]/g, "");
|
|
1911
|
-
if (!/^-?\d+$/.test(normalized))
|
|
1912
|
-
return null;
|
|
1913
|
-
return Number(normalized);
|
|
1914
|
-
}
|
|
1915
|
-
function parseCostCell(cell) {
|
|
1916
|
-
const trimmed = cell.replace(/`/g, "").trim();
|
|
1917
|
-
if (!trimmed || isEmDashOrDash(trimmed))
|
|
1918
|
-
return null;
|
|
1919
|
-
const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
|
|
1920
|
-
if (!/^-?\d+(\.\d+)?$/.test(normalized))
|
|
1921
|
-
return null;
|
|
1922
|
-
return Number(normalized);
|
|
1923
|
-
}
|
|
1924
|
-
function isEmDashOrDash(s) {
|
|
1925
|
-
const t = s.trim();
|
|
1926
|
-
return t === "—" || t === "-" || t === "–";
|
|
1927
|
-
}
|
|
1928
1952
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1929
1953
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1930
1954
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
@@ -1940,61 +1964,6 @@ function isWaiverLabelActorVerified(opts) {
|
|
|
1940
1964
|
return false;
|
|
1941
1965
|
return isPrincipal(opts.labelActor, opts.principalAllowlist);
|
|
1942
1966
|
}
|
|
1943
|
-
|
|
1944
|
-
// ../../packages/aeg-core/src/parse-token-report.ts
|
|
1945
|
-
var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
|
|
1946
|
-
var INLINE_FIELD_LIST = /Phase:\s*([^|]+?)\s*\|\s*Role:\s*([^|]+?)\s*\|\s*Agent\/Model:\s*([^|]+?)\s*\|\s*Tokens in:\s*([^|]+?)\s*\|\s*Tokens out:\s*([^|]+?)\s*\|\s*Cost:\s*([^|]+?)\s*\|\s*Date:\s*(.+?)\s*$/im;
|
|
1947
|
-
function parseTokenReportEntries(body) {
|
|
1948
|
-
const lines = body.split(/\r?\n/);
|
|
1949
|
-
const headingIdxs = [];
|
|
1950
|
-
lines.forEach((line, i) => {
|
|
1951
|
-
if (TOKEN_REPORT_HEADING.test(line))
|
|
1952
|
-
headingIdxs.push(i);
|
|
1953
|
-
});
|
|
1954
|
-
const out = [];
|
|
1955
|
-
for (let h = 0;h < headingIdxs.length; h++) {
|
|
1956
|
-
const start = headingIdxs[h] + 1;
|
|
1957
|
-
const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
|
|
1958
|
-
const section = lines.slice(start, end).join(`
|
|
1959
|
-
`);
|
|
1960
|
-
const tableRows = parseTableSection(section);
|
|
1961
|
-
if (tableRows.length > 0) {
|
|
1962
|
-
out.push(...tableRows);
|
|
1963
|
-
continue;
|
|
1964
|
-
}
|
|
1965
|
-
const inlineRow = parseInlineFieldList(section);
|
|
1966
|
-
if (inlineRow)
|
|
1967
|
-
out.push(inlineRow);
|
|
1968
|
-
}
|
|
1969
|
-
return out;
|
|
1970
|
-
}
|
|
1971
|
-
function parseTableSection(section) {
|
|
1972
|
-
const lines = section.split(/\r?\n/);
|
|
1973
|
-
let i = 0;
|
|
1974
|
-
for (;i < lines.length; i++) {
|
|
1975
|
-
if ((lines[i] ?? "").trim().startsWith("|"))
|
|
1976
|
-
break;
|
|
1977
|
-
}
|
|
1978
|
-
if (i + 1 >= lines.length)
|
|
1979
|
-
return [];
|
|
1980
|
-
i += 2;
|
|
1981
|
-
const out = [];
|
|
1982
|
-
for (;i < lines.length; i++) {
|
|
1983
|
-
const trimmed = (lines[i] ?? "").trim();
|
|
1984
|
-
if (!trimmed.startsWith("|"))
|
|
1985
|
-
break;
|
|
1986
|
-
const row = rowFromCells(splitTableRow(trimmed));
|
|
1987
|
-
if (row)
|
|
1988
|
-
out.push(row);
|
|
1989
|
-
}
|
|
1990
|
-
return out;
|
|
1991
|
-
}
|
|
1992
|
-
function parseInlineFieldList(section) {
|
|
1993
|
-
const m = section.match(INLINE_FIELD_LIST);
|
|
1994
|
-
if (!m)
|
|
1995
|
-
return null;
|
|
1996
|
-
return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
|
|
1997
|
-
}
|
|
1998
1967
|
// ../../packages/aeg-core/src/verdict-extraction.ts
|
|
1999
1968
|
var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
2000
1969
|
var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
@@ -2443,10 +2412,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
|
|
|
2443
2412
|
var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
|
|
2444
2413
|
var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
|
|
2445
2414
|
var DEFAULT_MAX_ROUNDS = 3;
|
|
2415
|
+
var DEFAULT_MAX_TASK_MINUTES = 180;
|
|
2446
2416
|
var DEFAULT_REVIEW_POLICY = {
|
|
2447
2417
|
codeReviewThreshold: "BLOCKER",
|
|
2448
2418
|
securityThreshold: "HIGH",
|
|
2449
|
-
maxRounds: DEFAULT_MAX_ROUNDS
|
|
2419
|
+
maxRounds: DEFAULT_MAX_ROUNDS,
|
|
2420
|
+
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
|
|
2450
2421
|
};
|
|
2451
2422
|
var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
|
|
2452
2423
|
var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
|
|
@@ -2454,6 +2425,9 @@ var ROLE_FILE_LOCATION = /(^|\/)aeg-root\/roles\//i;
|
|
|
2454
2425
|
function isProseLocation(location) {
|
|
2455
2426
|
if (ROLE_FILE_LOCATION.test(location))
|
|
2456
2427
|
return true;
|
|
2428
|
+
return isBodyOrCommentLocation(location);
|
|
2429
|
+
}
|
|
2430
|
+
function isBodyOrCommentLocation(location) {
|
|
2457
2431
|
if (FILE_SHAPED_LOCATION.test(location))
|
|
2458
2432
|
return false;
|
|
2459
2433
|
return PROSE_LOCATION_PATTERNS.some((pattern) => pattern.test(location));
|
|
@@ -2480,7 +2454,7 @@ function classifyFinding(finding, scale, threshold, context = {}) {
|
|
|
2480
2454
|
const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
|
|
2481
2455
|
if (!wouldBlock)
|
|
2482
2456
|
return { outcome: "non_blocking", deferralReason: null };
|
|
2483
|
-
const hasLocation = location !== undefined && location.length > 0;
|
|
2457
|
+
const hasLocation = location !== undefined && location.length > 0 && !isBodyOrCommentLocation(location);
|
|
2484
2458
|
if (hasLocation && context.inSurface && !context.inSurface(location)) {
|
|
2485
2459
|
return { outcome: "deferred", deferralReason: "outside-surface" };
|
|
2486
2460
|
}
|
|
@@ -2847,11 +2821,13 @@ function checkDocUpdateList(prBody) {
|
|
|
2847
2821
|
return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
|
|
2848
2822
|
}
|
|
2849
2823
|
function checkWorktreeStep0(prBody) {
|
|
2850
|
-
if (/git worktree add/.test(prBody))
|
|
2824
|
+
if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
|
|
2851
2825
|
return { status: "pass", errors: [] };
|
|
2852
2826
|
return {
|
|
2853
2827
|
status: "fail",
|
|
2854
|
-
errors: [
|
|
2828
|
+
errors: [
|
|
2829
|
+
"brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
|
|
2830
|
+
]
|
|
2855
2831
|
};
|
|
2856
2832
|
}
|
|
2857
2833
|
function checkStopConditions(prBody) {
|
|
@@ -3041,7 +3017,8 @@ function isCommandBlock(content) {
|
|
|
3041
3017
|
return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
|
|
3042
3018
|
}
|
|
3043
3019
|
function isStep0Block(content) {
|
|
3044
|
-
|
|
3020
|
+
const first = firstNonBlankLine(content);
|
|
3021
|
+
return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
|
|
3045
3022
|
}
|
|
3046
3023
|
function checkCommandsCarryOutput(prBody) {
|
|
3047
3024
|
const errors = [];
|
|
@@ -3510,10 +3487,14 @@ function legacySlugPattern(legacySlugs) {
|
|
|
3510
3487
|
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
3511
3488
|
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
3512
3489
|
}
|
|
3490
|
+
function specGrandfatherPaths(specGrandfather) {
|
|
3491
|
+
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3492
|
+
}
|
|
3513
3493
|
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3514
3494
|
const findings = [];
|
|
3515
3495
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3516
|
-
const
|
|
3496
|
+
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3497
|
+
const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
|
|
3517
3498
|
const patterns = [
|
|
3518
3499
|
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3519
3500
|
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
@@ -3532,18 +3513,19 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
|
|
|
3532
3513
|
continue;
|
|
3533
3514
|
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
3534
3515
|
continue;
|
|
3535
|
-
if (cls === "spec" &&
|
|
3516
|
+
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3536
3517
|
continue;
|
|
3537
3518
|
const blocking = cls === "product" || cls === "spec";
|
|
3538
3519
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3539
3520
|
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3521
|
+
const fileFindings = [];
|
|
3540
3522
|
for (const { pattern, what, group } of patternsToRun) {
|
|
3541
3523
|
pattern.lastIndex = 0;
|
|
3542
3524
|
let match = pattern.exec(scrubbed);
|
|
3543
3525
|
while (match !== null) {
|
|
3544
3526
|
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
3545
3527
|
const citedIndex = match.index + match[0].indexOf(cited);
|
|
3546
|
-
|
|
3528
|
+
fileFindings.push({
|
|
3547
3529
|
file: file.path,
|
|
3548
3530
|
line: lineAt(scrubbed, citedIndex),
|
|
3549
3531
|
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
@@ -3552,6 +3534,15 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
|
|
|
3552
3534
|
match = pattern.exec(scrubbed);
|
|
3553
3535
|
}
|
|
3554
3536
|
}
|
|
3537
|
+
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
3538
|
+
if (limit !== undefined) {
|
|
3539
|
+
if (fileFindings.length <= limit)
|
|
3540
|
+
continue;
|
|
3541
|
+
for (const f of fileFindings) {
|
|
3542
|
+
f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
findings.push(...fileFindings);
|
|
3555
3546
|
}
|
|
3556
3547
|
return findings;
|
|
3557
3548
|
}
|
|
@@ -4133,6 +4124,8 @@ var FILE_EXTENSIONS = new Set([
|
|
|
4133
4124
|
"html",
|
|
4134
4125
|
"css"
|
|
4135
4126
|
]);
|
|
4127
|
+
var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
|
|
4128
|
+
var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
|
|
4136
4129
|
|
|
4137
4130
|
// ../../packages/aeg-core/src/task-branch-identity.ts
|
|
4138
4131
|
var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
|
|
@@ -4511,8 +4504,7 @@ function briefHash(brief) {
|
|
|
4511
4504
|
function policyDigest(policy) {
|
|
4512
4505
|
return createHash4("sha256").update(JSON.stringify({
|
|
4513
4506
|
codeReviewThreshold: policy.codeReviewThreshold,
|
|
4514
|
-
securityThreshold: policy.securityThreshold
|
|
4515
|
-
maxRounds: policy.maxRounds
|
|
4507
|
+
securityThreshold: policy.securityThreshold
|
|
4516
4508
|
})).digest("hex");
|
|
4517
4509
|
}
|
|
4518
4510
|
function isBoundToHead(echoed, headSha) {
|
|
@@ -4825,7 +4817,46 @@ function parseEnforcementRegistry(content) {
|
|
|
4825
4817
|
return result;
|
|
4826
4818
|
}
|
|
4827
4819
|
// ../../packages/aeg-core/src/registry-checks.ts
|
|
4828
|
-
|
|
4820
|
+
var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
|
|
4821
|
+
var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
|
|
4822
|
+
function basename(path) {
|
|
4823
|
+
return path.slice(path.lastIndexOf("/") + 1);
|
|
4824
|
+
}
|
|
4825
|
+
function lineOf(content, index) {
|
|
4826
|
+
let line = 1;
|
|
4827
|
+
for (let i = 0;i < index; i++)
|
|
4828
|
+
if (content.charCodeAt(i) === 10)
|
|
4829
|
+
line++;
|
|
4830
|
+
return line;
|
|
4831
|
+
}
|
|
4832
|
+
function findUnshippedHookRefs(docs, shipped) {
|
|
4833
|
+
const shippedNames = new Set([...shipped].map(basename));
|
|
4834
|
+
const findings = [];
|
|
4835
|
+
const flag = (doc, token, index) => {
|
|
4836
|
+
findings.push({
|
|
4837
|
+
path: doc.path,
|
|
4838
|
+
reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
|
|
4839
|
+
});
|
|
4840
|
+
};
|
|
4841
|
+
for (const doc of docs) {
|
|
4842
|
+
for (const { cited, index } of extractCitedPaths(doc.content)) {
|
|
4843
|
+
if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
|
|
4844
|
+
continue;
|
|
4845
|
+
if (!shipped.has(cited))
|
|
4846
|
+
flag(doc, cited, index);
|
|
4847
|
+
}
|
|
4848
|
+
const spanPattern = /`([^`\n]+)`/g;
|
|
4849
|
+
let match = spanPattern.exec(doc.content);
|
|
4850
|
+
while (match !== null) {
|
|
4851
|
+
const token = match[1] ?? "";
|
|
4852
|
+
if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
|
|
4853
|
+
flag(doc, token, match.index);
|
|
4854
|
+
match = spanPattern.exec(doc.content);
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4857
|
+
return findings;
|
|
4858
|
+
}
|
|
4859
|
+
function checkG1(rows, existsFn, hookRefs) {
|
|
4829
4860
|
const findings = [];
|
|
4830
4861
|
for (const row of rows) {
|
|
4831
4862
|
if (row.implementation === "")
|
|
@@ -4838,6 +4869,8 @@ function checkG1(rows, existsFn) {
|
|
|
4838
4869
|
});
|
|
4839
4870
|
}
|
|
4840
4871
|
}
|
|
4872
|
+
if (hookRefs)
|
|
4873
|
+
findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
|
|
4841
4874
|
return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4842
4875
|
}
|
|
4843
4876
|
var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
@@ -4970,6 +5003,55 @@ function checkG6(rows, registeredCheckNames) {
|
|
|
4970
5003
|
}
|
|
4971
5004
|
return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4972
5005
|
}
|
|
5006
|
+
function reachesProducer(file, producers, imports) {
|
|
5007
|
+
const seen = new Set([file]);
|
|
5008
|
+
const queue = [file];
|
|
5009
|
+
for (let next = queue.pop();next !== undefined; next = queue.pop()) {
|
|
5010
|
+
if (producers.has(next))
|
|
5011
|
+
return true;
|
|
5012
|
+
for (const dep of imports.get(next) ?? []) {
|
|
5013
|
+
if (!seen.has(dep)) {
|
|
5014
|
+
seen.add(dep);
|
|
5015
|
+
queue.push(dep);
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
5019
|
+
return false;
|
|
5020
|
+
}
|
|
5021
|
+
function checkG7(input) {
|
|
5022
|
+
if (!input.enforcementMapPresent)
|
|
5023
|
+
return { check: "G7", status: "info", findings: [] };
|
|
5024
|
+
const subjects = new Set([...input.crossingFiles, ...input.blockingFiles]);
|
|
5025
|
+
const findings = [];
|
|
5026
|
+
for (const path of subjects) {
|
|
5027
|
+
if (path in input.exemptions)
|
|
5028
|
+
continue;
|
|
5029
|
+
if (!reachesProducer(path, input.producers, input.imports)) {
|
|
5030
|
+
findings.push({
|
|
5031
|
+
path,
|
|
5032
|
+
reason: `"${path}" ${input.crossingFiles.includes(path) ? "makes a GitHub-writing call" : "implements a blocking gate"} but neither is a log producer nor imports one, and it is not exempted with a reason`
|
|
5033
|
+
});
|
|
5034
|
+
}
|
|
5035
|
+
}
|
|
5036
|
+
for (const [path, reason] of Object.entries(input.exemptions)) {
|
|
5037
|
+
if (reason.trim() === "") {
|
|
5038
|
+
findings.push({ path, reason: `exemption for "${path}" states no reason` });
|
|
5039
|
+
} else if (!input.existsFn(path)) {
|
|
5040
|
+
findings.push({ path, reason: `exemption names "${path}", which no longer exists` });
|
|
5041
|
+
} else if (!subjects.has(path)) {
|
|
5042
|
+
findings.push({
|
|
5043
|
+
path,
|
|
5044
|
+
reason: `exemption names "${path}", which is neither a GitHub-writing file nor a blocking gate's implementation`
|
|
5045
|
+
});
|
|
5046
|
+
} else if (reachesProducer(path, input.producers, input.imports)) {
|
|
5047
|
+
findings.push({
|
|
5048
|
+
path,
|
|
5049
|
+
reason: `exemption names "${path}", which does reach a log producer — remove the exemption`
|
|
5050
|
+
});
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
return { check: "G7", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
5054
|
+
}
|
|
4973
5055
|
// ../../packages/aeg-core/src/dead-branch-push-guard.ts
|
|
4974
5056
|
function checkDeadBranchPush(input) {
|
|
4975
5057
|
const { branch, prState, prNumber } = input;
|
|
@@ -5149,6 +5231,11 @@ function checkDispatchReadiness(input) {
|
|
|
5149
5231
|
push("depends-on-unresolvable", `dispatch-gate depends-on: ${taskLabel} depends on "${dep.id}", which is UNRESOLVABLE — the resolver could not find a matching tranche/task/Issue for this edge (not a claim about merge status). Not dispatchable until the edge is corrected.`);
|
|
5150
5232
|
continue;
|
|
5151
5233
|
}
|
|
5234
|
+
if (dep.readFailed === true) {
|
|
5235
|
+
const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
|
|
5236
|
+
push("depends-on-read-failed", `dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, but the forge could not be read for that dependency — not a claim about its merge status. Retry the check.`);
|
|
5237
|
+
continue;
|
|
5238
|
+
}
|
|
5152
5239
|
if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
|
|
5153
5240
|
const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
|
|
5154
5241
|
push("depends-on-not-merged", `dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
|
|
@@ -5391,7 +5478,6 @@ var TaskPrPauseSchema = z.object({
|
|
|
5391
5478
|
var TaskPrReviewRecordSchema = z.object({
|
|
5392
5479
|
verdicts: z.array(TaskPrVerdictSchema),
|
|
5393
5480
|
roundMarkers: z.array(z.number().int().nonnegative()),
|
|
5394
|
-
summaryTable: z.string().nullable(),
|
|
5395
5481
|
pause: TaskPrPauseSchema.nullable()
|
|
5396
5482
|
});
|
|
5397
5483
|
var TaskPrReadInputSchema = z.object({
|
|
@@ -5438,16 +5524,6 @@ var TaskCancelResultSchema = z.object({
|
|
|
5438
5524
|
authenticatedFrom: z.string().min(1),
|
|
5439
5525
|
fencedEffectKeys: z.array(z.string())
|
|
5440
5526
|
});
|
|
5441
|
-
var TASK_TOOL_NAMES = [
|
|
5442
|
-
"task_start",
|
|
5443
|
-
"task_status",
|
|
5444
|
-
"task_escalation_read",
|
|
5445
|
-
"task_pr_read",
|
|
5446
|
-
"task_resume",
|
|
5447
|
-
"task_cancel"
|
|
5448
|
-
];
|
|
5449
|
-
var OPERATOR_STATUS_FOLLOW = "task_status_follow";
|
|
5450
|
-
var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
|
|
5451
5527
|
// ../../packages/aeg-core/src/first-push-dispatch-gate.ts
|
|
5452
5528
|
function parseTaskBranch(branch) {
|
|
5453
5529
|
const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
|
|
@@ -5678,16 +5754,71 @@ var NO_GATE_CUTOVERS = {
|
|
|
5678
5754
|
briefRulesSincePr: null,
|
|
5679
5755
|
agentBoxesRefusedSincePr: null
|
|
5680
5756
|
};
|
|
5681
|
-
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5682
|
-
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5683
|
-
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
5684
|
-
var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
|
|
5685
|
-
// ../../packages/aeg-core/src/log/envelope.ts
|
|
5686
|
-
import { createHash as createHash5 } from "node:crypto";
|
|
5687
|
-
|
|
5688
5757
|
// ../../packages/aeg-core/src/log/schema.ts
|
|
5758
|
+
import { z as z3 } from "zod";
|
|
5759
|
+
|
|
5760
|
+
// ../../packages/aeg-core/src/log/custom.ts
|
|
5689
5761
|
import { z as z2 } from "zod";
|
|
5762
|
+
var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
|
|
5763
|
+
var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
|
|
5764
|
+
var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
|
|
5765
|
+
var CUSTOM_EVENT_MAX_FIELDS = 20;
|
|
5766
|
+
var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
5767
|
+
var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
|
|
5768
|
+
var CUSTOM_TEXT_MAX_LENGTH = 500;
|
|
5769
|
+
var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
5770
|
+
var CUSTOM_WORD_MAX_LENGTH = 64;
|
|
5771
|
+
var CUSTOM_FIELD_MAX_WORDS = 50;
|
|
5772
|
+
var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
|
|
5773
|
+
var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
|
|
5774
|
+
fields: z2.record(z2.string(), CustomFieldTypeSchema)
|
|
5775
|
+
}).strict()).superRefine((events, ctx) => {
|
|
5776
|
+
for (const [name, declaration] of Object.entries(events)) {
|
|
5777
|
+
const refuse = (message, path = []) => {
|
|
5778
|
+
ctx.addIssue({
|
|
5779
|
+
code: z2.ZodIssueCode.custom,
|
|
5780
|
+
path: [name, ...path],
|
|
5781
|
+
message: `logs.events "${name}": ${message}`
|
|
5782
|
+
});
|
|
5783
|
+
};
|
|
5784
|
+
if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
|
|
5785
|
+
refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
|
|
5786
|
+
}
|
|
5787
|
+
if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
|
|
5788
|
+
refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
|
|
5789
|
+
} else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
|
|
5790
|
+
refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
|
|
5791
|
+
}
|
|
5792
|
+
const fieldEntries = Object.entries(declaration.fields);
|
|
5793
|
+
if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
|
|
5794
|
+
refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
|
|
5795
|
+
}
|
|
5796
|
+
for (const [field, type] of fieldEntries) {
|
|
5797
|
+
if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
|
|
5798
|
+
refuse(`field "${field}": a field name is lowercase letters, digits and \`_\`, starting with a letter, at most ${CUSTOM_FIELD_NAME_MAX_LENGTH} characters`, ["fields", field]);
|
|
5799
|
+
}
|
|
5800
|
+
if (typeof type === "string")
|
|
5801
|
+
continue;
|
|
5802
|
+
if (type.length === 0) {
|
|
5803
|
+
refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
|
|
5804
|
+
}
|
|
5805
|
+
if (type.length > CUSTOM_FIELD_MAX_WORDS) {
|
|
5806
|
+
refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
|
|
5807
|
+
}
|
|
5808
|
+
const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
|
|
5809
|
+
if (bad.length > 0) {
|
|
5810
|
+
refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
|
|
5811
|
+
}
|
|
5812
|
+
if (new Set(type).size !== type.length) {
|
|
5813
|
+
refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
|
|
5814
|
+
}
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5817
|
+
});
|
|
5818
|
+
|
|
5819
|
+
// ../../packages/aeg-core/src/log/schema.ts
|
|
5690
5820
|
var CONFIDENCE_REASON_MAX_LENGTH = 280;
|
|
5821
|
+
var REVIEW_FINDING_DESCRIPTION_MAX_LENGTH = 1000;
|
|
5691
5822
|
var ROLE_VALUES = [
|
|
5692
5823
|
"planner",
|
|
5693
5824
|
"developer",
|
|
@@ -5697,178 +5828,214 @@ var ROLE_VALUES = [
|
|
|
5697
5828
|
"archivist",
|
|
5698
5829
|
"architect"
|
|
5699
5830
|
];
|
|
5700
|
-
var RoleSchema =
|
|
5831
|
+
var RoleSchema = z3.enum(ROLE_VALUES);
|
|
5701
5832
|
var HOST_VALUES = ["hook", "ci", "cli", "loop"];
|
|
5702
|
-
var HostSchema =
|
|
5833
|
+
var HostSchema = z3.enum(HOST_VALUES);
|
|
5703
5834
|
var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
|
|
5704
5835
|
var headerMetaCore = {
|
|
5705
|
-
ts:
|
|
5706
|
-
run_id:
|
|
5707
|
-
seq:
|
|
5708
|
-
repo:
|
|
5709
|
-
vinaya:
|
|
5710
|
-
doctrine:
|
|
5836
|
+
ts: z3.string(),
|
|
5837
|
+
run_id: z3.string().regex(RUN_ID_PATTERN),
|
|
5838
|
+
seq: z3.number().int().nonnegative(),
|
|
5839
|
+
repo: z3.string().nullable(),
|
|
5840
|
+
vinaya: z3.string(),
|
|
5841
|
+
doctrine: z3.string(),
|
|
5711
5842
|
host: HostSchema,
|
|
5712
|
-
machine:
|
|
5843
|
+
machine: z3.string()
|
|
5713
5844
|
};
|
|
5714
|
-
var HeaderMetaV1Schema =
|
|
5715
|
-
schema:
|
|
5845
|
+
var HeaderMetaV1Schema = z3.object({
|
|
5846
|
+
schema: z3.literal(1),
|
|
5716
5847
|
...headerMetaCore
|
|
5717
5848
|
}).strict();
|
|
5718
|
-
var LineageSchema =
|
|
5719
|
-
run:
|
|
5720
|
-
attempt:
|
|
5721
|
-
parent:
|
|
5849
|
+
var LineageSchema = z3.object({
|
|
5850
|
+
run: z3.string().nullable(),
|
|
5851
|
+
attempt: z3.number().int().nullable(),
|
|
5852
|
+
parent: z3.string().nullable()
|
|
5722
5853
|
}).strict();
|
|
5723
|
-
var InputVersionsSchema =
|
|
5724
|
-
objectives_version:
|
|
5725
|
-
brief_hash:
|
|
5726
|
-
ruling_ordinal:
|
|
5727
|
-
policy_digest:
|
|
5854
|
+
var InputVersionsSchema = z3.object({
|
|
5855
|
+
objectives_version: z3.string().nullable(),
|
|
5856
|
+
brief_hash: z3.string().nullable(),
|
|
5857
|
+
ruling_ordinal: z3.number().int().nullable(),
|
|
5858
|
+
policy_digest: z3.string().nullable()
|
|
5728
5859
|
}).strict();
|
|
5729
|
-
var ProvenanceSchema =
|
|
5730
|
-
var HeaderMetaV2Schema =
|
|
5731
|
-
schema:
|
|
5860
|
+
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
5861
|
+
var HeaderMetaV2Schema = z3.object({
|
|
5862
|
+
schema: z3.literal(2),
|
|
5732
5863
|
...headerMetaCore,
|
|
5733
|
-
event_id:
|
|
5734
|
-
process_id:
|
|
5735
|
-
actor_id:
|
|
5864
|
+
event_id: z3.string().min(1),
|
|
5865
|
+
process_id: z3.string().min(1),
|
|
5866
|
+
actor_id: z3.string().nullable(),
|
|
5736
5867
|
lineage: LineageSchema,
|
|
5737
5868
|
input_versions: InputVersionsSchema,
|
|
5738
5869
|
provenance: ProvenanceSchema
|
|
5739
5870
|
}).strict();
|
|
5740
|
-
var
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
role: z2.union([RoleSchema, z2.literal("unattributed")]),
|
|
5746
|
-
round: z2.number().int().optional(),
|
|
5747
|
-
objectives_version: z2.string().optional()
|
|
5871
|
+
var WorkSchema = z3.object({
|
|
5872
|
+
ref: z3.string().nullable(),
|
|
5873
|
+
repo: z3.string().nullable(),
|
|
5874
|
+
change: z3.string().nullable(),
|
|
5875
|
+
revision: z3.string().nullable()
|
|
5748
5876
|
}).strict();
|
|
5749
|
-
var
|
|
5877
|
+
var FlowSchema = z3.object({
|
|
5878
|
+
id: z3.string().nullable(),
|
|
5879
|
+
version: z3.string().nullable()
|
|
5880
|
+
}).strict();
|
|
5881
|
+
var HeaderMetaV3Schema = z3.object({
|
|
5882
|
+
schema: z3.literal(3),
|
|
5883
|
+
...headerMetaCore,
|
|
5884
|
+
event_id: z3.string().min(1),
|
|
5885
|
+
process_id: z3.string().min(1),
|
|
5886
|
+
actor_id: z3.string().nullable(),
|
|
5887
|
+
lineage: LineageSchema,
|
|
5888
|
+
input_versions: InputVersionsSchema,
|
|
5889
|
+
provenance: ProvenanceSchema,
|
|
5890
|
+
work: WorkSchema,
|
|
5891
|
+
flow: FlowSchema,
|
|
5892
|
+
runtime: z3.string().nullable(),
|
|
5893
|
+
source: z3.string().nullable()
|
|
5894
|
+
}).strict();
|
|
5895
|
+
var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
|
|
5896
|
+
var SubjectSchema = z3.object({
|
|
5897
|
+
issue: z3.number().int().nullable(),
|
|
5898
|
+
pr: z3.number().int().optional(),
|
|
5899
|
+
sha: z3.string().optional(),
|
|
5900
|
+
role: z3.union([RoleSchema, z3.literal("unattributed")]),
|
|
5901
|
+
round: z3.number().int().optional(),
|
|
5902
|
+
objectives_version: z3.string().optional()
|
|
5903
|
+
}).strict();
|
|
5904
|
+
var HeaderSchema = z3.object({
|
|
5750
5905
|
meta: HeaderMetaSchema,
|
|
5751
5906
|
subject: SubjectSchema
|
|
5752
5907
|
}).strict();
|
|
5753
5908
|
var envelopeTail = {
|
|
5754
|
-
duration_ms:
|
|
5755
|
-
payload:
|
|
5909
|
+
duration_ms: z3.number().nonnegative().optional(),
|
|
5910
|
+
payload: z3.object({}).strict()
|
|
5756
5911
|
};
|
|
5757
|
-
var ReviewFindingSchema =
|
|
5758
|
-
id:
|
|
5759
|
-
severity:
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5912
|
+
var ReviewFindingSchema = z3.object({
|
|
5913
|
+
id: z3.string(),
|
|
5914
|
+
severity: z3.string(),
|
|
5915
|
+
location: z3.string().optional(),
|
|
5916
|
+
deferral_reason: z3.enum(["outside-surface", "unchanged-line"]).optional(),
|
|
5917
|
+
description: z3.string().max(REVIEW_FINDING_DESCRIPTION_MAX_LENGTH).optional(),
|
|
5918
|
+
state: z3.string().optional(),
|
|
5919
|
+
severity_scale: z3.string().optional(),
|
|
5920
|
+
policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
|
|
5921
|
+
confidence: z3.number().min(0).max(1).optional(),
|
|
5922
|
+
confidence_scale: z3.string().optional(),
|
|
5923
|
+
confidence_source: z3.string().optional()
|
|
5766
5924
|
}).strict();
|
|
5767
|
-
var DispatchOutcomeSchema =
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
type:
|
|
5771
|
-
pr:
|
|
5772
|
-
head:
|
|
5773
|
-
comment_id:
|
|
5925
|
+
var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
|
|
5926
|
+
z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
|
|
5927
|
+
z3.object({
|
|
5928
|
+
type: z3.literal("round_pushed"),
|
|
5929
|
+
pr: z3.number().int(),
|
|
5930
|
+
head: z3.string(),
|
|
5931
|
+
comment_id: z3.number().int()
|
|
5774
5932
|
}).strict(),
|
|
5775
|
-
|
|
5776
|
-
type:
|
|
5777
|
-
verdict:
|
|
5778
|
-
head:
|
|
5779
|
-
comment_id:
|
|
5780
|
-
objectives:
|
|
5781
|
-
findings:
|
|
5933
|
+
z3.object({
|
|
5934
|
+
type: z3.literal("verdict"),
|
|
5935
|
+
verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
|
|
5936
|
+
head: z3.string(),
|
|
5937
|
+
comment_id: z3.number().int(),
|
|
5938
|
+
objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
|
|
5939
|
+
findings: z3.array(ReviewFindingSchema)
|
|
5782
5940
|
}).strict(),
|
|
5783
|
-
|
|
5784
|
-
type:
|
|
5785
|
-
class:
|
|
5786
|
-
comment_id:
|
|
5941
|
+
z3.object({
|
|
5942
|
+
type: z3.literal("escalation"),
|
|
5943
|
+
class: z3.enum(["authority", "strategy", "product"]),
|
|
5944
|
+
comment_id: z3.number().int()
|
|
5787
5945
|
}).strict(),
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5946
|
+
z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
|
|
5947
|
+
z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
|
|
5948
|
+
z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
|
|
5949
|
+
z3.object({ type: z3.literal("completed") }).strict()
|
|
5792
5950
|
]);
|
|
5793
5951
|
var dispatchShared = {
|
|
5794
5952
|
meta: HeaderMetaSchema,
|
|
5795
5953
|
subject: SubjectSchema,
|
|
5796
|
-
kind:
|
|
5954
|
+
kind: z3.literal("dispatch"),
|
|
5797
5955
|
...envelopeTail,
|
|
5798
5956
|
target_role: RoleSchema,
|
|
5799
|
-
model:
|
|
5800
|
-
round:
|
|
5801
|
-
effect_id:
|
|
5957
|
+
model: z3.string(),
|
|
5958
|
+
round: z3.number().int().optional(),
|
|
5959
|
+
effect_id: z3.string()
|
|
5802
5960
|
};
|
|
5803
|
-
var dispatchUsageField =
|
|
5804
|
-
var DispatchEventSchema =
|
|
5805
|
-
|
|
5806
|
-
|
|
5961
|
+
var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
|
|
5962
|
+
var DispatchEventSchema = z3.discriminatedUnion("event", [
|
|
5963
|
+
z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
|
|
5964
|
+
z3.object({
|
|
5807
5965
|
...dispatchShared,
|
|
5808
|
-
event:
|
|
5966
|
+
event: z3.literal("outcome_received"),
|
|
5809
5967
|
outcome: DispatchOutcomeSchema,
|
|
5810
5968
|
usage: dispatchUsageField
|
|
5811
5969
|
}).strict(),
|
|
5812
|
-
|
|
5970
|
+
z3.object({
|
|
5813
5971
|
...dispatchShared,
|
|
5814
|
-
event:
|
|
5815
|
-
reason:
|
|
5972
|
+
event: z3.literal("dispatch_failed"),
|
|
5973
|
+
reason: z3.enum(["timeout", "crash", "refused", "unattributed_write", "usage_limit"]),
|
|
5974
|
+
usage_limit: z3.object({ agent: z3.string().min(1), reset_at: z3.string().nullable() }).strict().optional(),
|
|
5816
5975
|
usage: dispatchUsageField
|
|
5817
5976
|
}).strict()
|
|
5818
5977
|
]);
|
|
5978
|
+
var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
|
|
5979
|
+
var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
|
|
5980
|
+
var ReviewerVerdictSchema = z3.object({
|
|
5981
|
+
role: RoleSchema,
|
|
5982
|
+
outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
|
|
5983
|
+
blockers: z3.number().int().nonnegative()
|
|
5984
|
+
}).strict();
|
|
5819
5985
|
var loopShared = {
|
|
5820
5986
|
meta: HeaderMetaSchema,
|
|
5821
5987
|
subject: SubjectSchema,
|
|
5822
|
-
kind:
|
|
5988
|
+
kind: z3.literal("dev_review_loop"),
|
|
5823
5989
|
...envelopeTail,
|
|
5824
|
-
loop_id:
|
|
5990
|
+
loop_id: z3.string()
|
|
5825
5991
|
};
|
|
5826
|
-
var DevReviewLoopEventSchema =
|
|
5827
|
-
|
|
5992
|
+
var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
|
|
5993
|
+
z3.object({
|
|
5828
5994
|
...loopShared,
|
|
5829
|
-
event:
|
|
5830
|
-
task:
|
|
5831
|
-
policy:
|
|
5832
|
-
max_rounds:
|
|
5833
|
-
reviewers:
|
|
5834
|
-
models:
|
|
5995
|
+
event: z3.literal("loop_started"),
|
|
5996
|
+
task: z3.number().int(),
|
|
5997
|
+
policy: z3.object({
|
|
5998
|
+
max_rounds: z3.number().int().nonnegative(),
|
|
5999
|
+
reviewers: z3.array(RoleSchema),
|
|
6000
|
+
models: z3.record(RoleSchema, z3.string())
|
|
5835
6001
|
}).strict()
|
|
5836
6002
|
}).strict(),
|
|
5837
|
-
|
|
5838
|
-
|
|
6003
|
+
z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
|
|
6004
|
+
z3.object({
|
|
5839
6005
|
...loopShared,
|
|
5840
|
-
event:
|
|
5841
|
-
round:
|
|
5842
|
-
head:
|
|
5843
|
-
green:
|
|
5844
|
-
confidence_value:
|
|
5845
|
-
confidence_reason:
|
|
5846
|
-
confidence_unavailable:
|
|
5847
|
-
extra_turn_spent:
|
|
6006
|
+
event: z3.literal("gate_result_read"),
|
|
6007
|
+
round: z3.number().int(),
|
|
6008
|
+
head: z3.string(),
|
|
6009
|
+
green: z3.boolean(),
|
|
6010
|
+
confidence_value: z3.number().int().min(0).max(100).optional(),
|
|
6011
|
+
confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
|
|
6012
|
+
confidence_unavailable: z3.boolean().optional(),
|
|
6013
|
+
extra_turn_spent: z3.boolean().optional()
|
|
5848
6014
|
}).strict(),
|
|
5849
|
-
|
|
6015
|
+
z3.object({
|
|
5850
6016
|
...loopShared,
|
|
5851
|
-
event:
|
|
5852
|
-
round:
|
|
5853
|
-
head:
|
|
5854
|
-
all_approve:
|
|
5855
|
-
blockers:
|
|
5856
|
-
findings:
|
|
6017
|
+
event: z3.literal("verdicts_read"),
|
|
6018
|
+
round: z3.number().int(),
|
|
6019
|
+
head: z3.string(),
|
|
6020
|
+
all_approve: z3.boolean(),
|
|
6021
|
+
blockers: z3.number().int().nonnegative(),
|
|
6022
|
+
findings: z3.array(ReviewFindingSchema).optional(),
|
|
6023
|
+
reviewers: z3.array(ReviewerVerdictSchema).optional()
|
|
5857
6024
|
}).strict(),
|
|
5858
|
-
|
|
6025
|
+
z3.object({
|
|
5859
6026
|
...loopShared,
|
|
5860
|
-
event:
|
|
5861
|
-
round:
|
|
5862
|
-
open:
|
|
5863
|
-
resolved:
|
|
5864
|
-
new:
|
|
5865
|
-
recurring:
|
|
6027
|
+
event: z3.literal("findings_compared"),
|
|
6028
|
+
round: z3.number().int(),
|
|
6029
|
+
open: z3.array(z3.string()),
|
|
6030
|
+
resolved: z3.array(z3.string()),
|
|
6031
|
+
new: z3.array(z3.string()),
|
|
6032
|
+
recurring: z3.array(z3.string())
|
|
5866
6033
|
}).strict(),
|
|
5867
|
-
|
|
6034
|
+
z3.object({
|
|
5868
6035
|
...loopShared,
|
|
5869
|
-
event:
|
|
5870
|
-
round:
|
|
5871
|
-
condition:
|
|
6036
|
+
event: z3.literal("stop_condition_met"),
|
|
6037
|
+
round: z3.number().int(),
|
|
6038
|
+
condition: z3.enum([
|
|
5872
6039
|
"green",
|
|
5873
6040
|
"max_rounds",
|
|
5874
6041
|
"no_progress",
|
|
@@ -5877,66 +6044,85 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
|
|
|
5877
6044
|
"confidence",
|
|
5878
6045
|
"reappearance",
|
|
5879
6046
|
"repeat_finding",
|
|
5880
|
-
"repeat_failure"
|
|
6047
|
+
"repeat_failure",
|
|
6048
|
+
"time_budget"
|
|
5881
6049
|
])
|
|
5882
6050
|
}).strict(),
|
|
5883
|
-
|
|
6051
|
+
z3.object({
|
|
6052
|
+
...loopShared,
|
|
6053
|
+
event: z3.literal("paused"),
|
|
6054
|
+
round: z3.number().int(),
|
|
6055
|
+
reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
|
|
6056
|
+
reason_code: CodeTokenSchema.optional()
|
|
6057
|
+
}).strict(),
|
|
6058
|
+
z3.object({
|
|
6059
|
+
...loopShared,
|
|
6060
|
+
event: z3.literal("resumed"),
|
|
6061
|
+
round: z3.number().int(),
|
|
6062
|
+
by: z3.enum(["principal", "driver"])
|
|
6063
|
+
}).strict(),
|
|
6064
|
+
z3.object({
|
|
5884
6065
|
...loopShared,
|
|
5885
|
-
event:
|
|
5886
|
-
round:
|
|
5887
|
-
|
|
6066
|
+
event: z3.literal("cancelled"),
|
|
6067
|
+
round: z3.number().int(),
|
|
6068
|
+
by: z3.literal("principal")
|
|
5888
6069
|
}).strict(),
|
|
5889
|
-
|
|
6070
|
+
z3.object({
|
|
5890
6071
|
...loopShared,
|
|
5891
|
-
event:
|
|
5892
|
-
round:
|
|
5893
|
-
|
|
6072
|
+
event: z3.literal("unpushed_work_resume"),
|
|
6073
|
+
round: z3.number().int(),
|
|
6074
|
+
branch: z3.string(),
|
|
6075
|
+
detail: z3.string()
|
|
5894
6076
|
}).strict(),
|
|
5895
|
-
|
|
6077
|
+
z3.object({
|
|
5896
6078
|
...loopShared,
|
|
5897
|
-
event:
|
|
5898
|
-
round:
|
|
5899
|
-
|
|
6079
|
+
event: z3.literal("round_ended"),
|
|
6080
|
+
round: z3.number().int(),
|
|
6081
|
+
base_head: z3.string(),
|
|
6082
|
+
head: z3.string(),
|
|
6083
|
+
files_changed: z3.number().int().nonnegative(),
|
|
6084
|
+
insertions: z3.number().int().nonnegative(),
|
|
6085
|
+
deletions: z3.number().int().nonnegative(),
|
|
6086
|
+
wall_ms: z3.number().nonnegative(),
|
|
6087
|
+
outcome: z3.enum(["green", "changes_requested", "escalated"])
|
|
5900
6088
|
}).strict(),
|
|
5901
|
-
|
|
6089
|
+
z3.object({
|
|
5902
6090
|
...loopShared,
|
|
5903
|
-
event:
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
6091
|
+
event: z3.literal("journal_finalized"),
|
|
6092
|
+
rounds: z3.number().int().nonnegative(),
|
|
6093
|
+
total_wall_ms: z3.number().nonnegative(),
|
|
6094
|
+
time_to_green_ms: z3.number().nonnegative().nullable(),
|
|
6095
|
+
files_changed_total: z3.number().int().nonnegative(),
|
|
6096
|
+
final_head: z3.string(),
|
|
6097
|
+
result: z3.enum(["merged_ready", "stopped"])
|
|
5907
6098
|
}).strict(),
|
|
5908
|
-
|
|
6099
|
+
z3.object({
|
|
5909
6100
|
...loopShared,
|
|
5910
|
-
event:
|
|
5911
|
-
round:
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
insertions: z2.number().int().nonnegative(),
|
|
5916
|
-
deletions: z2.number().int().nonnegative(),
|
|
5917
|
-
wall_ms: z2.number().nonnegative(),
|
|
5918
|
-
outcome: z2.enum(["green", "changes_requested", "escalated"])
|
|
6101
|
+
event: z3.literal("infrastructure_retry"),
|
|
6102
|
+
round: z3.number().int(),
|
|
6103
|
+
failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
|
|
6104
|
+
attempts: z3.number().int().positive(),
|
|
6105
|
+
outcome: z3.enum(["recovered", "exhausted"])
|
|
5919
6106
|
}).strict(),
|
|
5920
|
-
|
|
6107
|
+
z3.object({
|
|
5921
6108
|
...loopShared,
|
|
5922
|
-
event:
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
final_head: z2.string(),
|
|
5928
|
-
result: z2.enum(["merged_ready", "stopped"])
|
|
6109
|
+
event: z3.literal("driver_heartbeat"),
|
|
6110
|
+
task: z3.number().int(),
|
|
6111
|
+
pr: z3.number().int().positive().optional(),
|
|
6112
|
+
round: z3.number().int(),
|
|
6113
|
+
phase: z3.string()
|
|
5929
6114
|
}).strict(),
|
|
5930
|
-
|
|
6115
|
+
z3.object({
|
|
5931
6116
|
...loopShared,
|
|
5932
|
-
event:
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
6117
|
+
event: z3.literal("driver_exited"),
|
|
6118
|
+
task: z3.number().int(),
|
|
6119
|
+
reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
|
|
6120
|
+
last_decision: z3.string(),
|
|
6121
|
+
exit_code: z3.number().int().optional(),
|
|
6122
|
+
error_class: CodeTokenSchema.optional()
|
|
5937
6123
|
}).strict()
|
|
5938
6124
|
]);
|
|
5939
|
-
var ForgeOpSchema =
|
|
6125
|
+
var ForgeOpSchema = z3.enum([
|
|
5940
6126
|
"pr.create",
|
|
5941
6127
|
"pr.comment",
|
|
5942
6128
|
"pr.body.replace",
|
|
@@ -5950,24 +6136,24 @@ var ForgeOpSchema = z2.enum([
|
|
|
5950
6136
|
"label.add",
|
|
5951
6137
|
"label.remove"
|
|
5952
6138
|
]);
|
|
5953
|
-
var ForgeWriteTargetSchema =
|
|
5954
|
-
issue:
|
|
5955
|
-
pr:
|
|
6139
|
+
var ForgeWriteTargetSchema = z3.object({
|
|
6140
|
+
issue: z3.number().int().optional(),
|
|
6141
|
+
pr: z3.number().int().optional()
|
|
5956
6142
|
}).strict();
|
|
5957
6143
|
var forgeWriteShared = {
|
|
5958
6144
|
meta: HeaderMetaSchema,
|
|
5959
6145
|
subject: SubjectSchema,
|
|
5960
|
-
kind:
|
|
6146
|
+
kind: z3.literal("forge_write"),
|
|
5961
6147
|
...envelopeTail,
|
|
5962
6148
|
op: ForgeOpSchema,
|
|
5963
6149
|
target: ForgeWriteTargetSchema
|
|
5964
6150
|
};
|
|
5965
|
-
var ForgeWriteEventSchema =
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
6151
|
+
var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
|
|
6152
|
+
z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
|
|
6153
|
+
z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
|
|
6154
|
+
z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
|
|
5969
6155
|
]);
|
|
5970
|
-
var GateOutcomeSchema =
|
|
6156
|
+
var GateOutcomeSchema = z3.enum([
|
|
5971
6157
|
"pass",
|
|
5972
6158
|
"fail",
|
|
5973
6159
|
"wait",
|
|
@@ -5980,61 +6166,74 @@ var GateOutcomeSchema = z2.enum([
|
|
|
5980
6166
|
var gateShared = {
|
|
5981
6167
|
meta: HeaderMetaSchema,
|
|
5982
6168
|
subject: SubjectSchema,
|
|
5983
|
-
kind:
|
|
6169
|
+
kind: z3.literal("gate"),
|
|
5984
6170
|
...envelopeTail,
|
|
5985
|
-
check:
|
|
5986
|
-
check_version:
|
|
5987
|
-
policy_version:
|
|
5988
|
-
input_fingerprint:
|
|
6171
|
+
check: z3.string(),
|
|
6172
|
+
check_version: z3.string().nullable(),
|
|
6173
|
+
policy_version: z3.string().nullable(),
|
|
6174
|
+
input_fingerprint: z3.string().nullable()
|
|
5989
6175
|
};
|
|
5990
|
-
var GateEventSchema =
|
|
5991
|
-
|
|
6176
|
+
var GateEventSchema = z3.discriminatedUnion("event", [
|
|
6177
|
+
z3.object({
|
|
5992
6178
|
...gateShared,
|
|
5993
|
-
event:
|
|
6179
|
+
event: z3.literal("checked"),
|
|
5994
6180
|
outcome: GateOutcomeSchema,
|
|
5995
|
-
reason:
|
|
6181
|
+
reason: z3.string().optional()
|
|
6182
|
+
}).strict(),
|
|
6183
|
+
z3.object({
|
|
6184
|
+
meta: HeaderMetaSchema,
|
|
6185
|
+
subject: SubjectSchema,
|
|
6186
|
+
kind: z3.literal("gate"),
|
|
6187
|
+
...envelopeTail,
|
|
6188
|
+
event: z3.literal("summary"),
|
|
6189
|
+
ran: z3.number().int().nonnegative(),
|
|
6190
|
+
passed: z3.number().int().nonnegative(),
|
|
6191
|
+
failed: z3.number().int().nonnegative(),
|
|
6192
|
+
skipped: z3.number().int().nonnegative(),
|
|
6193
|
+
failed_checks: z3.array(z3.string())
|
|
5996
6194
|
}).strict()
|
|
5997
6195
|
]);
|
|
5998
|
-
var OperationResultSchema =
|
|
6196
|
+
var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
|
|
5999
6197
|
var operationShared = {
|
|
6000
6198
|
meta: HeaderMetaSchema,
|
|
6001
6199
|
subject: SubjectSchema,
|
|
6002
|
-
kind:
|
|
6200
|
+
kind: z3.literal("operation"),
|
|
6003
6201
|
...envelopeTail,
|
|
6004
|
-
operation:
|
|
6005
|
-
target:
|
|
6202
|
+
operation: z3.string(),
|
|
6203
|
+
target: z3.string().nullable()
|
|
6006
6204
|
};
|
|
6007
|
-
var OperationEventSchema =
|
|
6008
|
-
|
|
6205
|
+
var OperationEventSchema = z3.discriminatedUnion("event", [
|
|
6206
|
+
z3.object({
|
|
6009
6207
|
...operationShared,
|
|
6010
|
-
event:
|
|
6208
|
+
event: z3.literal("completed"),
|
|
6011
6209
|
result: OperationResultSchema,
|
|
6012
|
-
error_class:
|
|
6210
|
+
error_class: z3.string().nullable(),
|
|
6211
|
+
field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
|
|
6013
6212
|
}).strict()
|
|
6014
6213
|
]);
|
|
6015
|
-
var UsageUnitsSchema =
|
|
6016
|
-
input:
|
|
6017
|
-
output:
|
|
6018
|
-
cache:
|
|
6214
|
+
var UsageUnitsSchema = z3.object({
|
|
6215
|
+
input: z3.number().nonnegative().nullable(),
|
|
6216
|
+
output: z3.number().nonnegative().nullable(),
|
|
6217
|
+
cache: z3.number().nonnegative().nullable()
|
|
6019
6218
|
}).strict();
|
|
6020
6219
|
var usageShared = {
|
|
6021
6220
|
meta: HeaderMetaSchema,
|
|
6022
6221
|
subject: SubjectSchema,
|
|
6023
|
-
kind:
|
|
6222
|
+
kind: z3.literal("usage"),
|
|
6024
6223
|
...envelopeTail,
|
|
6025
|
-
model:
|
|
6026
|
-
source:
|
|
6027
|
-
semantics:
|
|
6224
|
+
model: z3.string().nullable(),
|
|
6225
|
+
source: z3.string(),
|
|
6226
|
+
semantics: z3.enum(["cumulative", "delta"])
|
|
6028
6227
|
};
|
|
6029
|
-
var UsageEventSchema =
|
|
6030
|
-
|
|
6228
|
+
var UsageEventSchema = z3.discriminatedUnion("event", [
|
|
6229
|
+
z3.object({
|
|
6031
6230
|
...usageShared,
|
|
6032
|
-
event:
|
|
6231
|
+
event: z3.literal("observed"),
|
|
6033
6232
|
units: UsageUnitsSchema,
|
|
6034
|
-
unknown_reason:
|
|
6233
|
+
unknown_reason: z3.string().nullable()
|
|
6035
6234
|
}).strict()
|
|
6036
6235
|
]);
|
|
6037
|
-
var RoleAttemptOutcomeSchema =
|
|
6236
|
+
var RoleAttemptOutcomeSchema = z3.enum([
|
|
6038
6237
|
"completed",
|
|
6039
6238
|
"incomplete",
|
|
6040
6239
|
"infrastructure_failed",
|
|
@@ -6045,17 +6244,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
|
|
|
6045
6244
|
var roleAttemptShared = {
|
|
6046
6245
|
meta: HeaderMetaSchema,
|
|
6047
6246
|
subject: SubjectSchema,
|
|
6048
|
-
kind:
|
|
6247
|
+
kind: z3.literal("role_attempt"),
|
|
6049
6248
|
...envelopeTail,
|
|
6050
|
-
actor:
|
|
6051
|
-
attempt:
|
|
6052
|
-
effect_id:
|
|
6053
|
-
model:
|
|
6249
|
+
actor: z3.string().nullable(),
|
|
6250
|
+
attempt: z3.number().int().nullable(),
|
|
6251
|
+
effect_id: z3.string(),
|
|
6252
|
+
model: z3.string().nullable()
|
|
6054
6253
|
};
|
|
6055
|
-
var RoleAttemptEventSchema =
|
|
6056
|
-
|
|
6254
|
+
var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
|
|
6255
|
+
z3.object({
|
|
6057
6256
|
...roleAttemptShared,
|
|
6058
|
-
event:
|
|
6257
|
+
event: z3.literal("attempted"),
|
|
6059
6258
|
outcome: RoleAttemptOutcomeSchema,
|
|
6060
6259
|
usage: dispatchUsageField
|
|
6061
6260
|
}).strict()
|
|
@@ -6063,42 +6262,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
|
|
|
6063
6262
|
var handoffShared = {
|
|
6064
6263
|
meta: HeaderMetaSchema,
|
|
6065
6264
|
subject: SubjectSchema,
|
|
6066
|
-
kind:
|
|
6265
|
+
kind: z3.literal("handoff"),
|
|
6067
6266
|
...envelopeTail,
|
|
6068
|
-
class:
|
|
6069
|
-
reason:
|
|
6267
|
+
class: z3.enum(["authority", "strategy", "product"]),
|
|
6268
|
+
reason: z3.string()
|
|
6070
6269
|
};
|
|
6071
|
-
var HandoffEventSchema =
|
|
6072
|
-
|
|
6270
|
+
var HandoffEventSchema = z3.discriminatedUnion("event", [
|
|
6271
|
+
z3.object({
|
|
6073
6272
|
...handoffShared,
|
|
6074
|
-
event:
|
|
6075
|
-
requested_decision:
|
|
6273
|
+
event: z3.literal("raised"),
|
|
6274
|
+
requested_decision: z3.string().nullable()
|
|
6076
6275
|
}).strict(),
|
|
6077
|
-
|
|
6276
|
+
z3.object({
|
|
6078
6277
|
...handoffShared,
|
|
6079
|
-
event:
|
|
6080
|
-
resolution:
|
|
6081
|
-
resolved_by:
|
|
6278
|
+
event: z3.literal("resolved"),
|
|
6279
|
+
resolution: z3.string().nullable(),
|
|
6280
|
+
resolved_by: z3.string().nullable()
|
|
6082
6281
|
}).strict()
|
|
6083
6282
|
]);
|
|
6084
|
-
var EffectTargetSchema =
|
|
6085
|
-
kind:
|
|
6086
|
-
ref:
|
|
6283
|
+
var EffectTargetSchema = z3.object({
|
|
6284
|
+
kind: z3.string(),
|
|
6285
|
+
ref: z3.string()
|
|
6087
6286
|
}).strict();
|
|
6088
6287
|
var effectShared = {
|
|
6089
6288
|
meta: HeaderMetaSchema,
|
|
6090
6289
|
subject: SubjectSchema,
|
|
6091
|
-
kind:
|
|
6290
|
+
kind: z3.literal("effect"),
|
|
6092
6291
|
...envelopeTail,
|
|
6093
|
-
effect_id:
|
|
6292
|
+
effect_id: z3.string(),
|
|
6094
6293
|
target: EffectTargetSchema
|
|
6095
6294
|
};
|
|
6096
|
-
var EffectEventSchema =
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6295
|
+
var EffectEventSchema = z3.discriminatedUnion("event", [
|
|
6296
|
+
z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
|
|
6297
|
+
z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
|
|
6298
|
+
z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
|
|
6299
|
+
]);
|
|
6300
|
+
var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
|
|
6301
|
+
var customShared = {
|
|
6302
|
+
meta: HeaderMetaV3Schema,
|
|
6303
|
+
subject: SubjectSchema,
|
|
6304
|
+
kind: z3.literal("custom"),
|
|
6305
|
+
...envelopeTail
|
|
6306
|
+
};
|
|
6307
|
+
var CustomEventSchema = z3.discriminatedUnion("event", [
|
|
6308
|
+
z3.object({
|
|
6309
|
+
...customShared,
|
|
6310
|
+
event: z3.literal("recorded"),
|
|
6311
|
+
name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
|
|
6312
|
+
fields: z3.record(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH).regex(CUSTOM_FIELD_NAME_PATTERN), CustomFieldValueSchema).refine((f) => Object.keys(f).length <= CUSTOM_EVENT_MAX_FIELDS, {
|
|
6313
|
+
message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
|
|
6314
|
+
})
|
|
6315
|
+
}).strict()
|
|
6100
6316
|
]);
|
|
6101
|
-
var LogEventSchema =
|
|
6317
|
+
var LogEventSchema = z3.union([
|
|
6102
6318
|
DispatchEventSchema,
|
|
6103
6319
|
DevReviewLoopEventSchema,
|
|
6104
6320
|
ForgeWriteEventSchema,
|
|
@@ -6107,10 +6323,11 @@ var LogEventSchema = z2.union([
|
|
|
6107
6323
|
UsageEventSchema,
|
|
6108
6324
|
RoleAttemptEventSchema,
|
|
6109
6325
|
HandoffEventSchema,
|
|
6110
|
-
EffectEventSchema
|
|
6326
|
+
EffectEventSchema,
|
|
6327
|
+
CustomEventSchema
|
|
6111
6328
|
]);
|
|
6112
|
-
|
|
6113
6329
|
// ../../packages/aeg-core/src/log/envelope.ts
|
|
6330
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
6114
6331
|
function isRole(value) {
|
|
6115
6332
|
return value !== undefined && ROLE_VALUES.includes(value);
|
|
6116
6333
|
}
|
|
@@ -6147,18 +6364,27 @@ function roundFromEnv(round) {
|
|
|
6147
6364
|
const n = Number(round);
|
|
6148
6365
|
return Number.isInteger(n) ? n : undefined;
|
|
6149
6366
|
}
|
|
6367
|
+
function prFromEnv(pr) {
|
|
6368
|
+
if (pr === undefined || pr === "")
|
|
6369
|
+
return;
|
|
6370
|
+
const n = Number(pr);
|
|
6371
|
+
return Number.isInteger(n) && n > 0 ? n : undefined;
|
|
6372
|
+
}
|
|
6150
6373
|
function buildHeader(input) {
|
|
6151
6374
|
const role = isRole(input.env.role) ? input.env.role : "unattributed";
|
|
6152
6375
|
const round = roundFromEnv(input.env.round);
|
|
6376
|
+
const pr = prFromEnv(input.env.pr);
|
|
6153
6377
|
const subject = {
|
|
6154
6378
|
issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
|
|
6155
6379
|
role,
|
|
6156
6380
|
...round !== undefined ? { round } : {},
|
|
6381
|
+
...pr !== undefined ? { pr } : {},
|
|
6157
6382
|
...input.subject ?? {}
|
|
6158
6383
|
};
|
|
6384
|
+
const issue = subject.issue;
|
|
6159
6385
|
return {
|
|
6160
6386
|
meta: {
|
|
6161
|
-
schema:
|
|
6387
|
+
schema: 3,
|
|
6162
6388
|
ts: input.now.toISOString(),
|
|
6163
6389
|
run_id: input.runId,
|
|
6164
6390
|
seq: input.seq,
|
|
@@ -6181,7 +6407,19 @@ function buildHeader(input) {
|
|
|
6181
6407
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
6182
6408
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6183
6409
|
},
|
|
6184
|
-
provenance: provenanceFor(input)
|
|
6410
|
+
provenance: provenanceFor(input),
|
|
6411
|
+
work: {
|
|
6412
|
+
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6413
|
+
repo: input.repo,
|
|
6414
|
+
change: null,
|
|
6415
|
+
revision: null
|
|
6416
|
+
},
|
|
6417
|
+
flow: {
|
|
6418
|
+
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
6419
|
+
version: lineageFieldFromEnv(input.env.flowVersion)
|
|
6420
|
+
},
|
|
6421
|
+
runtime: lineageFieldFromEnv(input.env.runtime),
|
|
6422
|
+
source: lineageFieldFromEnv(input.env.source)
|
|
6185
6423
|
},
|
|
6186
6424
|
subject
|
|
6187
6425
|
};
|
|
@@ -6224,7 +6462,7 @@ function redact(value, home) {
|
|
|
6224
6462
|
return value;
|
|
6225
6463
|
}
|
|
6226
6464
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6227
|
-
var KNOWN_SCHEMA_VERSIONS = [1, 2];
|
|
6465
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
|
|
6228
6466
|
function metaOf(obj) {
|
|
6229
6467
|
if (obj === null || typeof obj !== "object")
|
|
6230
6468
|
return null;
|
|
@@ -6290,7 +6528,7 @@ function classifyStoredLine(raw, home) {
|
|
|
6290
6528
|
return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
|
|
6291
6529
|
}
|
|
6292
6530
|
const redacted = redact(event, home);
|
|
6293
|
-
const provenance = version
|
|
6531
|
+
const provenance = version >= 2 ? event.meta.provenance ?? null : null;
|
|
6294
6532
|
return {
|
|
6295
6533
|
status: "ok",
|
|
6296
6534
|
identity,
|
|
@@ -6303,143 +6541,148 @@ function classifyStoredLine(raw, home) {
|
|
|
6303
6541
|
};
|
|
6304
6542
|
}
|
|
6305
6543
|
// ../../packages/aeg-core/src/control-store/records.ts
|
|
6306
|
-
import { z as
|
|
6307
|
-
var isoTimestamp =
|
|
6308
|
-
var taskId =
|
|
6309
|
-
var epochNumber =
|
|
6310
|
-
var RunRecordSchema =
|
|
6311
|
-
version:
|
|
6312
|
-
kind:
|
|
6544
|
+
import { z as z4 } from "zod";
|
|
6545
|
+
var isoTimestamp = z4.string().min(1);
|
|
6546
|
+
var taskId = z4.number().int().positive();
|
|
6547
|
+
var epochNumber = z4.number().int().nonnegative();
|
|
6548
|
+
var RunRecordSchema = z4.object({
|
|
6549
|
+
version: z4.literal(1),
|
|
6550
|
+
kind: z4.literal("run"),
|
|
6313
6551
|
task: taskId,
|
|
6314
|
-
runId:
|
|
6315
|
-
pid:
|
|
6316
|
-
host:
|
|
6552
|
+
runId: z4.string().min(1),
|
|
6553
|
+
pid: z4.number().int().positive(),
|
|
6554
|
+
host: z4.string().min(1),
|
|
6317
6555
|
startedAt: isoTimestamp,
|
|
6318
|
-
childStartedAt:
|
|
6319
|
-
childCommand:
|
|
6556
|
+
childStartedAt: z4.string().min(1).nullable().optional(),
|
|
6557
|
+
childCommand: z4.string().min(1).nullable().optional()
|
|
6320
6558
|
}).strict();
|
|
6321
|
-
var InputRecordSchema =
|
|
6322
|
-
version:
|
|
6323
|
-
kind:
|
|
6559
|
+
var InputRecordSchema = z4.object({
|
|
6560
|
+
version: z4.literal(1),
|
|
6561
|
+
kind: z4.literal("input"),
|
|
6324
6562
|
task: taskId,
|
|
6325
|
-
runId:
|
|
6326
|
-
source:
|
|
6327
|
-
pr:
|
|
6328
|
-
round:
|
|
6563
|
+
runId: z4.string().min(1),
|
|
6564
|
+
source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
|
|
6565
|
+
pr: z4.number().int().positive().nullable(),
|
|
6566
|
+
round: z4.number().int().nonnegative(),
|
|
6329
6567
|
recordedAt: isoTimestamp
|
|
6330
6568
|
}).strict();
|
|
6331
|
-
var OwnershipRecordSchema =
|
|
6332
|
-
version:
|
|
6333
|
-
kind:
|
|
6569
|
+
var OwnershipRecordSchema = z4.object({
|
|
6570
|
+
version: z4.literal(1),
|
|
6571
|
+
kind: z4.literal("ownership"),
|
|
6334
6572
|
task: taskId,
|
|
6335
6573
|
epoch: epochNumber,
|
|
6336
|
-
ownerId:
|
|
6337
|
-
pid:
|
|
6338
|
-
host:
|
|
6574
|
+
ownerId: z4.string().min(1),
|
|
6575
|
+
pid: z4.number().int().positive(),
|
|
6576
|
+
host: z4.string().min(1),
|
|
6339
6577
|
acquiredAt: isoTimestamp
|
|
6340
6578
|
}).strict();
|
|
6341
|
-
var TransitionRecordSchema =
|
|
6342
|
-
version:
|
|
6343
|
-
kind:
|
|
6579
|
+
var TransitionRecordSchema = z4.object({
|
|
6580
|
+
version: z4.literal(1),
|
|
6581
|
+
kind: z4.literal("transition"),
|
|
6344
6582
|
task: taskId,
|
|
6345
6583
|
epoch: epochNumber,
|
|
6346
|
-
seq:
|
|
6347
|
-
from:
|
|
6348
|
-
to:
|
|
6349
|
-
detail:
|
|
6584
|
+
seq: z4.number().int().nonnegative(),
|
|
6585
|
+
from: z4.string().min(1),
|
|
6586
|
+
to: z4.string().min(1),
|
|
6587
|
+
detail: z4.string().optional(),
|
|
6350
6588
|
at: isoTimestamp
|
|
6351
6589
|
}).strict();
|
|
6352
|
-
var ManifestRecordSchema =
|
|
6353
|
-
version:
|
|
6354
|
-
kind:
|
|
6590
|
+
var ManifestRecordSchema = z4.object({
|
|
6591
|
+
version: z4.literal(1),
|
|
6592
|
+
kind: z4.literal("manifest"),
|
|
6355
6593
|
task: taskId,
|
|
6356
6594
|
round: epochNumber,
|
|
6357
|
-
repository:
|
|
6358
|
-
pr:
|
|
6359
|
-
branch:
|
|
6360
|
-
baseSha:
|
|
6361
|
-
headSha:
|
|
6362
|
-
briefHash:
|
|
6363
|
-
objectivesVersion:
|
|
6595
|
+
repository: z4.string().min(1),
|
|
6596
|
+
pr: z4.number().int().positive(),
|
|
6597
|
+
branch: z4.string().min(1),
|
|
6598
|
+
baseSha: z4.string().min(1).nullable(),
|
|
6599
|
+
headSha: z4.string().min(1),
|
|
6600
|
+
briefHash: z4.string().min(1).nullable(),
|
|
6601
|
+
objectivesVersion: z4.string().min(1).nullable(),
|
|
6364
6602
|
rulingOrdinal: epochNumber,
|
|
6365
|
-
policyDigest:
|
|
6603
|
+
policyDigest: z4.string().min(1),
|
|
6366
6604
|
recordedAt: isoTimestamp
|
|
6367
6605
|
}).strict();
|
|
6368
|
-
var roundHeadIdentity =
|
|
6369
|
-
var LoopBudgetsSchema =
|
|
6370
|
-
mechanicalRetries:
|
|
6371
|
-
reviewRounds:
|
|
6372
|
-
infrastructureRetries:
|
|
6606
|
+
var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
|
|
6607
|
+
var LoopBudgetsSchema = z4.object({
|
|
6608
|
+
mechanicalRetries: z4.number().int().nonnegative(),
|
|
6609
|
+
reviewRounds: z4.number().int().nonnegative(),
|
|
6610
|
+
infrastructureRetries: z4.number().int().nonnegative()
|
|
6373
6611
|
}).strict();
|
|
6374
|
-
var LoopStateRecordSchema =
|
|
6375
|
-
version:
|
|
6376
|
-
kind:
|
|
6612
|
+
var LoopStateRecordSchema = z4.object({
|
|
6613
|
+
version: z4.literal(1),
|
|
6614
|
+
kind: z4.literal("loop_state"),
|
|
6377
6615
|
task: taskId,
|
|
6378
|
-
round:
|
|
6379
|
-
phase:
|
|
6380
|
-
pauseReason:
|
|
6616
|
+
round: z4.number().int().positive(),
|
|
6617
|
+
phase: z4.string().min(1),
|
|
6618
|
+
pauseReason: z4.string().min(1).nullable(),
|
|
6381
6619
|
budgets: LoopBudgetsSchema,
|
|
6382
6620
|
heldResult: roundHeadIdentity.nullable(),
|
|
6383
6621
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6384
|
-
repeatMemory:
|
|
6385
|
-
blockingFindings:
|
|
6386
|
-
lastFailure:
|
|
6622
|
+
repeatMemory: z4.object({
|
|
6623
|
+
blockingFindings: z4.array(z4.string()),
|
|
6624
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
6387
6625
|
}).strict().optional(),
|
|
6626
|
+
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6627
|
+
taskStartedAt: isoTimestamp.optional(),
|
|
6628
|
+
phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
|
|
6388
6629
|
recordedAt: isoTimestamp
|
|
6389
6630
|
}).strict();
|
|
6390
|
-
var EffectRecordSchema =
|
|
6391
|
-
version:
|
|
6392
|
-
kind:
|
|
6631
|
+
var EffectRecordSchema = z4.object({
|
|
6632
|
+
version: z4.literal(1),
|
|
6633
|
+
kind: z4.literal("effect"),
|
|
6393
6634
|
task: taskId,
|
|
6394
|
-
key:
|
|
6395
|
-
operation:
|
|
6396
|
-
target:
|
|
6397
|
-
inputVersion:
|
|
6398
|
-
payloadDigest:
|
|
6399
|
-
status:
|
|
6400
|
-
url:
|
|
6635
|
+
key: z4.string().min(1),
|
|
6636
|
+
operation: z4.string().min(1),
|
|
6637
|
+
target: z4.string().min(1),
|
|
6638
|
+
inputVersion: z4.number().int().nonnegative(),
|
|
6639
|
+
payloadDigest: z4.string().min(1),
|
|
6640
|
+
status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
|
|
6641
|
+
url: z4.string().optional(),
|
|
6401
6642
|
recordedAt: isoTimestamp
|
|
6402
6643
|
}).strict();
|
|
6403
|
-
var EscalationRecordSchema =
|
|
6404
|
-
version:
|
|
6405
|
-
kind:
|
|
6644
|
+
var EscalationRecordSchema = z4.object({
|
|
6645
|
+
version: z4.literal(1),
|
|
6646
|
+
kind: z4.literal("escalation"),
|
|
6406
6647
|
task: taskId,
|
|
6407
|
-
escalationId:
|
|
6648
|
+
escalationId: z4.string().min(1),
|
|
6408
6649
|
round: epochNumber,
|
|
6409
|
-
head:
|
|
6410
|
-
branch:
|
|
6411
|
-
pr:
|
|
6412
|
-
runId:
|
|
6413
|
-
pid:
|
|
6414
|
-
host:
|
|
6415
|
-
agent:
|
|
6416
|
-
reason:
|
|
6417
|
-
detail:
|
|
6418
|
-
evidence:
|
|
6419
|
-
attemptedRecovery:
|
|
6420
|
-
requestedDecision:
|
|
6421
|
-
recipient:
|
|
6422
|
-
briefHash:
|
|
6423
|
-
objectivesVersion:
|
|
6650
|
+
head: z4.string().min(1),
|
|
6651
|
+
branch: z4.string().min(1),
|
|
6652
|
+
pr: z4.number().int().positive().nullable(),
|
|
6653
|
+
runId: z4.string().min(1),
|
|
6654
|
+
pid: z4.number().int().positive(),
|
|
6655
|
+
host: z4.string().min(1),
|
|
6656
|
+
agent: z4.string().min(1).optional(),
|
|
6657
|
+
reason: z4.string().min(1),
|
|
6658
|
+
detail: z4.string().optional(),
|
|
6659
|
+
evidence: z4.string().optional(),
|
|
6660
|
+
attemptedRecovery: z4.string().min(1),
|
|
6661
|
+
requestedDecision: z4.string().min(1),
|
|
6662
|
+
recipient: z4.string().min(1),
|
|
6663
|
+
briefHash: z4.string().min(1).nullable(),
|
|
6664
|
+
objectivesVersion: z4.string().min(1).nullable(),
|
|
6424
6665
|
rulingOrdinal: epochNumber,
|
|
6425
|
-
policyDigest:
|
|
6666
|
+
policyDigest: z4.string().min(1),
|
|
6426
6667
|
recordedAt: isoTimestamp
|
|
6427
6668
|
}).strict();
|
|
6428
|
-
var ResolutionRecordSchema =
|
|
6429
|
-
version:
|
|
6430
|
-
kind:
|
|
6669
|
+
var ResolutionRecordSchema = z4.object({
|
|
6670
|
+
version: z4.literal(1),
|
|
6671
|
+
kind: z4.literal("resolution"),
|
|
6431
6672
|
task: taskId,
|
|
6432
|
-
escalationId:
|
|
6433
|
-
decision:
|
|
6434
|
-
authenticatedBy:
|
|
6435
|
-
authenticatedFrom:
|
|
6673
|
+
escalationId: z4.string().min(1),
|
|
6674
|
+
decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
|
|
6675
|
+
authenticatedBy: z4.string().min(1),
|
|
6676
|
+
authenticatedFrom: z4.string().min(1),
|
|
6436
6677
|
consumedAt: isoTimestamp
|
|
6437
6678
|
}).strict();
|
|
6679
|
+
// ../../packages/aeg-core/src/control-store/local.ts
|
|
6680
|
+
var CONTROL_AREA_DIRNAME = "control";
|
|
6438
6681
|
// src/commands/doctrine.ts
|
|
6439
|
-
import { execFileSync as
|
|
6440
|
-
import { existsSync as
|
|
6441
|
-
import { dirname as
|
|
6442
|
-
import
|
|
6682
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
6683
|
+
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
6684
|
+
import { dirname as dirname3, join as join3, sep } from "node:path";
|
|
6685
|
+
import matter4 from "gray-matter";
|
|
6443
6686
|
|
|
6444
6687
|
// src/lib/package-root.ts
|
|
6445
6688
|
import { existsSync } from "node:fs";
|
|
@@ -6458,607 +6701,10 @@ function packageRoot(moduleUrl) {
|
|
|
6458
6701
|
return dir;
|
|
6459
6702
|
}
|
|
6460
6703
|
|
|
6461
|
-
// src/
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
}
|
|
6466
|
-
function gitToplevel(cwd) {
|
|
6467
|
-
try {
|
|
6468
|
-
return execFileSync2("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
6469
|
-
encoding: "utf8",
|
|
6470
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6471
|
-
}).trim();
|
|
6472
|
-
} catch {
|
|
6473
|
-
return null;
|
|
6474
|
-
}
|
|
6475
|
-
}
|
|
6476
|
-
function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
6477
|
-
const toplevel = gitToplevel(cwd);
|
|
6478
|
-
if (toplevel !== null) {
|
|
6479
|
-
const treeRoot = join2(toplevel, "aeg-root");
|
|
6480
|
-
if (existsSync2(join2(treeRoot, "roles")))
|
|
6481
|
-
return { root: treeRoot, source: "tree" };
|
|
6482
|
-
}
|
|
6483
|
-
const fromSource = !pkg.split(sep).includes("node_modules");
|
|
6484
|
-
const bundleRoot = fromSource ? join2(dirname2(dirname2(pkg)), "aeg-root") : join2(pkg, "aeg-root");
|
|
6485
|
-
return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
|
|
6486
|
-
}
|
|
6487
|
-
function hasDoctrineEntry(root) {
|
|
6488
|
-
return existsSync2(join2(root, ...ENTRY_SEGMENTS));
|
|
6489
|
-
}
|
|
6490
|
-
|
|
6491
|
-
// src/lib/config.ts
|
|
6492
|
-
import { execFile as execFile4, execFileSync as execFileSync4 } from "node:child_process";
|
|
6493
|
-
import { promisify as promisify4 } from "node:util";
|
|
6494
|
-
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
|
|
6495
|
-
import { homedir } from "node:os";
|
|
6496
|
-
import { dirname as dirname3, isAbsolute, join as join3, resolve } from "node:path";
|
|
6497
|
-
import { z as z4 } from "zod";
|
|
6498
|
-
|
|
6499
|
-
// src/lib/agent-vendors.ts
|
|
6500
|
-
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6501
|
-
|
|
6502
|
-
// src/lib/worker-boundary.ts
|
|
6503
|
-
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
6504
|
-
var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
|
|
6505
|
-
var logHeaderKeychainCache = new Map;
|
|
6506
|
-
function readRealLogHeaderKeychainCredential(variable) {
|
|
6507
|
-
if (process.platform !== "darwin")
|
|
6508
|
-
return null;
|
|
6509
|
-
try {
|
|
6510
|
-
return execFileSync3("/usr/bin/security", ["find-generic-password", "-s", LOG_HEADER_KEYCHAIN_SERVICE, "-a", variable, "-w"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5000, maxBuffer: 1024 * 1024 }).replace(/\n$/, "");
|
|
6511
|
-
} catch {
|
|
6512
|
-
return null;
|
|
6513
|
-
}
|
|
6514
|
-
}
|
|
6515
|
-
function readLogHeaderKeychainCredential(variable) {
|
|
6516
|
-
const cached = logHeaderKeychainCache.get(variable);
|
|
6517
|
-
if (cached !== undefined)
|
|
6518
|
-
return cached;
|
|
6519
|
-
const value = readRealLogHeaderKeychainCredential(variable);
|
|
6520
|
-
logHeaderKeychainCache.set(variable, value);
|
|
6521
|
-
return value;
|
|
6522
|
-
}
|
|
6523
|
-
|
|
6524
|
-
// src/lib/config.ts
|
|
6525
|
-
var EnvEntrySchema = z4.union([
|
|
6526
|
-
z4.literal(true),
|
|
6527
|
-
z4.object({ optional: z4.literal(true) }),
|
|
6528
|
-
z4.object({ anyOf: z4.array(z4.string()).min(2) }),
|
|
6529
|
-
z4.string()
|
|
6530
|
-
]);
|
|
6531
|
-
var CheckEntrySchema = z4.object({
|
|
6532
|
-
run: z4.string(),
|
|
6533
|
-
scope: z4.enum(["diff", "full"]),
|
|
6534
|
-
include: z4.array(z4.string()).optional(),
|
|
6535
|
-
args: z4.array(z4.string()).optional(),
|
|
6536
|
-
timeoutMs: z4.number().optional(),
|
|
6537
|
-
env: z4.record(z4.string(), EnvEntrySchema).optional(),
|
|
6538
|
-
requiresOpenPr: z4.boolean().optional(),
|
|
6539
|
-
ownWorkflow: z4.boolean().optional(),
|
|
6540
|
-
principalOwed: z4.literal(true).optional(),
|
|
6541
|
-
validates: z4.enum(["body", "issue"]).optional()
|
|
6542
|
-
}).superRefine((entry, ctx) => {
|
|
6543
|
-
if (!entry.env)
|
|
6544
|
-
return;
|
|
6545
|
-
for (const [key, value] of Object.entries(entry.env)) {
|
|
6546
|
-
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
6547
|
-
continue;
|
|
6548
|
-
const members = value.anyOf;
|
|
6549
|
-
if (new Set(members).size !== members.length) {
|
|
6550
|
-
ctx.addIssue({
|
|
6551
|
-
code: z4.ZodIssueCode.custom,
|
|
6552
|
-
message: `env.${key}.anyOf has duplicate members`,
|
|
6553
|
-
path: ["env", key, "anyOf"]
|
|
6554
|
-
});
|
|
6555
|
-
}
|
|
6556
|
-
if (!members.includes(key)) {
|
|
6557
|
-
ctx.addIssue({
|
|
6558
|
-
code: z4.ZodIssueCode.custom,
|
|
6559
|
-
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
6560
|
-
path: ["env", key, "anyOf"]
|
|
6561
|
-
});
|
|
6562
|
-
}
|
|
6563
|
-
}
|
|
6564
|
-
});
|
|
6565
|
-
var RoleEntrySchema = z4.object({
|
|
6566
|
-
contract: z4.string().refine((p) => p.includes("/"), {
|
|
6567
|
-
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
6568
|
-
})
|
|
6569
|
-
});
|
|
6570
|
-
var MAX_REPORT_COMMAND_TIMEOUT_MS = 3600000;
|
|
6571
|
-
var BRIEF_BUILTINS = [
|
|
6572
|
-
"tier",
|
|
6573
|
-
"testPlan",
|
|
6574
|
-
"testPlanExclusivity",
|
|
6575
|
-
"principalPlaceholder",
|
|
6576
|
-
"surfaceMap",
|
|
6577
|
-
"docUpdateList",
|
|
6578
|
-
"worktreeStep0",
|
|
6579
|
-
"stopConditions",
|
|
6580
|
-
"autonomyClause",
|
|
6581
|
-
"project",
|
|
6582
|
-
"for",
|
|
6583
|
-
"closesN",
|
|
6584
|
-
"premiseCoverage",
|
|
6585
|
-
"issueRationale",
|
|
6586
|
-
"objectives",
|
|
6587
|
-
"briefSections",
|
|
6588
|
-
"milestoneShape"
|
|
6589
|
-
];
|
|
6590
|
-
var BriefSectionSchema = z4.union([
|
|
6591
|
-
z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
|
|
6592
|
-
z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
|
|
6593
|
-
z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
|
|
6594
|
-
z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
|
|
6595
|
-
]);
|
|
6596
|
-
var BriefSchemaSchema = z4.object({
|
|
6597
|
-
pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
|
|
6598
|
-
issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
|
|
6599
|
-
milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
|
|
6600
|
-
ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
|
|
6601
|
-
});
|
|
6602
|
-
function isSafeRepoRelPath(p) {
|
|
6603
|
-
if (p.length === 0)
|
|
6604
|
-
return false;
|
|
6605
|
-
if (p.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(p))
|
|
6606
|
-
return false;
|
|
6607
|
-
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
6608
|
-
}
|
|
6609
|
-
var SafeRepoRelPath = z4.string().refine(isSafeRepoRelPath, {
|
|
6610
|
-
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
6611
|
-
});
|
|
6612
|
-
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
6613
|
-
function isCanonicalHookBlockPath(p) {
|
|
6614
|
-
return CANONICAL_HOOK_BLOCK_PREFIXES.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
|
|
6615
|
-
}
|
|
6616
|
-
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
6617
|
-
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
6618
|
-
});
|
|
6619
|
-
var ManagedBlockRecordSchema = z4.object({
|
|
6620
|
-
path: ManagedHookBlockPath,
|
|
6621
|
-
marker: z4.string(),
|
|
6622
|
-
comment: z4.enum(["hash", "html"])
|
|
6623
|
-
});
|
|
6624
|
-
var ManagedManifestSchema = z4.object({
|
|
6625
|
-
version: z4.number().int().positive(),
|
|
6626
|
-
files: z4.array(SafeRepoRelPath),
|
|
6627
|
-
blocks: z4.array(ManagedBlockRecordSchema),
|
|
6628
|
-
labels: z4.array(z4.string()),
|
|
6629
|
-
agents: z4.array(z4.enum(AGENT_VENDORS)).optional()
|
|
6630
|
-
});
|
|
6631
|
-
var ProjectEntrySchema = z4.object({
|
|
6632
|
-
name: z4.string().min(1),
|
|
6633
|
-
description: z4.string().min(1).optional(),
|
|
6634
|
-
path: z4.string().min(1).optional()
|
|
6635
|
-
});
|
|
6636
|
-
function parseTokensCollectDeclaration(value) {
|
|
6637
|
-
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
6638
|
-
if (!m)
|
|
6639
|
-
return null;
|
|
6640
|
-
const [, interpreter, script] = m;
|
|
6641
|
-
if (!isSafeRepoRelPath(script))
|
|
6642
|
-
return null;
|
|
6643
|
-
return { interpreter, script };
|
|
6644
|
-
}
|
|
6645
|
-
var VinayaConfigSchema = z4.object({
|
|
6646
|
-
rings: z4.object({
|
|
6647
|
-
ring1_forgeWriteInterception: z4.boolean(),
|
|
6648
|
-
ring2_asyncAudits: z4.boolean()
|
|
6649
|
-
}).optional(),
|
|
6650
|
-
checks: z4.record(z4.string(), CheckEntrySchema).optional(),
|
|
6651
|
-
roles: z4.record(z4.string(), RoleEntrySchema).optional(),
|
|
6652
|
-
briefSchema: BriefSchemaSchema.optional(),
|
|
6653
|
-
managed: ManagedManifestSchema.optional(),
|
|
6654
|
-
principals: z4.array(z4.string()).min(1).optional(),
|
|
6655
|
-
releaseActor: z4.string().min(1).optional(),
|
|
6656
|
-
ci: z4.object({ setup: z4.string().min(1) }).optional(),
|
|
6657
|
-
tokens: z4.object({
|
|
6658
|
-
collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
6659
|
-
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
6660
|
-
})
|
|
6661
|
-
}).optional(),
|
|
6662
|
-
blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
|
|
6663
|
-
proseGates: z4.object({
|
|
6664
|
-
doctrineRoot: z4.string().min(1).optional(),
|
|
6665
|
-
readerFacingPrefix: z4.string().min(1).optional(),
|
|
6666
|
-
readerFacingSuffix: z4.string().min(1).optional(),
|
|
6667
|
-
legacySlugDir: z4.string().min(1).optional(),
|
|
6668
|
-
sourceComments: z4.object({
|
|
6669
|
-
globs: z4.array(z4.string().min(1)).optional(),
|
|
6670
|
-
allowlist: z4.array(z4.string().min(1)).optional(),
|
|
6671
|
-
severity: z4.enum(["warning", "error"]).optional()
|
|
6672
|
-
}).optional(),
|
|
6673
|
-
specGrandfather: z4.array(z4.string().min(1)).optional(),
|
|
6674
|
-
specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
|
|
6675
|
-
message: "must be a repository-relative path, not an absolute one"
|
|
6676
|
-
}).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
|
|
6677
|
-
message: "must stay inside the repository — no `..` segment"
|
|
6678
|
-
})).optional()
|
|
6679
|
-
}).optional(),
|
|
6680
|
-
projects: z4.array(ProjectEntrySchema).optional(),
|
|
6681
|
-
dispatch: z4.object({
|
|
6682
|
-
timeoutMs: z4.number().int().positive().optional(),
|
|
6683
|
-
killGraceMs: z4.number().int().positive().optional(),
|
|
6684
|
-
agent: z4.enum(["claude", "codex", "gemini"]).optional(),
|
|
6685
|
-
requireWorkerIsolation: z4.boolean().optional()
|
|
6686
|
-
}).optional(),
|
|
6687
|
-
reviewPolicy: z4.object({
|
|
6688
|
-
codeReviewThreshold: z4.string().min(1).optional(),
|
|
6689
|
-
securityThreshold: z4.string().min(1).optional(),
|
|
6690
|
-
maxRounds: z4.number().optional()
|
|
6691
|
-
}).optional(),
|
|
6692
|
-
gateCutovers: z4.object({
|
|
6693
|
-
objectivesSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6694
|
-
briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6695
|
-
documentationSinceIssue: z4.number().int().nonnegative().optional(),
|
|
6696
|
-
briefRulesSincePr: z4.number().int().nonnegative().optional(),
|
|
6697
|
-
agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
|
|
6698
|
-
}).optional(),
|
|
6699
|
-
planning: z4.object({
|
|
6700
|
-
collisionThreshold: z4.number().int().nonnegative().optional()
|
|
6701
|
-
}).optional(),
|
|
6702
|
-
prePush: z4.object({
|
|
6703
|
-
alwaysRun: z4.array(z4.string()).optional()
|
|
6704
|
-
}).optional(),
|
|
6705
|
-
report: z4.object({
|
|
6706
|
-
commandTimeoutMs: z4.number().int().positive().optional()
|
|
6707
|
-
}).superRefine((report, ctx) => {
|
|
6708
|
-
const commandTimeoutMs = report.commandTimeoutMs;
|
|
6709
|
-
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
6710
|
-
ctx.addIssue({
|
|
6711
|
-
code: z4.ZodIssueCode.custom,
|
|
6712
|
-
path: ["commandTimeoutMs"],
|
|
6713
|
-
message: "must be at most 3600000 (1 hour)"
|
|
6714
|
-
});
|
|
6715
|
-
}
|
|
6716
|
-
}).optional(),
|
|
6717
|
-
logPublish: z4.unknown().refine((v) => v === undefined, {
|
|
6718
|
-
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
6719
|
-
}),
|
|
6720
|
-
runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
6721
|
-
logs: z4.object({
|
|
6722
|
-
folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
6723
|
-
url: z4.string().url().optional(),
|
|
6724
|
-
headers: z4.record(z4.string()).optional()
|
|
6725
|
-
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
6726
|
-
message: "logs: set at most one of folder/url"
|
|
6727
|
-
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
6728
|
-
message: "logs: headers requires url"
|
|
6729
|
-
}).optional()
|
|
6730
|
-
});
|
|
6731
|
-
var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
|
|
6732
|
-
var GLOBAL_CONFIG_PATH = join3(GLOBAL_VINAYA_HOME, "config.json");
|
|
6733
|
-
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
6734
|
-
function findLocalConfig() {
|
|
6735
|
-
let dir = process.cwd();
|
|
6736
|
-
while (true) {
|
|
6737
|
-
const candidate = join3(dir, LOCAL_CONFIG_FILENAME);
|
|
6738
|
-
if (existsSync3(candidate))
|
|
6739
|
-
return candidate;
|
|
6740
|
-
if (existsSync3(join3(dir, ".git")))
|
|
6741
|
-
return null;
|
|
6742
|
-
const parent = dirname3(dir);
|
|
6743
|
-
if (parent === dir)
|
|
6744
|
-
return null;
|
|
6745
|
-
dir = parent;
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
function configPath() {
|
|
6749
|
-
const local = findLocalConfig();
|
|
6750
|
-
if (local)
|
|
6751
|
-
return local;
|
|
6752
|
-
if (existsSync3(GLOBAL_CONFIG_PATH))
|
|
6753
|
-
return GLOBAL_CONFIG_PATH;
|
|
6754
|
-
return null;
|
|
6755
|
-
}
|
|
6756
|
-
function globalChecksIgnoredWarning(path) {
|
|
6757
|
-
return `${path}: "checks" registration in the global config is ignored — checks may only be registered from a repo-local vinaya.config.json.`;
|
|
6758
|
-
}
|
|
6759
|
-
function globalPrincipalsIgnoredWarning(path) {
|
|
6760
|
-
return `${path}: "principals" in the global config is ignored — principals may only be declared from a repo-local vinaya.config.json.`;
|
|
6761
|
-
}
|
|
6762
|
-
function globalRolesIgnoredWarning(path) {
|
|
6763
|
-
return `${path}: "roles" registration in the global config is ignored — roles may only be registered from a repo-local vinaya.config.json.`;
|
|
6764
|
-
}
|
|
6765
|
-
function globalReleaseActorIgnoredWarning(path) {
|
|
6766
|
-
return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
|
|
6767
|
-
}
|
|
6768
|
-
function globalTokensCollectIgnoredWarning(path) {
|
|
6769
|
-
return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
|
|
6770
|
-
}
|
|
6771
|
-
function globalRuntimeDirIgnoredWarning(path) {
|
|
6772
|
-
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.`;
|
|
6773
|
-
}
|
|
6774
|
-
var emittedGlobalKeyWarnings = new Set;
|
|
6775
|
-
function warnGlobalKeyIgnoredOnce(message) {
|
|
6776
|
-
if (emittedGlobalKeyWarnings.has(message))
|
|
6777
|
-
return;
|
|
6778
|
-
emittedGlobalKeyWarnings.add(message);
|
|
6779
|
-
console.error(`⚠ ${message}`);
|
|
6780
|
-
}
|
|
6781
|
-
function stripGlobalOnlyKeys(config, path) {
|
|
6782
|
-
if (path !== GLOBAL_CONFIG_PATH)
|
|
6783
|
-
return config;
|
|
6784
|
-
let result = config;
|
|
6785
|
-
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
6786
|
-
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
6787
|
-
result = { ...result, checks: undefined };
|
|
6788
|
-
}
|
|
6789
|
-
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
6790
|
-
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
6791
|
-
result = { ...result, roles: undefined };
|
|
6792
|
-
}
|
|
6793
|
-
if (result.principals && result.principals.length > 0) {
|
|
6794
|
-
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
6795
|
-
result = { ...result, principals: undefined };
|
|
6796
|
-
}
|
|
6797
|
-
if (result.releaseActor) {
|
|
6798
|
-
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
6799
|
-
result = { ...result, releaseActor: undefined };
|
|
6800
|
-
}
|
|
6801
|
-
if (result.tokens) {
|
|
6802
|
-
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
6803
|
-
result = { ...result, tokens: undefined };
|
|
6804
|
-
}
|
|
6805
|
-
if (result.runtimeDir) {
|
|
6806
|
-
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
6807
|
-
result = { ...result, runtimeDir: undefined };
|
|
6808
|
-
}
|
|
6809
|
-
return result;
|
|
6810
|
-
}
|
|
6811
|
-
function resolvePrincipalAllowlist(config) {
|
|
6812
|
-
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
6813
|
-
}
|
|
6814
|
-
function resolveReleaseActor(config) {
|
|
6815
|
-
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
6816
|
-
}
|
|
6817
|
-
function resolveReviewPolicy(config) {
|
|
6818
|
-
const raw = config?.reviewPolicy;
|
|
6819
|
-
if (!raw)
|
|
6820
|
-
return DEFAULT_REVIEW_POLICY;
|
|
6821
|
-
const codeReviewThreshold = raw.codeReviewThreshold ?? DEFAULT_REVIEW_POLICY.codeReviewThreshold;
|
|
6822
|
-
if (!isKnownSeverity(CODE_REVIEW_SEVERITY_ORDER, codeReviewThreshold)) {
|
|
6823
|
-
throw new Error(`vinaya.config.json: reviewPolicy.codeReviewThreshold "${codeReviewThreshold}" is not one of ${CODE_REVIEW_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
|
|
6824
|
-
}
|
|
6825
|
-
const securityThreshold = raw.securityThreshold ?? DEFAULT_REVIEW_POLICY.securityThreshold;
|
|
6826
|
-
if (!isKnownSeverity(SECURITY_SEVERITY_ORDER, securityThreshold)) {
|
|
6827
|
-
throw new Error(`vinaya.config.json: reviewPolicy.securityThreshold "${securityThreshold}" is not one of ${SECURITY_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
|
|
6828
|
-
}
|
|
6829
|
-
const maxRounds = raw.maxRounds ?? DEFAULT_REVIEW_POLICY.maxRounds;
|
|
6830
|
-
if (!Number.isInteger(maxRounds) || maxRounds < 1) {
|
|
6831
|
-
throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
|
|
6832
|
-
}
|
|
6833
|
-
return {
|
|
6834
|
-
codeReviewThreshold,
|
|
6835
|
-
securityThreshold,
|
|
6836
|
-
maxRounds
|
|
6837
|
-
};
|
|
6838
|
-
}
|
|
6839
|
-
function resolveGateCutovers(config) {
|
|
6840
|
-
const raw = config?.gateCutovers;
|
|
6841
|
-
if (!raw)
|
|
6842
|
-
return NO_GATE_CUTOVERS;
|
|
6843
|
-
return {
|
|
6844
|
-
objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
|
|
6845
|
-
briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
|
|
6846
|
-
documentationSinceIssue: raw.documentationSinceIssue ?? null,
|
|
6847
|
-
briefRulesSincePr: raw.briefRulesSincePr ?? null,
|
|
6848
|
-
agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
|
|
6849
|
-
};
|
|
6850
|
-
}
|
|
6851
|
-
function resolveRuntimeDirSetting(config) {
|
|
6852
|
-
return config?.runtimeDir ?? null;
|
|
6853
|
-
}
|
|
6854
|
-
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
6855
|
-
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
6856
|
-
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
6857
|
-
}
|
|
6858
|
-
function resolveLogsSetting(config) {
|
|
6859
|
-
const raw = config?.logs;
|
|
6860
|
-
if (!raw)
|
|
6861
|
-
return null;
|
|
6862
|
-
if (raw.url !== undefined)
|
|
6863
|
-
return { url: raw.url, headers: raw.headers };
|
|
6864
|
-
if (raw.folder !== undefined)
|
|
6865
|
-
return { folder: raw.folder };
|
|
6866
|
-
return null;
|
|
6867
|
-
}
|
|
6868
|
-
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
6869
|
-
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
6870
|
-
if (!anchored)
|
|
6871
|
-
return null;
|
|
6872
|
-
if ("url" in local)
|
|
6873
|
-
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
6874
|
-
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
6875
|
-
}
|
|
6876
|
-
function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
|
|
6877
|
-
if (!headers)
|
|
6878
|
-
return;
|
|
6879
|
-
const resolved = {};
|
|
6880
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
6881
|
-
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
|
|
6882
|
-
const fromEnv = env[name];
|
|
6883
|
-
if (fromEnv !== undefined)
|
|
6884
|
-
return fromEnv;
|
|
6885
|
-
return readKeychain(name) ?? "";
|
|
6886
|
-
});
|
|
6887
|
-
}
|
|
6888
|
-
return resolved;
|
|
6889
|
-
}
|
|
6890
|
-
function trustAnchorRepo() {
|
|
6891
|
-
const fromRunner = trustAnchorRepoFromRunner();
|
|
6892
|
-
if (fromRunner)
|
|
6893
|
-
return fromRunner;
|
|
6894
|
-
try {
|
|
6895
|
-
const url = execFileSync4("git", ["remote", "get-url", "origin"], {
|
|
6896
|
-
encoding: "utf-8",
|
|
6897
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6898
|
-
});
|
|
6899
|
-
return trustAnchorRepoFromRemoteUrl(url);
|
|
6900
|
-
} catch {
|
|
6901
|
-
return null;
|
|
6902
|
-
}
|
|
6903
|
-
}
|
|
6904
|
-
async function trustAnchorRepoAsync() {
|
|
6905
|
-
const fromRunner = trustAnchorRepoFromRunner();
|
|
6906
|
-
if (fromRunner)
|
|
6907
|
-
return fromRunner;
|
|
6908
|
-
try {
|
|
6909
|
-
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
6910
|
-
encoding: "utf-8",
|
|
6911
|
-
timeout: 1e4,
|
|
6912
|
-
killSignal: "SIGKILL"
|
|
6913
|
-
});
|
|
6914
|
-
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
6915
|
-
} catch {
|
|
6916
|
-
return null;
|
|
6917
|
-
}
|
|
6918
|
-
}
|
|
6919
|
-
function wellFormedRepoSlug(slug) {
|
|
6920
|
-
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
6921
|
-
}
|
|
6922
|
-
function trustAnchorRepoFromRunner() {
|
|
6923
|
-
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
6924
|
-
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
6925
|
-
}
|
|
6926
|
-
function trustAnchorRepoFromRemoteUrl(url) {
|
|
6927
|
-
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
6928
|
-
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
6929
|
-
}
|
|
6930
|
-
var execFileAsync4 = promisify4(execFile4);
|
|
6931
|
-
function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
6932
|
-
const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
|
|
6933
|
-
if (!ref)
|
|
6934
|
-
return null;
|
|
6935
|
-
if (env.GITHUB_ACTIONS !== "true")
|
|
6936
|
-
return null;
|
|
6937
|
-
if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
|
|
6938
|
-
return null;
|
|
6939
|
-
return ref;
|
|
6940
|
-
}
|
|
6941
|
-
function readTrustAnchorConfigAtRef(ref) {
|
|
6942
|
-
const raw = execFileSync4("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6943
|
-
encoding: "utf-8",
|
|
6944
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
6945
|
-
timeout: 1e4
|
|
6946
|
-
});
|
|
6947
|
-
return Buffer.from(raw, "utf-8").toString("base64");
|
|
6948
|
-
}
|
|
6949
|
-
function ghFetchTrustAnchorConfig() {
|
|
6950
|
-
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6951
|
-
if (probeRef)
|
|
6952
|
-
return readTrustAnchorConfigAtRef(probeRef);
|
|
6953
|
-
const repo = trustAnchorRepo();
|
|
6954
|
-
if (!repo)
|
|
6955
|
-
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6956
|
-
return execFileSync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
6957
|
-
encoding: "utf-8",
|
|
6958
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6959
|
-
});
|
|
6960
|
-
}
|
|
6961
|
-
async function ghFetchTrustAnchorConfigAsync() {
|
|
6962
|
-
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
6963
|
-
if (probeRef) {
|
|
6964
|
-
const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6965
|
-
encoding: "utf-8",
|
|
6966
|
-
timeout: 1e4
|
|
6967
|
-
});
|
|
6968
|
-
return Buffer.from(stdout, "utf-8").toString("base64");
|
|
6969
|
-
}
|
|
6970
|
-
const repo = await trustAnchorRepoAsync();
|
|
6971
|
-
if (!repo)
|
|
6972
|
-
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6973
|
-
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
6974
|
-
return stdout;
|
|
6975
|
-
}
|
|
6976
|
-
function firstLine(err) {
|
|
6977
|
-
return err?.message?.split(`
|
|
6978
|
-
`)[0] ?? "unknown error";
|
|
6979
|
-
}
|
|
6980
|
-
function isMissingFileError(err) {
|
|
6981
|
-
const stderr = err?.stderr;
|
|
6982
|
-
const haystack = [
|
|
6983
|
-
err?.message ?? "",
|
|
6984
|
-
typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
|
|
6985
|
-
].join(`
|
|
6986
|
-
`);
|
|
6987
|
-
return /\b404\b|not found/i.test(haystack);
|
|
6988
|
-
}
|
|
6989
|
-
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
6990
|
-
let base64;
|
|
6991
|
-
try {
|
|
6992
|
-
base64 = fetcher();
|
|
6993
|
-
} catch (err) {
|
|
6994
|
-
return trustAnchorFetchFailed(err);
|
|
6995
|
-
}
|
|
6996
|
-
return parseTrustAnchorContent(base64);
|
|
6997
|
-
}
|
|
6998
|
-
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
6999
|
-
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
7000
|
-
let base64;
|
|
7001
|
-
try {
|
|
7002
|
-
base64 = await fetcher();
|
|
7003
|
-
} catch (err) {
|
|
7004
|
-
return trustAnchorFetchFailed(err, warn);
|
|
7005
|
-
}
|
|
7006
|
-
return parseTrustAnchorContent(base64, warn);
|
|
7007
|
-
}
|
|
7008
|
-
function warnTrustAnchorFallback(why) {
|
|
7009
|
-
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.
|
|
7010
|
-
`);
|
|
7011
|
-
}
|
|
7012
|
-
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
7013
|
-
if (!isMissingFileError(err))
|
|
7014
|
-
warn(firstLine(err));
|
|
7015
|
-
return null;
|
|
7016
|
-
}
|
|
7017
|
-
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
7018
|
-
const base64 = content.trim();
|
|
7019
|
-
if (!base64)
|
|
7020
|
-
return null;
|
|
7021
|
-
try {
|
|
7022
|
-
const raw = Buffer.from(base64, "base64").toString("utf-8");
|
|
7023
|
-
const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
|
|
7024
|
-
if (parsed.success)
|
|
7025
|
-
return parsed.data;
|
|
7026
|
-
warn("it did not satisfy the config schema");
|
|
7027
|
-
return null;
|
|
7028
|
-
} catch {
|
|
7029
|
-
warn("it was not readable as JSON");
|
|
7030
|
-
return null;
|
|
7031
|
-
}
|
|
7032
|
-
}
|
|
7033
|
-
function loadConfig() {
|
|
7034
|
-
const path = configPath();
|
|
7035
|
-
if (!path)
|
|
7036
|
-
return null;
|
|
7037
|
-
try {
|
|
7038
|
-
const raw = JSON.parse(readFileSync3(path, "utf-8"));
|
|
7039
|
-
return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
|
|
7040
|
-
} catch {
|
|
7041
|
-
return null;
|
|
7042
|
-
}
|
|
7043
|
-
}
|
|
7044
|
-
var TOKENS_COLLECT_TRUST_PATH = join3(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
7045
|
-
|
|
7046
|
-
// src/checks/contract.ts
|
|
7047
|
-
var CHECK_SCHEMA_VERSION = 1;
|
|
7048
|
-
function emitCheckError(error) {
|
|
7049
|
-
process.stderr.write(`${JSON.stringify(error)}
|
|
7050
|
-
`);
|
|
7051
|
-
}
|
|
7052
|
-
|
|
7053
|
-
// src/lib/diff-evidence.ts
|
|
7054
|
-
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
7055
|
-
import { join as join9, relative, resolve as resolve2 } from "node:path";
|
|
7056
|
-
|
|
7057
|
-
// src/lib/brief-assembly.ts
|
|
7058
|
-
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
7059
|
-
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
|
|
7060
|
-
import { join as join4 } from "node:path";
|
|
7061
|
-
|
|
6704
|
+
// ../../packages/aeg-core/src/docs/parse-doc.ts
|
|
6705
|
+
import matter2 from "gray-matter";
|
|
6706
|
+
// ../../packages/aeg-core/src/docs/surfaced-manifest.ts
|
|
6707
|
+
var NO_MODEL_BACKED_PATHS = new Set;
|
|
7062
6708
|
// ../../packages/sources/src/commands.ts
|
|
7063
6709
|
var COMMANDS = [
|
|
7064
6710
|
{
|
|
@@ -7207,20 +6853,31 @@ var COMMANDS = [
|
|
|
7207
6853
|
{
|
|
7208
6854
|
flag: "--agent <claude|codex|gemini>",
|
|
7209
6855
|
description: "Vendor for the developer and both reviewers this run dispatches"
|
|
6856
|
+
},
|
|
6857
|
+
{
|
|
6858
|
+
flag: "--quiet",
|
|
6859
|
+
description: "Hide the detail lines (an agent's prose, full commands, failed-result tails) on the live terminal; the driver log file keeps them"
|
|
7210
6860
|
}
|
|
7211
6861
|
],
|
|
7212
6862
|
details: [
|
|
7213
6863
|
"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.",
|
|
7214
6864
|
"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.",
|
|
7215
6865
|
"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.",
|
|
7216
|
-
"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
|
|
6866
|
+
"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 working `vinaya task run` command for this task's own branch to continue by hand — `<tranche> <n>` for a tranche task, `--issue <n>` for a backlog one — never a `dev-review-loop --resume` line naming a pull-request number this pause does not have), a usage/argv error (exit `2`), and any other failure (exit `3`)."
|
|
7217
6867
|
],
|
|
7218
6868
|
status: "shipped"
|
|
7219
6869
|
},
|
|
7220
6870
|
{
|
|
7221
6871
|
name: "task status",
|
|
7222
6872
|
description: "Every open task with a frozen brief, its pull request, and whether its loop is running, paused, or published",
|
|
7223
|
-
flags: [
|
|
6873
|
+
flags: [
|
|
6874
|
+
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" },
|
|
6875
|
+
{
|
|
6876
|
+
flag: "--follow",
|
|
6877
|
+
description: "Tail the task's driver log live, with its detail lines, on either the `<tranche> <n>` form or `--issue <n>`"
|
|
6878
|
+
},
|
|
6879
|
+
{ flag: "--quiet", description: "With `--follow`, hide the detail lines; the log file is unchanged" }
|
|
6880
|
+
],
|
|
7224
6881
|
details: [
|
|
7225
6882
|
"Read-only: one `gh issue list` for every open task Issue across every tranche (title/label resolved through the same `resolveTaskIssueRef` `list-tasks.ts` already uses), the open pull request per branch, and the driver pid record / pause record / publish effect markers under `<outboxRoot>/dev-review-loop/<task>/` — never a `ps` scan, never a re-parse of posted verdict comments to decide `published`.",
|
|
7226
6883
|
"`running` names the driver's pid (`review-validity-v1` task 7's pid record); `paused` names the reason from the pause record; `published` means the newest round's reviewer and security verdict effect markers both read `posted`; `no driver` is the fallback when none of the above holds.",
|
|
@@ -7256,6 +6913,26 @@ var COMMANDS = [
|
|
|
7256
6913
|
],
|
|
7257
6914
|
status: "shipped"
|
|
7258
6915
|
},
|
|
6916
|
+
{
|
|
6917
|
+
name: "task-tools result-proof",
|
|
6918
|
+
description: "Prove, live on this host, that a CLI delivers the Developer's turn result as its own structured final output",
|
|
6919
|
+
flags: [{ flag: "--agent <claude|codex>", description: "The CLI to prove" }],
|
|
6920
|
+
details: [
|
|
6921
|
+
"Runs real Developer-shaped dispatches on this host — the driver-run dev-tools registered and called, the agent's own sandbox where the host supports it, the subscription login, and the dispatch's own argv — and asks for the versioned `DeveloperTurnResult` (`completed`, `blocked` or `needs_ruling`) through the CLI's native structured output: Claude Code `--json-schema` under `--output-format stream-json`, with the dispatch's Stop hook plus one that rejects the first stop; Codex `--output-schema` under `exec --json` and `exec resume --json`.",
|
|
6922
|
+
"Cases: a first and a resumed session (the same provider session, a fresh result, exactly one accepted); a schema-valid but semantically invalid result (an unknown finding id, a ruling request naming no permissible decision), which the driver rejects; malformed output, which never reaches the driver; and a cancelled run, a provider error and context exhaustion, each ending with no accepted result. Each case prints whether a schema-valid result reached the driver, the result, and the event it was read from; exits 1 when any case fails. Never publishes, opens a pull request or writes the forge."
|
|
6923
|
+
],
|
|
6924
|
+
status: "shipped"
|
|
6925
|
+
},
|
|
6926
|
+
{
|
|
6927
|
+
name: "task-tools review-result-proof",
|
|
6928
|
+
description: "Prove, live on this host, that a CLI delivers a reviewer's result as its own structured final output, concurrent and fresh",
|
|
6929
|
+
flags: [{ flag: "--agent <claude|codex>", description: "The CLI to prove" }],
|
|
6930
|
+
details: [
|
|
6931
|
+
"Runs real reviewer-shaped dispatches on this host — fresh, non-resumed sessions, the agent's own sandbox where the host supports it, the subscription login, read-only grants, and the staged diff and review-input manifest — and asks for the versioned `ReviewResult` (`completed` or `blocked`, bound to the controller's role, head and manifest digest) through the CLI's native structured output: Claude Code `--json-schema` under `--output-format stream-json`; Codex `--output-schema` under `exec --json`. Both the code-reviewer and the security-reviewer role run, concurrently against one manifest, each accepted result attributed to its own role.",
|
|
6932
|
+
"Cases: a role mismatch, a wrong head and a wrong manifest digest; an objective id outside the brief, a severity outside the role's scale and a finding without a file (all refused) and a finding without a line (accepted); and a blocked, malformed, missing, cancelled, provider-error and context-exhausted outcome, each recorded as no review, never approval. Each case prints whether a schema-valid result reached the driver and what the controller made of it; exits 1 when any case fails. Never writes the forge and leaves the loop's reviewer dispatch and result files untouched."
|
|
6933
|
+
],
|
|
6934
|
+
status: "shipped"
|
|
6935
|
+
},
|
|
7259
6936
|
{
|
|
7260
6937
|
name: "pr create",
|
|
7261
6938
|
description: "Open a pull request after full brief-schema validation",
|
|
@@ -7298,13 +6975,14 @@ var COMMANDS = [
|
|
|
7298
6975
|
},
|
|
7299
6976
|
{
|
|
7300
6977
|
flag: "--push",
|
|
7301
|
-
description: "PR number; splices the same content into that PR's LIVE body (fetched from the forge) and pushes it via `gh pr edit`, self-verifying nothing outside the AEG:EVIDENCE
|
|
6978
|
+
description: "PR number; splices the same content into that PR's LIVE body (fetched from the forge) and pushes it via `gh pr edit`, self-verifying nothing outside the AEG:EVIDENCE region changed. Mutually exclusive with --write."
|
|
7302
6979
|
}
|
|
7303
6980
|
],
|
|
7304
6981
|
details: [
|
|
7305
6982
|
"Two groups: Group A (recomputable) is the head sha and a width-invariant `git diff --numstat` against the merge-base with `BASE_SHA` (else `origin/main`, then `main`) — `check-evidence-fresh` recomputes and byte-compares this exactly. Group B (attested) is the result of `vinaya check --all --diff-only`, this CLI's own portable gate suite — `check-evidence-fresh` can only check it for staleness (the block's recorded head still matches the PR's real head), never re-run it.",
|
|
7306
6983
|
"With no `--write`/`--push`, prints the block to stdout instead of writing a file. Exits non-zero whenever the gate run failed, whether or not `--write`/`--push` was given — the block records a failing result rather than hiding one, and a non-zero exit stops a scripted `--write && open-pr` (or `--push`) from carrying a failing suite onto the forge.",
|
|
7307
|
-
"`--push` refuses before writing anything when the live body carries no real `AEG:EVIDENCE` pair (it never appends one, unlike `--write`), when the anchor resolves differently before and after normalisation, or when `<pr>` isn't a bare number.
|
|
6984
|
+
"`--push` refuses before writing anything when the live body carries no real `AEG:EVIDENCE` pair (it never appends one, unlike `--write`), when the anchor resolves differently before and after normalisation, or when `<pr>` isn't a bare number. After pushing, it re-reads the live body and restores the pre-edit body — exiting non-zero — if anything outside that one anchored region changed.",
|
|
6985
|
+
"A pull-request body carries no token table, and this command writes none: a dispatched turn's token use is recorded as the Vinaya log's own `usage` event instead. A body that still carries an older run's table keeps it byte for byte — it is prose this command does not own, and a change inside it reads as real drift."
|
|
7308
6986
|
],
|
|
7309
6987
|
status: "shipped"
|
|
7310
6988
|
},
|
|
@@ -7329,7 +7007,7 @@ var COMMANDS = [
|
|
|
7329
7007
|
"Deliberately a command, not a check: `evidence-fresh` runs inside `vinaya check --all`, and `pr report` runs `vinaya check --all --diff-only`, so a check that regenerated the block would run the suite containing itself. That recursion is why `evidence-fresh` verifies Group A only and leaves Group B attested.",
|
|
7330
7008
|
"Must be run from the repository ROOT of a CLEAN checkout at the pull request's head, and refuses otherwise. The regeneration inherits the working directory and several gates resolve their scan root from it, so a subdirectory silently narrows what the fresh run inspects. On cleanliness: Group B is regenerated by diff-scoped checks, so uncommitted or untracked files change which files are scanned and can produce a MATCH a clean checkout would not. Ignored paths are deliberately NOT inspected — `git diff` never reports one, so they cannot change the scope, and including them would refuse in every real checkout since `node_modules` is ignored and always present. The head is read from the forge and both a mismatch AND an unreadable head refuse — the verdict is bound to a commit, never merely attested. `BASE_SHA` is refused as well, since it steers the regeneration's merge-base.",
|
|
7331
7009
|
"Exits 0 on MATCH; 1 on DIFFERS, HIDDEN, or no block; 2 on a refusal (dirty worktree, wrong head, usage error). HIDDEN means the anchor pair sits inside a collapsed `<details>` block, where `body-bare-digits` blanks every digit and nothing can verify what it claims.",
|
|
7332
|
-
"Comparison is a multiset of repo-relative, control-stripped lines: absolute paths (local AND foreign, so a block generated in CI compares against one generated on a laptop) and line order are ignored — a reorder is not a fabrication. Only the AEG:EVIDENCE region is read
|
|
7010
|
+
"Comparison is a multiset of repo-relative, control-stripped lines: absolute paths (local AND foreign, so a block generated in CI compares against one generated on a laptop) and line order are ignored — a reorder is not a fabrication. Only the AEG:EVIDENCE region is read: every other section of the body is prose no regeneration reproduces. A moved merge-base is reported ALONGSIDE the differing lines, never instead of them."
|
|
7333
7011
|
],
|
|
7334
7012
|
status: "shipped"
|
|
7335
7013
|
},
|
|
@@ -7500,7 +7178,7 @@ var COMMANDS = [
|
|
|
7500
7178
|
{ flag: "--secrets", description: "security only: the SECRETS line" },
|
|
7501
7179
|
{
|
|
7502
7180
|
flag: "--secrets-evidence-file",
|
|
7503
|
-
description: 'security only: required whenever `--secrets` claims "none found" — the
|
|
7181
|
+
description: 'security only: required whenever `--secrets` claims "none found" — the passing `atta-labs/secret-scan` check result on the judged head that backs it; never run or paste the scanner'
|
|
7504
7182
|
},
|
|
7505
7183
|
{ flag: "--task-id", description: "the closing `Tokens:` line's task id" },
|
|
7506
7184
|
{ flag: "--model", description: "the closing `Tokens:` line's model name" },
|
|
@@ -7608,7 +7286,20 @@ var COMMANDS = [
|
|
|
7608
7286
|
flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
|
|
7609
7287
|
details: [
|
|
7610
7288
|
"Refuses if any task Issue attached to the named tranche is still open, naming each one — closing a tranche with unresolved work is never silently allowed.",
|
|
7611
|
-
"Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes
|
|
7289
|
+
"Once every task Issue is closed, prompts for confirmation (unless `--yes`), records the tranche's retrospective in the Milestone its task Issues are attached to, and closes that Milestone once nothing else in it is still open.",
|
|
7290
|
+
"A tranche none of whose task Issues carry a Milestone gets one: a Milestone titled with the tranche's slug is created, the tranche's closed task Issues are attached to it, the retrospective is recorded, and it is closed — so the tranche reads as archived. An Issue already on a Milestone is never moved.",
|
|
7291
|
+
"Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
|
|
7292
|
+
"The generated `vinaya-archivist.yml` workflow runs it after a task pull request merges, and again when an Issue labeled with the tranche closes without a merge (dropped, replaced or closed by hand) — the tranche's slug read from that Issue's own label."
|
|
7293
|
+
],
|
|
7294
|
+
status: "shipped"
|
|
7295
|
+
},
|
|
7296
|
+
{
|
|
7297
|
+
name: "archive tranches",
|
|
7298
|
+
description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
|
|
7299
|
+
flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
|
|
7300
|
+
details: [
|
|
7301
|
+
"Walks every `vinaya/tranche:<slug>` label, skips each tranche that still has an open task Issue, and runs `archive tranche` for each finished one whose Milestone is not already closed with its retrospective. One tranche failing does not stop the others; the exit code reports it.",
|
|
7302
|
+
"The generated `vinaya-archivist.yml` workflow calls it on its daily scheduled run, so a tranche that finished before the workflow could see it is archived within a day. Running it again when every finished tranche is archived changes nothing and says so."
|
|
7612
7303
|
],
|
|
7613
7304
|
status: "shipped"
|
|
7614
7305
|
},
|
|
@@ -7752,6 +7443,29 @@ var COMMANDS = [
|
|
|
7752
7443
|
],
|
|
7753
7444
|
status: "shipped"
|
|
7754
7445
|
},
|
|
7446
|
+
{
|
|
7447
|
+
name: "log selftest",
|
|
7448
|
+
description: "Prove log delivery works end to end: send one marked test event and read it back — PASS (exit 0) or FAIL with the one reason (exit 1)",
|
|
7449
|
+
details: [
|
|
7450
|
+
"Resolves the destination exactly as an UNATTENDED review-loop run does in this repository — the same trust-anchor read and credential lookup, forced unattended so running it by hand proves the launch path's own resolution, not a human's. It sends one test event to the configured `logs.url` server, then reads it back from the server by the event's own id through the server's cursor read.",
|
|
7451
|
+
"PASS (exit 0) only when the event round-trips. Otherwise FAIL (exit 1) with the ONE reason that stopped it: no server is configured, the default branch's config could not be read to confirm the url (and why), this host holds no ingest or read credential, the server refused with its status, or the event could not be read back. It never prints a credential value.",
|
|
7452
|
+
"The read-back needs a READ credential distinct from the write-only ingest one the server refuses on a read route: set `logs.readHeaders` in vinaya.config.json to the server's read token (referenced by variable name, resolved from the environment exactly as `logs.headers` is). The test event is marked `operation: 'log.selftest'` so a reader can exclude it from real telemetry."
|
|
7453
|
+
],
|
|
7454
|
+
status: "shipped"
|
|
7455
|
+
},
|
|
7456
|
+
{
|
|
7457
|
+
name: "log emit",
|
|
7458
|
+
description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
|
|
7459
|
+
flags: [
|
|
7460
|
+
{ flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
|
|
7461
|
+
],
|
|
7462
|
+
details: [
|
|
7463
|
+
"Reads the field values as ONE JSON object — `--json '<json>'` or piped on standard input, never positional arguments — and records them through `emitCustomEvent`, the same chokepoint every custom event goes through, so the refusal event and the redaction stay in one place.",
|
|
7464
|
+
"A declared event with every field present and of its declared type exits 0 and prints the event name and the kind of destination it was recorded toward (`folder`, `server`, or `none`) — never a field value. A refused event (an undeclared name, or a missing, extra, wrong-typed or too-long field) exits 1 and prints the reason class and the field names — never a value, since a rejected value may be the secret. A missing event name, unreadable JSON, or JSON that is not a flat object is a usage error: exit 2, before anything is recorded.",
|
|
7465
|
+
"A process with only `VINAYA_WORK_REF` and `VINAYA_FLOW` set, and no Vinaya role or task, still gets a header carrying that work reference and way-of-working id — the same environment read every event already honours (`apps/cli/specs/log.md` § Attribution)."
|
|
7466
|
+
],
|
|
7467
|
+
status: "shipped"
|
|
7468
|
+
},
|
|
7755
7469
|
{
|
|
7756
7470
|
name: "log send",
|
|
7757
7471
|
description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
|
|
@@ -7764,32 +7478,628 @@ var COMMANDS = [
|
|
|
7764
7478
|
status: "shipped"
|
|
7765
7479
|
},
|
|
7766
7480
|
{
|
|
7767
|
-
name: "
|
|
7768
|
-
description: "
|
|
7481
|
+
name: "sync",
|
|
7482
|
+
description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
|
|
7483
|
+
flags: [
|
|
7484
|
+
{
|
|
7485
|
+
flag: "--rebuild",
|
|
7486
|
+
description: "Delete the cache file and sync from the beginning of what the destination still retains"
|
|
7487
|
+
},
|
|
7488
|
+
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
7489
|
+
],
|
|
7769
7490
|
details: [
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
"
|
|
7491
|
+
"Resolves the destination exactly the way a normal event does — the sink's own decision over `vinaya.config.json`'s `logs` setting, trust-anchor-gated for an unattended caller — then reads a folder destination through the folder source or a server destination through the server source (with the configured `logs.readHeaders`, substituted from the environment), and runs the bounded sync engine against the durable cache this repository holds under its runtime directory. Prints pages read, rows stored, duplicates, edits, deletions, gaps, quarantined lines and, for a server destination, its lost-event diagnostic. Reads the destination and writes only its own cache directory — never the folder, the server, or the forge.",
|
|
7492
|
+
"Exits 0 when the run completed or stopped cleanly on its page bound (and says more is available), 1 when it failed part way (the progress made is kept — a second run resumes from the stored cursor), and 2 for a usage or configuration problem: no destination is configured, or a server destination is configured with no usable read credential. A missing credential names the environment variable to set and never prints its value.",
|
|
7493
|
+
"`--rebuild` deletes the cache file ALONE — never anything else under the cache directory — and syncs again from the beginning of what the destination still retains; an event already rotated out of a folder's single backup slot, or no longer retained by the destination, cannot be recovered and shows up as a gap, never silently."
|
|
7773
7494
|
],
|
|
7774
7495
|
status: "shipped"
|
|
7775
7496
|
}
|
|
7776
|
-
];
|
|
7777
|
-
// ../../packages/sources/src/forge-adapter.ts
|
|
7778
|
-
function createForgeSource(config) {
|
|
7779
|
-
return {
|
|
7780
|
-
async getTranche(slug) {
|
|
7781
|
-
return deriveTrancheFromForge(config.owner, config.repo, slug);
|
|
7782
|
-
}
|
|
7783
|
-
};
|
|
7497
|
+
];
|
|
7498
|
+
// ../../packages/sources/src/forge-adapter.ts
|
|
7499
|
+
function createForgeSource(config) {
|
|
7500
|
+
return {
|
|
7501
|
+
async getTranche(slug) {
|
|
7502
|
+
return deriveTrancheFromForge(config.owner, config.repo, slug);
|
|
7503
|
+
}
|
|
7504
|
+
};
|
|
7505
|
+
}
|
|
7506
|
+
// ../../packages/sources/src/select-source.ts
|
|
7507
|
+
import { z as z5 } from "zod";
|
|
7508
|
+
var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
|
|
7509
|
+
z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
|
|
7510
|
+
z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
|
|
7511
|
+
]);
|
|
7512
|
+
// src/lib/config.ts
|
|
7513
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
7514
|
+
import { promisify as promisify4 } from "node:util";
|
|
7515
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
|
|
7516
|
+
import { homedir } from "node:os";
|
|
7517
|
+
import { dirname as dirname2, isAbsolute, join as join2, resolve } from "node:path";
|
|
7518
|
+
import { z as z6 } from "zod";
|
|
7519
|
+
|
|
7520
|
+
// src/lib/agent-vendors.ts
|
|
7521
|
+
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
7522
|
+
|
|
7523
|
+
// src/lib/config.ts
|
|
7524
|
+
var EnvEntrySchema = z6.union([
|
|
7525
|
+
z6.literal(true),
|
|
7526
|
+
z6.object({ optional: z6.literal(true) }),
|
|
7527
|
+
z6.object({ anyOf: z6.array(z6.string()).min(2) }),
|
|
7528
|
+
z6.string()
|
|
7529
|
+
]);
|
|
7530
|
+
var CheckEntrySchema = z6.object({
|
|
7531
|
+
run: z6.string(),
|
|
7532
|
+
scope: z6.enum(["diff", "full"]),
|
|
7533
|
+
include: z6.array(z6.string()).optional(),
|
|
7534
|
+
args: z6.array(z6.string()).optional(),
|
|
7535
|
+
timeoutMs: z6.number().optional(),
|
|
7536
|
+
env: z6.record(z6.string(), EnvEntrySchema).optional(),
|
|
7537
|
+
requiresOpenPr: z6.boolean().optional(),
|
|
7538
|
+
ownWorkflow: z6.boolean().optional(),
|
|
7539
|
+
principalOwed: z6.literal(true).optional(),
|
|
7540
|
+
validates: z6.enum(["body", "issue"]).optional()
|
|
7541
|
+
}).superRefine((entry, ctx) => {
|
|
7542
|
+
if (!entry.env)
|
|
7543
|
+
return;
|
|
7544
|
+
for (const [key, value] of Object.entries(entry.env)) {
|
|
7545
|
+
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
7546
|
+
continue;
|
|
7547
|
+
const members = value.anyOf;
|
|
7548
|
+
if (new Set(members).size !== members.length) {
|
|
7549
|
+
ctx.addIssue({
|
|
7550
|
+
code: z6.ZodIssueCode.custom,
|
|
7551
|
+
message: `env.${key}.anyOf has duplicate members`,
|
|
7552
|
+
path: ["env", key, "anyOf"]
|
|
7553
|
+
});
|
|
7554
|
+
}
|
|
7555
|
+
if (!members.includes(key)) {
|
|
7556
|
+
ctx.addIssue({
|
|
7557
|
+
code: z6.ZodIssueCode.custom,
|
|
7558
|
+
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
7559
|
+
path: ["env", key, "anyOf"]
|
|
7560
|
+
});
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
});
|
|
7564
|
+
var RoleEntrySchema = z6.object({
|
|
7565
|
+
contract: z6.string().refine((p) => p.includes("/"), {
|
|
7566
|
+
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
7567
|
+
})
|
|
7568
|
+
});
|
|
7569
|
+
var MAX_REPORT_COMMAND_TIMEOUT_MS = 3600000;
|
|
7570
|
+
var BRIEF_BUILTINS = [
|
|
7571
|
+
"tier",
|
|
7572
|
+
"testPlan",
|
|
7573
|
+
"testPlanExclusivity",
|
|
7574
|
+
"principalPlaceholder",
|
|
7575
|
+
"surfaceMap",
|
|
7576
|
+
"docUpdateList",
|
|
7577
|
+
"worktreeStep0",
|
|
7578
|
+
"stopConditions",
|
|
7579
|
+
"autonomyClause",
|
|
7580
|
+
"project",
|
|
7581
|
+
"for",
|
|
7582
|
+
"closesN",
|
|
7583
|
+
"premiseCoverage",
|
|
7584
|
+
"issueRationale",
|
|
7585
|
+
"objectives",
|
|
7586
|
+
"briefSections",
|
|
7587
|
+
"milestoneShape"
|
|
7588
|
+
];
|
|
7589
|
+
var BriefSectionSchema = z6.union([
|
|
7590
|
+
z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
|
|
7591
|
+
z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
|
|
7592
|
+
z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
|
|
7593
|
+
z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
|
|
7594
|
+
]);
|
|
7595
|
+
var BriefSchemaSchema = z6.object({
|
|
7596
|
+
pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
7597
|
+
issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
7598
|
+
milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
7599
|
+
ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
|
|
7600
|
+
});
|
|
7601
|
+
function isSafeRepoRelPath(p) {
|
|
7602
|
+
if (p.length === 0)
|
|
7603
|
+
return false;
|
|
7604
|
+
if (p.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(p))
|
|
7605
|
+
return false;
|
|
7606
|
+
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
7607
|
+
}
|
|
7608
|
+
var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
|
|
7609
|
+
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
7610
|
+
});
|
|
7611
|
+
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
7612
|
+
function isCanonicalHookBlockPath(p) {
|
|
7613
|
+
return CANONICAL_HOOK_BLOCK_PREFIXES.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
|
|
7614
|
+
}
|
|
7615
|
+
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
7616
|
+
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
7617
|
+
});
|
|
7618
|
+
var ManagedBlockRecordSchema = z6.object({
|
|
7619
|
+
path: ManagedHookBlockPath,
|
|
7620
|
+
marker: z6.string(),
|
|
7621
|
+
comment: z6.enum(["hash", "html"])
|
|
7622
|
+
});
|
|
7623
|
+
var ManagedManifestSchema = z6.object({
|
|
7624
|
+
version: z6.number().int().positive(),
|
|
7625
|
+
files: z6.array(SafeRepoRelPath),
|
|
7626
|
+
blocks: z6.array(ManagedBlockRecordSchema),
|
|
7627
|
+
labels: z6.array(z6.string()),
|
|
7628
|
+
agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
|
|
7629
|
+
});
|
|
7630
|
+
var ProjectEntrySchema = z6.object({
|
|
7631
|
+
name: z6.string().min(1),
|
|
7632
|
+
description: z6.string().min(1).optional(),
|
|
7633
|
+
path: z6.string().min(1).optional()
|
|
7634
|
+
});
|
|
7635
|
+
function parseTokensCollectDeclaration(value) {
|
|
7636
|
+
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
7637
|
+
if (!m)
|
|
7638
|
+
return null;
|
|
7639
|
+
const [, interpreter, script] = m;
|
|
7640
|
+
if (!isSafeRepoRelPath(script))
|
|
7641
|
+
return null;
|
|
7642
|
+
return { interpreter, script };
|
|
7643
|
+
}
|
|
7644
|
+
var VinayaConfigSchema = z6.object({
|
|
7645
|
+
rings: z6.object({
|
|
7646
|
+
ring1_forgeWriteInterception: z6.boolean(),
|
|
7647
|
+
ring2_asyncAudits: z6.boolean()
|
|
7648
|
+
}).optional(),
|
|
7649
|
+
checks: z6.record(z6.string(), CheckEntrySchema).optional(),
|
|
7650
|
+
roles: z6.record(z6.string(), RoleEntrySchema).optional(),
|
|
7651
|
+
briefSchema: BriefSchemaSchema.optional(),
|
|
7652
|
+
managed: ManagedManifestSchema.optional(),
|
|
7653
|
+
principals: z6.array(z6.string()).min(1).optional(),
|
|
7654
|
+
releaseActor: z6.string().min(1).optional(),
|
|
7655
|
+
ci: z6.object({ setup: z6.string().min(1) }).optional(),
|
|
7656
|
+
tokens: z6.object({
|
|
7657
|
+
collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
7658
|
+
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
7659
|
+
})
|
|
7660
|
+
}).optional(),
|
|
7661
|
+
blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
|
|
7662
|
+
proseGates: z6.object({
|
|
7663
|
+
doctrineRoot: z6.string().min(1).optional(),
|
|
7664
|
+
readerFacingPrefix: z6.string().min(1).optional(),
|
|
7665
|
+
readerFacingSuffix: z6.string().min(1).optional(),
|
|
7666
|
+
legacySlugDir: z6.string().min(1).optional(),
|
|
7667
|
+
sourceComments: z6.object({
|
|
7668
|
+
globs: z6.array(z6.string().min(1)).optional(),
|
|
7669
|
+
allowlist: z6.array(z6.string().min(1)).optional(),
|
|
7670
|
+
severity: z6.enum(["warning", "error"]).optional()
|
|
7671
|
+
}).optional(),
|
|
7672
|
+
specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
|
|
7673
|
+
specPaths: z6.array(z6.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
|
|
7674
|
+
message: "must be a repository-relative path, not an absolute one"
|
|
7675
|
+
}).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
|
|
7676
|
+
message: "must stay inside the repository — no `..` segment"
|
|
7677
|
+
})).optional()
|
|
7678
|
+
}).optional(),
|
|
7679
|
+
projects: z6.array(ProjectEntrySchema).optional(),
|
|
7680
|
+
dispatch: z6.object({
|
|
7681
|
+
timeoutMs: z6.number().int().positive().optional(),
|
|
7682
|
+
killGraceMs: z6.number().int().positive().optional(),
|
|
7683
|
+
agent: z6.enum(["claude", "codex", "gemini"]).optional()
|
|
7684
|
+
}).optional(),
|
|
7685
|
+
reviewPolicy: z6.object({
|
|
7686
|
+
codeReviewThreshold: z6.string().min(1).optional(),
|
|
7687
|
+
securityThreshold: z6.string().min(1).optional(),
|
|
7688
|
+
maxRounds: z6.number().optional(),
|
|
7689
|
+
maxTaskMinutes: z6.number().optional()
|
|
7690
|
+
}).optional(),
|
|
7691
|
+
securityScan: z6.object({
|
|
7692
|
+
command: z6.array(z6.string().min(1)).min(1)
|
|
7693
|
+
}).optional(),
|
|
7694
|
+
gateCutovers: z6.object({
|
|
7695
|
+
objectivesSinceIssue: z6.number().int().nonnegative().optional(),
|
|
7696
|
+
briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
|
|
7697
|
+
documentationSinceIssue: z6.number().int().nonnegative().optional(),
|
|
7698
|
+
briefRulesSincePr: z6.number().int().nonnegative().optional(),
|
|
7699
|
+
agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
|
|
7700
|
+
}).optional(),
|
|
7701
|
+
planning: z6.object({
|
|
7702
|
+
collisionThreshold: z6.number().int().nonnegative().optional()
|
|
7703
|
+
}).optional(),
|
|
7704
|
+
prePush: z6.object({
|
|
7705
|
+
alwaysRun: z6.array(z6.string()).optional()
|
|
7706
|
+
}).optional(),
|
|
7707
|
+
report: z6.object({
|
|
7708
|
+
commandTimeoutMs: z6.number().int().positive().optional()
|
|
7709
|
+
}).superRefine((report, ctx) => {
|
|
7710
|
+
const commandTimeoutMs = report.commandTimeoutMs;
|
|
7711
|
+
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
7712
|
+
ctx.addIssue({
|
|
7713
|
+
code: z6.ZodIssueCode.custom,
|
|
7714
|
+
path: ["commandTimeoutMs"],
|
|
7715
|
+
message: "must be at most 3600000 (1 hour)"
|
|
7716
|
+
});
|
|
7717
|
+
}
|
|
7718
|
+
}).optional(),
|
|
7719
|
+
logPublish: z6.unknown().refine((v) => v === undefined, {
|
|
7720
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
7721
|
+
}),
|
|
7722
|
+
runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
7723
|
+
logs: z6.object({
|
|
7724
|
+
folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
7725
|
+
url: z6.string().url().optional(),
|
|
7726
|
+
headers: z6.record(z6.string()).optional(),
|
|
7727
|
+
readHeaders: z6.record(z6.string()).optional(),
|
|
7728
|
+
events: CustomEventDeclarationsSchema.optional()
|
|
7729
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
7730
|
+
message: "logs: set at most one of folder/url"
|
|
7731
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
7732
|
+
message: "logs: headers requires url"
|
|
7733
|
+
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
7734
|
+
message: "logs: readHeaders requires url"
|
|
7735
|
+
}).optional()
|
|
7736
|
+
});
|
|
7737
|
+
var GLOBAL_VINAYA_HOME = join2(homedir(), ".vinaya");
|
|
7738
|
+
var GLOBAL_CONFIG_PATH = join2(GLOBAL_VINAYA_HOME, "config.json");
|
|
7739
|
+
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
7740
|
+
function findLocalConfig() {
|
|
7741
|
+
let dir = process.cwd();
|
|
7742
|
+
while (true) {
|
|
7743
|
+
const candidate = join2(dir, LOCAL_CONFIG_FILENAME);
|
|
7744
|
+
if (existsSync2(candidate))
|
|
7745
|
+
return candidate;
|
|
7746
|
+
if (existsSync2(join2(dir, ".git")))
|
|
7747
|
+
return null;
|
|
7748
|
+
const parent = dirname2(dir);
|
|
7749
|
+
if (parent === dir)
|
|
7750
|
+
return null;
|
|
7751
|
+
dir = parent;
|
|
7752
|
+
}
|
|
7753
|
+
}
|
|
7754
|
+
function configPath() {
|
|
7755
|
+
const local = findLocalConfig();
|
|
7756
|
+
if (local)
|
|
7757
|
+
return local;
|
|
7758
|
+
if (existsSync2(GLOBAL_CONFIG_PATH))
|
|
7759
|
+
return GLOBAL_CONFIG_PATH;
|
|
7760
|
+
return null;
|
|
7761
|
+
}
|
|
7762
|
+
function globalChecksIgnoredWarning(path) {
|
|
7763
|
+
return `${path}: "checks" registration in the global config is ignored — checks may only be registered from a repo-local vinaya.config.json.`;
|
|
7764
|
+
}
|
|
7765
|
+
function globalPrincipalsIgnoredWarning(path) {
|
|
7766
|
+
return `${path}: "principals" in the global config is ignored — principals may only be declared from a repo-local vinaya.config.json.`;
|
|
7767
|
+
}
|
|
7768
|
+
function globalRolesIgnoredWarning(path) {
|
|
7769
|
+
return `${path}: "roles" registration in the global config is ignored — roles may only be registered from a repo-local vinaya.config.json.`;
|
|
7770
|
+
}
|
|
7771
|
+
function globalReleaseActorIgnoredWarning(path) {
|
|
7772
|
+
return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
|
|
7773
|
+
}
|
|
7774
|
+
function globalTokensCollectIgnoredWarning(path) {
|
|
7775
|
+
return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
|
|
7776
|
+
}
|
|
7777
|
+
function globalRuntimeDirIgnoredWarning(path) {
|
|
7778
|
+
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.`;
|
|
7779
|
+
}
|
|
7780
|
+
var emittedGlobalKeyWarnings = new Set;
|
|
7781
|
+
function warnGlobalKeyIgnoredOnce(message) {
|
|
7782
|
+
if (emittedGlobalKeyWarnings.has(message))
|
|
7783
|
+
return;
|
|
7784
|
+
emittedGlobalKeyWarnings.add(message);
|
|
7785
|
+
console.error(`⚠ ${message}`);
|
|
7786
|
+
}
|
|
7787
|
+
function stripGlobalOnlyKeys(config, path) {
|
|
7788
|
+
if (path !== GLOBAL_CONFIG_PATH)
|
|
7789
|
+
return config;
|
|
7790
|
+
let result = config;
|
|
7791
|
+
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
7792
|
+
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
7793
|
+
result = { ...result, checks: undefined };
|
|
7794
|
+
}
|
|
7795
|
+
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
7796
|
+
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
7797
|
+
result = { ...result, roles: undefined };
|
|
7798
|
+
}
|
|
7799
|
+
if (result.principals && result.principals.length > 0) {
|
|
7800
|
+
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
7801
|
+
result = { ...result, principals: undefined };
|
|
7802
|
+
}
|
|
7803
|
+
if (result.releaseActor) {
|
|
7804
|
+
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
7805
|
+
result = { ...result, releaseActor: undefined };
|
|
7806
|
+
}
|
|
7807
|
+
if (result.tokens) {
|
|
7808
|
+
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
7809
|
+
result = { ...result, tokens: undefined };
|
|
7810
|
+
}
|
|
7811
|
+
if (result.runtimeDir) {
|
|
7812
|
+
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
7813
|
+
result = { ...result, runtimeDir: undefined };
|
|
7814
|
+
}
|
|
7815
|
+
return result;
|
|
7816
|
+
}
|
|
7817
|
+
function resolvePrincipalAllowlist(config) {
|
|
7818
|
+
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
7819
|
+
}
|
|
7820
|
+
function resolveReleaseActor(config) {
|
|
7821
|
+
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
7822
|
+
}
|
|
7823
|
+
function resolveReviewPolicy(config) {
|
|
7824
|
+
const raw = config?.reviewPolicy;
|
|
7825
|
+
if (!raw)
|
|
7826
|
+
return DEFAULT_REVIEW_POLICY;
|
|
7827
|
+
const codeReviewThreshold = raw.codeReviewThreshold ?? DEFAULT_REVIEW_POLICY.codeReviewThreshold;
|
|
7828
|
+
if (!isKnownSeverity(CODE_REVIEW_SEVERITY_ORDER, codeReviewThreshold)) {
|
|
7829
|
+
throw new Error(`vinaya.config.json: reviewPolicy.codeReviewThreshold "${codeReviewThreshold}" is not one of ${CODE_REVIEW_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
|
|
7830
|
+
}
|
|
7831
|
+
const securityThreshold = raw.securityThreshold ?? DEFAULT_REVIEW_POLICY.securityThreshold;
|
|
7832
|
+
if (!isKnownSeverity(SECURITY_SEVERITY_ORDER, securityThreshold)) {
|
|
7833
|
+
throw new Error(`vinaya.config.json: reviewPolicy.securityThreshold "${securityThreshold}" is not one of ${SECURITY_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
|
|
7834
|
+
}
|
|
7835
|
+
const maxRounds = raw.maxRounds ?? DEFAULT_REVIEW_POLICY.maxRounds;
|
|
7836
|
+
if (!Number.isInteger(maxRounds) || maxRounds < 1) {
|
|
7837
|
+
throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
|
|
7838
|
+
}
|
|
7839
|
+
const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
|
|
7840
|
+
if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
|
|
7841
|
+
throw new Error(`vinaya.config.json: reviewPolicy.maxTaskMinutes "${maxTaskMinutes}" is not a non-negative integer (0 turns the budget off) — fix the config, this never falls back to a default.`);
|
|
7842
|
+
}
|
|
7843
|
+
return {
|
|
7844
|
+
codeReviewThreshold,
|
|
7845
|
+
securityThreshold,
|
|
7846
|
+
maxRounds,
|
|
7847
|
+
maxTaskMinutes
|
|
7848
|
+
};
|
|
7849
|
+
}
|
|
7850
|
+
function resolveGateCutovers(config) {
|
|
7851
|
+
const raw = config?.gateCutovers;
|
|
7852
|
+
if (!raw)
|
|
7853
|
+
return NO_GATE_CUTOVERS;
|
|
7854
|
+
return {
|
|
7855
|
+
objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
|
|
7856
|
+
briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
|
|
7857
|
+
documentationSinceIssue: raw.documentationSinceIssue ?? null,
|
|
7858
|
+
briefRulesSincePr: raw.briefRulesSincePr ?? null,
|
|
7859
|
+
agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
|
|
7860
|
+
};
|
|
7861
|
+
}
|
|
7862
|
+
function resolveRuntimeDirSetting(config) {
|
|
7863
|
+
return config?.runtimeDir ?? null;
|
|
7864
|
+
}
|
|
7865
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
7866
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
7867
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
7868
|
+
}
|
|
7869
|
+
function resolveLogsSetting(config) {
|
|
7870
|
+
const raw = config?.logs;
|
|
7871
|
+
if (!raw)
|
|
7872
|
+
return null;
|
|
7873
|
+
if (raw.url !== undefined)
|
|
7874
|
+
return { url: raw.url, headers: raw.headers };
|
|
7875
|
+
if (raw.folder !== undefined)
|
|
7876
|
+
return { folder: raw.folder };
|
|
7877
|
+
return null;
|
|
7878
|
+
}
|
|
7879
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
7880
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
7881
|
+
if (!anchored)
|
|
7882
|
+
return null;
|
|
7883
|
+
if ("url" in local)
|
|
7884
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
7885
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
7886
|
+
}
|
|
7887
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
7888
|
+
if (!headers)
|
|
7889
|
+
return;
|
|
7890
|
+
const resolved = {};
|
|
7891
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
7892
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
7893
|
+
}
|
|
7894
|
+
return resolved;
|
|
7895
|
+
}
|
|
7896
|
+
function trustAnchorRepo() {
|
|
7897
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
7898
|
+
if (fromRunner)
|
|
7899
|
+
return fromRunner;
|
|
7900
|
+
try {
|
|
7901
|
+
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
7902
|
+
encoding: "utf-8",
|
|
7903
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
7904
|
+
});
|
|
7905
|
+
return trustAnchorRepoFromRemoteUrl(url);
|
|
7906
|
+
} catch {
|
|
7907
|
+
return null;
|
|
7908
|
+
}
|
|
7909
|
+
}
|
|
7910
|
+
async function trustAnchorRepoAsync() {
|
|
7911
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
7912
|
+
if (fromRunner)
|
|
7913
|
+
return fromRunner;
|
|
7914
|
+
try {
|
|
7915
|
+
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
7916
|
+
encoding: "utf-8",
|
|
7917
|
+
timeout: 1e4,
|
|
7918
|
+
killSignal: "SIGKILL"
|
|
7919
|
+
});
|
|
7920
|
+
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
7921
|
+
} catch {
|
|
7922
|
+
return null;
|
|
7923
|
+
}
|
|
7924
|
+
}
|
|
7925
|
+
function wellFormedRepoSlug(slug) {
|
|
7926
|
+
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
7927
|
+
}
|
|
7928
|
+
function trustAnchorRepoFromRunner() {
|
|
7929
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
7930
|
+
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
7931
|
+
}
|
|
7932
|
+
function trustAnchorRepoFromRemoteUrl(url) {
|
|
7933
|
+
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
7934
|
+
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
7935
|
+
}
|
|
7936
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
7937
|
+
function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
7938
|
+
const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
|
|
7939
|
+
if (!ref)
|
|
7940
|
+
return null;
|
|
7941
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
7942
|
+
return null;
|
|
7943
|
+
if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
|
|
7944
|
+
return null;
|
|
7945
|
+
return ref;
|
|
7946
|
+
}
|
|
7947
|
+
function readTrustAnchorConfigAtRef(ref) {
|
|
7948
|
+
const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
7949
|
+
encoding: "utf-8",
|
|
7950
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
7951
|
+
timeout: 1e4
|
|
7952
|
+
});
|
|
7953
|
+
return Buffer.from(raw, "utf-8").toString("base64");
|
|
7954
|
+
}
|
|
7955
|
+
function ghFetchTrustAnchorConfig() {
|
|
7956
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
7957
|
+
if (probeRef)
|
|
7958
|
+
return readTrustAnchorConfigAtRef(probeRef);
|
|
7959
|
+
const repo = trustAnchorRepo();
|
|
7960
|
+
if (!repo)
|
|
7961
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
7962
|
+
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
7963
|
+
encoding: "utf-8",
|
|
7964
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
7965
|
+
});
|
|
7966
|
+
}
|
|
7967
|
+
async function ghFetchTrustAnchorConfigAsync() {
|
|
7968
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
7969
|
+
if (probeRef) {
|
|
7970
|
+
const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
|
|
7971
|
+
encoding: "utf-8",
|
|
7972
|
+
timeout: 1e4
|
|
7973
|
+
});
|
|
7974
|
+
return Buffer.from(stdout, "utf-8").toString("base64");
|
|
7975
|
+
}
|
|
7976
|
+
const repo = await trustAnchorRepoAsync();
|
|
7977
|
+
if (!repo)
|
|
7978
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
7979
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
7980
|
+
return stdout;
|
|
7981
|
+
}
|
|
7982
|
+
function firstLine(err) {
|
|
7983
|
+
return err?.message?.split(`
|
|
7984
|
+
`)[0] ?? "unknown error";
|
|
7985
|
+
}
|
|
7986
|
+
function isMissingFileError(err) {
|
|
7987
|
+
const stderr = err?.stderr;
|
|
7988
|
+
const haystack = [
|
|
7989
|
+
err?.message ?? "",
|
|
7990
|
+
typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
|
|
7991
|
+
].join(`
|
|
7992
|
+
`);
|
|
7993
|
+
return /\b404\b|not found/i.test(haystack);
|
|
7994
|
+
}
|
|
7995
|
+
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
7996
|
+
let base64;
|
|
7997
|
+
try {
|
|
7998
|
+
base64 = fetcher();
|
|
7999
|
+
} catch (err) {
|
|
8000
|
+
return trustAnchorFetchFailed(err);
|
|
8001
|
+
}
|
|
8002
|
+
return parseTrustAnchorContent(base64);
|
|
8003
|
+
}
|
|
8004
|
+
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
8005
|
+
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
8006
|
+
let base64;
|
|
8007
|
+
try {
|
|
8008
|
+
base64 = await fetcher();
|
|
8009
|
+
} catch (err) {
|
|
8010
|
+
return trustAnchorFetchFailed(err, warn);
|
|
8011
|
+
}
|
|
8012
|
+
return parseTrustAnchorContent(base64, warn);
|
|
8013
|
+
}
|
|
8014
|
+
function warnTrustAnchorFallback(why) {
|
|
8015
|
+
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.
|
|
8016
|
+
`);
|
|
8017
|
+
}
|
|
8018
|
+
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
8019
|
+
if (!isMissingFileError(err))
|
|
8020
|
+
warn(firstLine(err));
|
|
8021
|
+
return null;
|
|
8022
|
+
}
|
|
8023
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
8024
|
+
const base64 = content.trim();
|
|
8025
|
+
if (!base64)
|
|
8026
|
+
return null;
|
|
8027
|
+
try {
|
|
8028
|
+
const raw = Buffer.from(base64, "base64").toString("utf-8");
|
|
8029
|
+
const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
|
|
8030
|
+
if (parsed.success)
|
|
8031
|
+
return parsed.data;
|
|
8032
|
+
warn("it did not satisfy the config schema");
|
|
8033
|
+
return null;
|
|
8034
|
+
} catch {
|
|
8035
|
+
warn("it was not readable as JSON");
|
|
8036
|
+
return null;
|
|
8037
|
+
}
|
|
7784
8038
|
}
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
8039
|
+
function loadConfig() {
|
|
8040
|
+
const path = configPath();
|
|
8041
|
+
if (!path)
|
|
8042
|
+
return null;
|
|
8043
|
+
try {
|
|
8044
|
+
const raw = JSON.parse(readFileSync2(path, "utf-8"));
|
|
8045
|
+
return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
|
|
8046
|
+
} catch {
|
|
8047
|
+
return null;
|
|
8048
|
+
}
|
|
8049
|
+
}
|
|
8050
|
+
var TOKENS_COLLECT_TRUST_PATH = join2(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
8051
|
+
|
|
8052
|
+
// src/roles/contract.ts
|
|
8053
|
+
import matter3 from "gray-matter";
|
|
8054
|
+
|
|
8055
|
+
// src/commands/doctrine.ts
|
|
8056
|
+
var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
|
|
8057
|
+
function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
8058
|
+
return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
|
|
8059
|
+
}
|
|
8060
|
+
function gitToplevel(cwd) {
|
|
8061
|
+
try {
|
|
8062
|
+
return execFileSync3("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
8063
|
+
encoding: "utf8",
|
|
8064
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
8065
|
+
}).trim();
|
|
8066
|
+
} catch {
|
|
8067
|
+
return null;
|
|
8068
|
+
}
|
|
8069
|
+
}
|
|
8070
|
+
function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
8071
|
+
const toplevel = gitToplevel(cwd);
|
|
8072
|
+
if (toplevel !== null) {
|
|
8073
|
+
const treeRoot = join3(toplevel, "aeg-root");
|
|
8074
|
+
if (existsSync3(join3(treeRoot, "roles")))
|
|
8075
|
+
return { root: treeRoot, source: "tree" };
|
|
8076
|
+
}
|
|
8077
|
+
const fromSource = !pkg.split(sep).includes("node_modules");
|
|
8078
|
+
const bundleRoot = fromSource ? join3(dirname3(dirname3(pkg)), "aeg-root") : join3(pkg, "aeg-root");
|
|
8079
|
+
return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
|
|
8080
|
+
}
|
|
8081
|
+
function hasDoctrineEntry(root) {
|
|
8082
|
+
return existsSync3(join3(root, ...ENTRY_SEGMENTS));
|
|
8083
|
+
}
|
|
8084
|
+
|
|
8085
|
+
// src/checks/contract.ts
|
|
8086
|
+
var CHECK_SCHEMA_VERSION = 1;
|
|
8087
|
+
function emitCheckError(error) {
|
|
8088
|
+
process.stderr.write(`${JSON.stringify(error)}
|
|
8089
|
+
`);
|
|
8090
|
+
}
|
|
8091
|
+
|
|
8092
|
+
// src/lib/diff-evidence.ts
|
|
8093
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
8094
|
+
import { join as join9, relative as relative2, resolve as resolve2 } from "node:path";
|
|
8095
|
+
|
|
8096
|
+
// src/lib/brief-assembly.ts
|
|
7792
8097
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
8098
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
|
|
8099
|
+
import { join as join4 } from "node:path";
|
|
8100
|
+
|
|
8101
|
+
// src/checks/edge-resolve.ts
|
|
8102
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
7793
8103
|
var DIRECT_ISSUE_REF = /#(\d+)/;
|
|
7794
8104
|
var issueCache = new Map;
|
|
7795
8105
|
function fetchIssueState(num, repo) {
|
|
@@ -7798,7 +8108,7 @@ function fetchIssueState(num, repo) {
|
|
|
7798
8108
|
return issueCache.get(key) ?? null;
|
|
7799
8109
|
let out = null;
|
|
7800
8110
|
try {
|
|
7801
|
-
const raw =
|
|
8111
|
+
const raw = execFileSync4("gh", [
|
|
7802
8112
|
"issue",
|
|
7803
8113
|
"view",
|
|
7804
8114
|
String(num),
|
|
@@ -7912,7 +8222,7 @@ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief
|
|
|
7912
8222
|
var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
7913
8223
|
function git(args) {
|
|
7914
8224
|
try {
|
|
7915
|
-
return
|
|
8225
|
+
return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7916
8226
|
} catch {
|
|
7917
8227
|
return "";
|
|
7918
8228
|
}
|
|
@@ -7925,12 +8235,16 @@ function expandGlob(glob) {
|
|
|
7925
8235
|
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
7926
8236
|
|
|
7927
8237
|
// src/checks/registry.ts
|
|
7928
|
-
import {
|
|
7929
|
-
import {
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
8238
|
+
import { join as join5, relative, sep as sep2 } from "node:path";
|
|
8239
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8240
|
+
function resolveCheckBin(packageDir, moduleUrl) {
|
|
8241
|
+
const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
|
|
8242
|
+
const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep2}`);
|
|
8243
|
+
return bundled ? { dir: join5(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join5(packageDir, "src", "checks", "bin"), ext: ".ts" };
|
|
8244
|
+
}
|
|
8245
|
+
var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
|
|
8246
|
+
var BIN_DIR = CHECK_BIN.dir;
|
|
8247
|
+
var BIN_EXT = CHECK_BIN.ext;
|
|
7934
8248
|
function bin(name) {
|
|
7935
8249
|
return join5(BIN_DIR, `${name}${BIN_EXT}`);
|
|
7936
8250
|
}
|
|
@@ -7974,6 +8288,8 @@ var REGISTRY = [
|
|
|
7974
8288
|
timeoutMs: 15000,
|
|
7975
8289
|
env: {
|
|
7976
8290
|
BASE_SHA: { optional: true },
|
|
8291
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8292
|
+
VINAYA_COMMIT_HOOK: { optional: true },
|
|
7977
8293
|
PR_BODY: { optional: true },
|
|
7978
8294
|
PR_BODY_FILE: { optional: true },
|
|
7979
8295
|
PR_NUMBER: { optional: true },
|
|
@@ -8128,23 +8444,6 @@ var REGISTRY = [
|
|
|
8128
8444
|
},
|
|
8129
8445
|
1
|
|
8130
8446
|
],
|
|
8131
|
-
[
|
|
8132
|
-
{
|
|
8133
|
-
name: "token-report",
|
|
8134
|
-
validates: "body",
|
|
8135
|
-
run: bin("check-token-report"),
|
|
8136
|
-
scope: "diff",
|
|
8137
|
-
timeoutMs: 15000,
|
|
8138
|
-
requiresOpenPr: true,
|
|
8139
|
-
env: {
|
|
8140
|
-
PR_BODY: { optional: true },
|
|
8141
|
-
BRANCH: { optional: true },
|
|
8142
|
-
CLAUDE_PROJECT_DIR: { optional: true },
|
|
8143
|
-
CLAUDE_CODE_SESSION_ID: { optional: true }
|
|
8144
|
-
}
|
|
8145
|
-
},
|
|
8146
|
-
1
|
|
8147
|
-
],
|
|
8148
8447
|
[
|
|
8149
8448
|
{
|
|
8150
8449
|
name: "no-disk-state",
|
|
@@ -8494,23 +8793,35 @@ var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.na
|
|
|
8494
8793
|
import { execFile as execFile5 } from "node:child_process";
|
|
8495
8794
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
8496
8795
|
import {
|
|
8497
|
-
|
|
8498
|
-
|
|
8796
|
+
appendFileSync,
|
|
8797
|
+
closeSync as closeSync4,
|
|
8798
|
+
constants as fsConstants4,
|
|
8499
8799
|
existsSync as existsSync7,
|
|
8500
|
-
fstatSync as
|
|
8501
|
-
mkdirSync as
|
|
8502
|
-
|
|
8503
|
-
|
|
8800
|
+
fstatSync as fstatSync3,
|
|
8801
|
+
mkdirSync as mkdirSync4,
|
|
8802
|
+
lstatSync as lstatSync2,
|
|
8803
|
+
openSync as openSync4,
|
|
8804
|
+
readFileSync as readFileSync7,
|
|
8504
8805
|
renameSync as renameSync2,
|
|
8505
|
-
|
|
8806
|
+
writeFileSync as writeFileSync3,
|
|
8807
|
+
writeSync as writeSync3
|
|
8506
8808
|
} from "node:fs";
|
|
8507
8809
|
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
8508
|
-
import { dirname as
|
|
8810
|
+
import { dirname as dirname7, join as join8 } from "node:path";
|
|
8509
8811
|
import { promisify as promisify5 } from "node:util";
|
|
8510
8812
|
|
|
8511
8813
|
// src/lib/run-paths.ts
|
|
8512
|
-
import {
|
|
8814
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
8815
|
+
import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
8513
8816
|
import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
|
|
8817
|
+
var TASKS_EXECUTION_DIRNAME = "tasks-execution";
|
|
8818
|
+
var RUN_AREA_DIRNAMES = {
|
|
8819
|
+
control: CONTROL_AREA_DIRNAME,
|
|
8820
|
+
sessions: "sessions",
|
|
8821
|
+
hooks: "hooks",
|
|
8822
|
+
output: "output",
|
|
8823
|
+
rounds: "rounds"
|
|
8824
|
+
};
|
|
8514
8825
|
var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8515
8826
|
function isSafeRepoSegment(segment) {
|
|
8516
8827
|
return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
|
|
@@ -8541,12 +8852,52 @@ function isInsideRepo(candidate, repoRoot) {
|
|
|
8541
8852
|
const target = resolvePath(candidate);
|
|
8542
8853
|
return target === root || target.startsWith(`${root}/`);
|
|
8543
8854
|
}
|
|
8855
|
+
function runPath(runtimeDir, scope, location) {
|
|
8856
|
+
const dir = join6(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
|
|
8857
|
+
switch (location.area) {
|
|
8858
|
+
case "task":
|
|
8859
|
+
return location.file ? join6(dir, location.file) : dir;
|
|
8860
|
+
case "control": {
|
|
8861
|
+
const controlDir = join6(dir, RUN_AREA_DIRNAMES.control);
|
|
8862
|
+
return location.file ? join6(controlDir, location.file) : controlDir;
|
|
8863
|
+
}
|
|
8864
|
+
case "rounds":
|
|
8865
|
+
return join6(dir, RUN_AREA_DIRNAMES.rounds);
|
|
8866
|
+
case "round": {
|
|
8867
|
+
const roundDir = join6(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
|
|
8868
|
+
return location.file ? join6(roundDir, location.file) : roundDir;
|
|
8869
|
+
}
|
|
8870
|
+
case "developer": {
|
|
8871
|
+
const developerDir = join6(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
|
|
8872
|
+
return location.file ? join6(developerDir, location.file) : developerDir;
|
|
8873
|
+
}
|
|
8874
|
+
default: {
|
|
8875
|
+
const areaDir = join6(dir, RUN_AREA_DIRNAMES[location.area]);
|
|
8876
|
+
return location.file ? join6(areaDir, location.file) : areaDir;
|
|
8877
|
+
}
|
|
8878
|
+
}
|
|
8879
|
+
}
|
|
8880
|
+
function scopeSegment(scope) {
|
|
8881
|
+
if (scope === "unscoped")
|
|
8882
|
+
return "unscoped";
|
|
8883
|
+
if (typeof scope === "number")
|
|
8884
|
+
return String(scope);
|
|
8885
|
+
return `pr-${scope.pr}`;
|
|
8886
|
+
}
|
|
8544
8887
|
var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
|
|
8545
8888
|
var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
|
|
8546
8889
|
function isUnattendedProcess(env = process.env) {
|
|
8547
8890
|
return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
|
|
8548
8891
|
}
|
|
8549
8892
|
var memoized = null;
|
|
8893
|
+
function runtimeDirForRepo(repo) {
|
|
8894
|
+
const key = repoSegment(repo);
|
|
8895
|
+
if (memoized?.key === key)
|
|
8896
|
+
return memoized.value;
|
|
8897
|
+
const value = resolveRuntimeDirUncached(repo);
|
|
8898
|
+
memoized = { key, value };
|
|
8899
|
+
return value;
|
|
8900
|
+
}
|
|
8550
8901
|
async function runtimeDirForRepoAsync(repo) {
|
|
8551
8902
|
const key = repoSegment(repo);
|
|
8552
8903
|
if (memoized?.key === key)
|
|
@@ -8562,6 +8913,16 @@ async function runtimeDirForRepoAsync(repo) {
|
|
|
8562
8913
|
memoized = { key, value };
|
|
8563
8914
|
return value;
|
|
8564
8915
|
}
|
|
8916
|
+
function resolveRuntimeDirUncached(repo) {
|
|
8917
|
+
const inputs = runtimeDirInputs();
|
|
8918
|
+
if (typeof inputs === "string")
|
|
8919
|
+
return inputs;
|
|
8920
|
+
return resolveRuntimeDir({
|
|
8921
|
+
repo,
|
|
8922
|
+
...inputs.base,
|
|
8923
|
+
trustAnchorConfig: inputs.needsAnchor ? loadTrustAnchorConfig() : null
|
|
8924
|
+
});
|
|
8925
|
+
}
|
|
8565
8926
|
function runtimeDirInputs() {
|
|
8566
8927
|
const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
|
|
8567
8928
|
if (handedDown)
|
|
@@ -8581,7 +8942,7 @@ function repoRootSync(start = process.cwd()) {
|
|
|
8581
8942
|
return null;
|
|
8582
8943
|
}
|
|
8583
8944
|
for (;; ) {
|
|
8584
|
-
if (
|
|
8945
|
+
if (existsSync5(join6(dir, ".git")))
|
|
8585
8946
|
return dir;
|
|
8586
8947
|
const parent = dirname4(dir);
|
|
8587
8948
|
if (parent === dir)
|
|
@@ -8589,26 +8950,94 @@ function repoRootSync(start = process.cwd()) {
|
|
|
8589
8950
|
dir = parent;
|
|
8590
8951
|
}
|
|
8591
8952
|
}
|
|
8953
|
+
function resolveRepoSync() {
|
|
8954
|
+
const fromEnv = process.env.AEG_REPO;
|
|
8955
|
+
if (fromEnv) {
|
|
8956
|
+
const m = /^([^/]+)\/(.+)$/.exec(fromEnv);
|
|
8957
|
+
if (m?.[1] && m[2])
|
|
8958
|
+
return { owner: m[1], repo: m[2] };
|
|
8959
|
+
}
|
|
8960
|
+
let url;
|
|
8961
|
+
try {
|
|
8962
|
+
url = execFileSync6("git", ["remote", "get-url", "origin"], {
|
|
8963
|
+
encoding: "utf-8",
|
|
8964
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
8965
|
+
}).trim();
|
|
8966
|
+
} catch {
|
|
8967
|
+
return null;
|
|
8968
|
+
}
|
|
8969
|
+
const ssh = /^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/.exec(url);
|
|
8970
|
+
if (ssh?.[1] && ssh[2])
|
|
8971
|
+
return { owner: ssh[1], repo: ssh[2] };
|
|
8972
|
+
const https = /^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(url);
|
|
8973
|
+
if (https?.[1] && https[2])
|
|
8974
|
+
return { owner: https[1], repo: https[2] };
|
|
8975
|
+
return null;
|
|
8976
|
+
}
|
|
8977
|
+
var memoizedThisRepo = null;
|
|
8978
|
+
function runtimeDirForThisRepo() {
|
|
8979
|
+
if (memoizedThisRepo !== null)
|
|
8980
|
+
return memoizedThisRepo;
|
|
8981
|
+
memoizedThisRepo = runtimeDirForRepo(resolveRepoSync());
|
|
8982
|
+
return memoizedThisRepo;
|
|
8983
|
+
}
|
|
8592
8984
|
|
|
8593
|
-
// src/lib/log
|
|
8985
|
+
// src/lib/loop-log.ts
|
|
8594
8986
|
import {
|
|
8595
8987
|
closeSync as closeSync2,
|
|
8596
8988
|
constants as fsConstants2,
|
|
8597
|
-
|
|
8989
|
+
existsSync as existsSync6,
|
|
8990
|
+
fstatSync as fstatSync2,
|
|
8598
8991
|
mkdirSync as mkdirSync2,
|
|
8599
8992
|
openSync as openSync2,
|
|
8600
|
-
linkSync,
|
|
8601
8993
|
readFileSync as readFileSync5,
|
|
8602
|
-
|
|
8994
|
+
readSync,
|
|
8603
8995
|
statSync,
|
|
8996
|
+
writeSync
|
|
8997
|
+
} from "node:fs";
|
|
8998
|
+
import { dirname as dirname5 } from "node:path";
|
|
8999
|
+
function loopsRoot() {
|
|
9000
|
+
return runtimeDirForThisRepo();
|
|
9001
|
+
}
|
|
9002
|
+
function loopLogPathFor(_repo, issue, root = loopsRoot()) {
|
|
9003
|
+
return runPath(root, issue, { area: "output", file: "driver.log" });
|
|
9004
|
+
}
|
|
9005
|
+
var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
|
|
9006
|
+
function appendLoopLogLine(path, line) {
|
|
9007
|
+
try {
|
|
9008
|
+
mkdirSync2(dirname5(path), { recursive: true, mode: 448 });
|
|
9009
|
+
const fd = openSync2(path, fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW, 384);
|
|
9010
|
+
try {
|
|
9011
|
+
const stat = fstatSync2(fd);
|
|
9012
|
+
if (stat.isFile() && stat.size < LOOP_LOG_MAX_BYTES) {
|
|
9013
|
+
writeSync(fd, `${line}
|
|
9014
|
+
`);
|
|
9015
|
+
}
|
|
9016
|
+
} finally {
|
|
9017
|
+
closeSync2(fd);
|
|
9018
|
+
}
|
|
9019
|
+
} catch {}
|
|
9020
|
+
}
|
|
9021
|
+
|
|
9022
|
+
// src/lib/log-webhook-drain.ts
|
|
9023
|
+
import {
|
|
9024
|
+
closeSync as closeSync3,
|
|
9025
|
+
constants as fsConstants3,
|
|
9026
|
+
lstatSync,
|
|
9027
|
+
mkdirSync as mkdirSync3,
|
|
9028
|
+
openSync as openSync3,
|
|
9029
|
+
linkSync,
|
|
9030
|
+
readFileSync as readFileSync6,
|
|
9031
|
+
renameSync,
|
|
9032
|
+
statSync as statSync2,
|
|
8604
9033
|
unlinkSync,
|
|
8605
9034
|
utimesSync,
|
|
8606
9035
|
writeFileSync as writeFileSync2,
|
|
8607
|
-
writeSync
|
|
9036
|
+
writeSync as writeSync2
|
|
8608
9037
|
} from "node:fs";
|
|
8609
9038
|
import { randomUUID } from "node:crypto";
|
|
8610
9039
|
import { homedir as homedir2 } from "node:os";
|
|
8611
|
-
import { dirname as
|
|
9040
|
+
import { dirname as dirname6, join as join7 } from "node:path";
|
|
8612
9041
|
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
8613
9042
|
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
8614
9043
|
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
@@ -8624,13 +9053,13 @@ function isEnoent(err) {
|
|
|
8624
9053
|
var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
|
|
8625
9054
|
function tryCreateLock(lockPath, token) {
|
|
8626
9055
|
try {
|
|
8627
|
-
|
|
8628
|
-
const fd =
|
|
9056
|
+
mkdirSync3(dirname6(lockPath), { recursive: true, mode: 448 });
|
|
9057
|
+
const fd = openSync3(lockPath, fsConstants3.O_WRONLY | fsConstants3.O_CREAT | fsConstants3.O_EXCL, 384);
|
|
8629
9058
|
try {
|
|
8630
|
-
|
|
9059
|
+
writeSync2(fd, `${token}
|
|
8631
9060
|
`);
|
|
8632
9061
|
} finally {
|
|
8633
|
-
|
|
9062
|
+
closeSync3(fd);
|
|
8634
9063
|
}
|
|
8635
9064
|
return true;
|
|
8636
9065
|
} catch (err) {
|
|
@@ -8645,7 +9074,7 @@ function acquireDrainLock(lockPath) {
|
|
|
8645
9074
|
return token;
|
|
8646
9075
|
let observedMtimeMs;
|
|
8647
9076
|
try {
|
|
8648
|
-
observedMtimeMs =
|
|
9077
|
+
observedMtimeMs = statSync2(lockPath).mtimeMs;
|
|
8649
9078
|
} catch (err) {
|
|
8650
9079
|
if (!isEnoent(err))
|
|
8651
9080
|
throw err;
|
|
@@ -8663,7 +9092,7 @@ function acquireDrainLock(lockPath) {
|
|
|
8663
9092
|
}
|
|
8664
9093
|
let claimedMtimeMs = null;
|
|
8665
9094
|
try {
|
|
8666
|
-
claimedMtimeMs =
|
|
9095
|
+
claimedMtimeMs = statSync2(claimed).mtimeMs;
|
|
8667
9096
|
} catch (err) {
|
|
8668
9097
|
if (!isEnoent(err))
|
|
8669
9098
|
throw err;
|
|
@@ -8689,7 +9118,7 @@ function acquireDrainLock(lockPath) {
|
|
|
8689
9118
|
function renewDrainLock(lockPath, token) {
|
|
8690
9119
|
let holder;
|
|
8691
9120
|
try {
|
|
8692
|
-
holder =
|
|
9121
|
+
holder = readFileSync6(lockPath, "utf8").trim();
|
|
8693
9122
|
} catch (err) {
|
|
8694
9123
|
if (!isEnoent(err))
|
|
8695
9124
|
throw err;
|
|
@@ -8709,7 +9138,7 @@ function renewDrainLock(lockPath, token) {
|
|
|
8709
9138
|
}
|
|
8710
9139
|
function releaseDrainLock(lockPath, token) {
|
|
8711
9140
|
try {
|
|
8712
|
-
const holder =
|
|
9141
|
+
const holder = readFileSync6(lockPath, "utf8").trim();
|
|
8713
9142
|
if (holder !== token)
|
|
8714
9143
|
return;
|
|
8715
9144
|
unlinkSync(lockPath);
|
|
@@ -8759,7 +9188,7 @@ function queueLines(buf) {
|
|
|
8759
9188
|
return lines;
|
|
8760
9189
|
}
|
|
8761
9190
|
function removeQueueHead(path, cut) {
|
|
8762
|
-
const remaining =
|
|
9191
|
+
const remaining = readFileSync6(path);
|
|
8763
9192
|
writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
|
|
8764
9193
|
}
|
|
8765
9194
|
function queueBucketSize(path) {
|
|
@@ -8780,7 +9209,7 @@ function queueBucketSize(path) {
|
|
|
8780
9209
|
function readQueueFile(path) {
|
|
8781
9210
|
if (queueBucketSize(path) === null)
|
|
8782
9211
|
return null;
|
|
8783
|
-
return
|
|
9212
|
+
return readFileSync6(path);
|
|
8784
9213
|
}
|
|
8785
9214
|
function rejectLine(rejectedPath, reason, status, identity, raw) {
|
|
8786
9215
|
const record = JSON.stringify({
|
|
@@ -8962,13 +9391,19 @@ function logsCredentialMissing(headers, env) {
|
|
|
8962
9391
|
const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
8963
9392
|
for (const value of Object.values(headers)) {
|
|
8964
9393
|
for (const match of value.matchAll(varPattern)) {
|
|
8965
|
-
|
|
8966
|
-
|
|
9394
|
+
const name = match[1];
|
|
9395
|
+
if (env[name])
|
|
9396
|
+
continue;
|
|
9397
|
+
return true;
|
|
8967
9398
|
}
|
|
8968
9399
|
}
|
|
8969
9400
|
return false;
|
|
8970
9401
|
}
|
|
8971
9402
|
function resolveLogDestinationFrom(input) {
|
|
9403
|
+
const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
|
|
9404
|
+
if (spoolDir !== undefined && spoolDir.trim() !== "") {
|
|
9405
|
+
return { kind: "folder", folder: spoolDir };
|
|
9406
|
+
}
|
|
8972
9407
|
const local = resolveLogsSetting(input.localConfig);
|
|
8973
9408
|
let effective = null;
|
|
8974
9409
|
let fallbackReason;
|
|
@@ -9008,23 +9443,72 @@ function resolveLogDestinationFrom(input) {
|
|
|
9008
9443
|
const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
|
|
9009
9444
|
return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
|
|
9010
9445
|
}
|
|
9011
|
-
var
|
|
9012
|
-
function processTrustAnchor() {
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9446
|
+
var processTrustAnchorByRepo = new Map;
|
|
9447
|
+
function processTrustAnchor(repoRoot) {
|
|
9448
|
+
const cached = processTrustAnchorByRepo.get(repoRoot);
|
|
9449
|
+
if (cached !== undefined)
|
|
9450
|
+
return cached;
|
|
9451
|
+
const reading = safeLoadTrustAnchorConfig();
|
|
9452
|
+
processTrustAnchorByRepo.set(repoRoot, reading);
|
|
9453
|
+
return reading;
|
|
9016
9454
|
}
|
|
9017
9455
|
async function defaultResolveLogDestination(repo, env) {
|
|
9018
9456
|
const localConfig = loadConfig();
|
|
9019
9457
|
const unattended = isUnattendedProcess(process.env);
|
|
9458
|
+
const repoRoot = repoRootSync();
|
|
9020
9459
|
return resolveLogDestinationFrom({
|
|
9021
9460
|
localConfig,
|
|
9022
|
-
trustAnchorConfig: unattended ? await processTrustAnchor() : null,
|
|
9461
|
+
trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
|
|
9023
9462
|
unattended,
|
|
9024
9463
|
env,
|
|
9025
9464
|
defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
|
|
9026
|
-
repoRoot
|
|
9465
|
+
repoRoot
|
|
9466
|
+
});
|
|
9467
|
+
}
|
|
9468
|
+
function unresolvedLogDestination(env) {
|
|
9469
|
+
if (hostFromEnv(env) === "ci") {
|
|
9470
|
+
return {
|
|
9471
|
+
kind: "none",
|
|
9472
|
+
reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
|
|
9473
|
+
};
|
|
9474
|
+
}
|
|
9475
|
+
const loaded = loadConfig();
|
|
9476
|
+
const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
|
|
9477
|
+
const unattended = isUnattendedProcess(process.env);
|
|
9478
|
+
const repoRoot = repoRootSync();
|
|
9479
|
+
const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
|
|
9480
|
+
const defaultFolder = join8(runtimeDir, "logs");
|
|
9481
|
+
const resolved = resolveLogDestinationFrom({
|
|
9482
|
+
localConfig,
|
|
9483
|
+
trustAnchorConfig: null,
|
|
9484
|
+
unattended,
|
|
9485
|
+
env,
|
|
9486
|
+
defaultFolder,
|
|
9487
|
+
repoRoot
|
|
9027
9488
|
});
|
|
9489
|
+
return resolved.kind === "folder" ? resolved : { kind: "folder", folder: defaultFolder };
|
|
9490
|
+
}
|
|
9491
|
+
function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
|
|
9492
|
+
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
9493
|
+
return join8(stateRoot, "fallback", `${dirName}.json`);
|
|
9494
|
+
}
|
|
9495
|
+
function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
|
|
9496
|
+
const message = describeFolderFallback(reason);
|
|
9497
|
+
if (issue !== null) {
|
|
9498
|
+
appendLoopLogLine(loopLogPathFor(repo, issue, runtimeDir), `[log] ${message}`);
|
|
9499
|
+
}
|
|
9500
|
+
try {
|
|
9501
|
+
const record = {
|
|
9502
|
+
at: now.toISOString(),
|
|
9503
|
+
reason: message,
|
|
9504
|
+
intendedUrl: reason.intendedUrl,
|
|
9505
|
+
kind: reason.kind
|
|
9506
|
+
};
|
|
9507
|
+
const path = folderFallbackStatePath(repo, stateRoot);
|
|
9508
|
+
mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
|
|
9509
|
+
writeFileSync3(path, `${JSON.stringify(record)}
|
|
9510
|
+
`, { mode: 384 });
|
|
9511
|
+
} catch {}
|
|
9028
9512
|
}
|
|
9029
9513
|
function isEnoent2(err) {
|
|
9030
9514
|
return typeof err === "object" && err !== null && err.code === "ENOENT";
|
|
@@ -9138,7 +9622,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
|
|
|
9138
9622
|
}
|
|
9139
9623
|
function readVinayaVersion() {
|
|
9140
9624
|
try {
|
|
9141
|
-
const pkg = JSON.parse(
|
|
9625
|
+
const pkg = JSON.parse(readFileSync7(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
9142
9626
|
return pkg.version ?? "unknown";
|
|
9143
9627
|
} catch {
|
|
9144
9628
|
return "unknown";
|
|
@@ -9176,6 +9660,7 @@ function defaultStderr(message) {
|
|
|
9176
9660
|
}
|
|
9177
9661
|
var branchIssueFallbackEnabled = true;
|
|
9178
9662
|
var branchIssueByCwd = new Map;
|
|
9663
|
+
var branchIssueSettledByCwd = new Map;
|
|
9179
9664
|
function branchIssueRead(key, read, shared) {
|
|
9180
9665
|
if (!shared)
|
|
9181
9666
|
return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
@@ -9184,8 +9669,30 @@ function branchIssueRead(key, read, shared) {
|
|
|
9184
9669
|
return cached;
|
|
9185
9670
|
const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
9186
9671
|
branchIssueByCwd.set(key, reading);
|
|
9672
|
+
reading.then((value) => branchIssueSettledByCwd.set(key, value));
|
|
9673
|
+
return reading;
|
|
9674
|
+
}
|
|
9675
|
+
var headShaByCwd = new Map;
|
|
9676
|
+
var headShaSettledByCwd = new Map;
|
|
9677
|
+
function headShaRead(key, read, shared) {
|
|
9678
|
+
if (!shared)
|
|
9679
|
+
return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
9680
|
+
const cached = headShaByCwd.get(key);
|
|
9681
|
+
if (cached !== undefined)
|
|
9682
|
+
return cached;
|
|
9683
|
+
const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
9684
|
+
headShaByCwd.set(key, reading);
|
|
9685
|
+
reading.then((value) => headShaSettledByCwd.set(key, value));
|
|
9187
9686
|
return reading;
|
|
9188
9687
|
}
|
|
9688
|
+
async function resolveHeadSha(cwd) {
|
|
9689
|
+
try {
|
|
9690
|
+
const out = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8" })).stdout.trim();
|
|
9691
|
+
return /^[0-9a-f]{40}$/.test(out) ? out : null;
|
|
9692
|
+
} catch {
|
|
9693
|
+
return null;
|
|
9694
|
+
}
|
|
9695
|
+
}
|
|
9189
9696
|
function defaultDeps() {
|
|
9190
9697
|
return {
|
|
9191
9698
|
outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
|
|
@@ -9200,29 +9707,30 @@ function defaultDeps() {
|
|
|
9200
9707
|
inputVersions: () => {
|
|
9201
9708
|
return;
|
|
9202
9709
|
},
|
|
9203
|
-
resolveLogDestination: defaultResolveLogDestination
|
|
9710
|
+
resolveLogDestination: defaultResolveLogDestination,
|
|
9711
|
+
unresolvedLogDestination
|
|
9204
9712
|
};
|
|
9205
9713
|
}
|
|
9206
|
-
var APPEND_OPEN_FLAGS =
|
|
9714
|
+
var APPEND_OPEN_FLAGS = fsConstants4.O_WRONLY | fsConstants4.O_APPEND | fsConstants4.O_CREAT | fsConstants4.O_NOFOLLOW | fsConstants4.O_NONBLOCK;
|
|
9207
9715
|
function guardedAppendOpen(path) {
|
|
9208
9716
|
try {
|
|
9209
|
-
return
|
|
9717
|
+
return openSync4(path, APPEND_OPEN_FLAGS, 384);
|
|
9210
9718
|
} catch {
|
|
9211
9719
|
return;
|
|
9212
9720
|
}
|
|
9213
9721
|
}
|
|
9214
9722
|
function appendHardenedLine(path, line) {
|
|
9215
9723
|
try {
|
|
9216
|
-
|
|
9724
|
+
mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
|
|
9217
9725
|
const fd = guardedAppendOpen(path);
|
|
9218
9726
|
if (fd === undefined)
|
|
9219
9727
|
return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
|
|
9220
9728
|
try {
|
|
9221
|
-
if (!
|
|
9729
|
+
if (!fstatSync3(fd).isFile())
|
|
9222
9730
|
return `target is not a regular file: ${path}`;
|
|
9223
|
-
|
|
9731
|
+
writeSync3(fd, line);
|
|
9224
9732
|
} finally {
|
|
9225
|
-
|
|
9733
|
+
closeSync4(fd);
|
|
9226
9734
|
}
|
|
9227
9735
|
return null;
|
|
9228
9736
|
} catch (err) {
|
|
@@ -9232,7 +9740,7 @@ function appendHardenedLine(path, line) {
|
|
|
9232
9740
|
function reportRotationOverflow(backupPath, warn) {
|
|
9233
9741
|
let raw;
|
|
9234
9742
|
try {
|
|
9235
|
-
raw =
|
|
9743
|
+
raw = readFileSync7(backupPath, "utf8");
|
|
9236
9744
|
} catch {
|
|
9237
9745
|
return;
|
|
9238
9746
|
}
|
|
@@ -9255,7 +9763,7 @@ function reportRotationOverflow(backupPath, warn) {
|
|
|
9255
9763
|
}
|
|
9256
9764
|
function appendLine(path, line, warn) {
|
|
9257
9765
|
try {
|
|
9258
|
-
|
|
9766
|
+
mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
|
|
9259
9767
|
let fd = guardedAppendOpen(path);
|
|
9260
9768
|
if (fd === undefined) {
|
|
9261
9769
|
warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
|
|
@@ -9264,14 +9772,14 @@ function appendLine(path, line, warn) {
|
|
|
9264
9772
|
}
|
|
9265
9773
|
let closed = false;
|
|
9266
9774
|
try {
|
|
9267
|
-
const stat =
|
|
9775
|
+
const stat = fstatSync3(fd);
|
|
9268
9776
|
if (!stat.isFile()) {
|
|
9269
9777
|
warn(`vinaya: log outbox target is not a regular file — refusing to write: ${path}
|
|
9270
9778
|
`);
|
|
9271
9779
|
return;
|
|
9272
9780
|
}
|
|
9273
9781
|
if (stat.size > OUTBOX_MAX_BYTES) {
|
|
9274
|
-
|
|
9782
|
+
closeSync4(fd);
|
|
9275
9783
|
closed = true;
|
|
9276
9784
|
const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
|
|
9277
9785
|
reportRotationOverflow(backupPath, warn);
|
|
@@ -9285,10 +9793,10 @@ function appendLine(path, line, warn) {
|
|
|
9285
9793
|
fd = rotated;
|
|
9286
9794
|
closed = false;
|
|
9287
9795
|
}
|
|
9288
|
-
|
|
9796
|
+
writeSync3(fd, line);
|
|
9289
9797
|
} finally {
|
|
9290
9798
|
if (!closed)
|
|
9291
|
-
|
|
9799
|
+
closeSync4(fd);
|
|
9292
9800
|
}
|
|
9293
9801
|
} catch (err) {
|
|
9294
9802
|
warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
|
|
@@ -9299,12 +9807,14 @@ function createLogSink(overrides = {}) {
|
|
|
9299
9807
|
const deps = {
|
|
9300
9808
|
...defaultDeps(),
|
|
9301
9809
|
resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
|
|
9810
|
+
resolveHeadSha: () => resolveHeadSha(deps.cwd()),
|
|
9302
9811
|
...overrides
|
|
9303
9812
|
};
|
|
9304
9813
|
const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
|
|
9305
9814
|
const processId = randomUUID2();
|
|
9306
9815
|
let seq = 0;
|
|
9307
9816
|
let warned = false;
|
|
9817
|
+
let folderFallbackRecorded = false;
|
|
9308
9818
|
const warnOnce = (message) => {
|
|
9309
9819
|
if (warned)
|
|
9310
9820
|
return;
|
|
@@ -9322,6 +9832,7 @@ function createLogSink(overrides = {}) {
|
|
|
9322
9832
|
};
|
|
9323
9833
|
const readerIsReal = overrides.resolveBranchIssue === undefined;
|
|
9324
9834
|
let ownBranchIssue;
|
|
9835
|
+
let ownBranchIssueSettled = null;
|
|
9325
9836
|
const branchIssueOnce = (repo) => {
|
|
9326
9837
|
if (!branchIssueFallbackEnabled)
|
|
9327
9838
|
return Promise.resolve(null);
|
|
@@ -9329,10 +9840,36 @@ function createLogSink(overrides = {}) {
|
|
|
9329
9840
|
const read = () => deps.resolveBranchIssue(slug);
|
|
9330
9841
|
if (readerIsReal)
|
|
9331
9842
|
return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
|
|
9332
|
-
if (ownBranchIssue === undefined)
|
|
9843
|
+
if (ownBranchIssue === undefined) {
|
|
9333
9844
|
ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
|
|
9845
|
+
ownBranchIssue.then((value) => {
|
|
9846
|
+
ownBranchIssueSettled = value;
|
|
9847
|
+
});
|
|
9848
|
+
}
|
|
9334
9849
|
return ownBranchIssue;
|
|
9335
9850
|
};
|
|
9851
|
+
const branchIssueIfSettled = (repo) => {
|
|
9852
|
+
if (!branchIssueFallbackEnabled)
|
|
9853
|
+
return null;
|
|
9854
|
+
if (!readerIsReal)
|
|
9855
|
+
return ownBranchIssueSettled;
|
|
9856
|
+
return branchIssueSettledByCwd.get(`${deps.cwd()}\x00${safeRepoSlug(repo) ?? ""}`) ?? null;
|
|
9857
|
+
};
|
|
9858
|
+
const headShaReaderIsReal = overrides.resolveHeadSha === undefined;
|
|
9859
|
+
let ownHeadSha;
|
|
9860
|
+
let ownHeadShaSettled = null;
|
|
9861
|
+
const headShaOnce = () => {
|
|
9862
|
+
if (headShaReaderIsReal)
|
|
9863
|
+
return headShaRead(deps.cwd(), deps.resolveHeadSha, true);
|
|
9864
|
+
if (ownHeadSha === undefined) {
|
|
9865
|
+
ownHeadSha = headShaRead(deps.cwd(), deps.resolveHeadSha, false);
|
|
9866
|
+
ownHeadSha.then((value) => {
|
|
9867
|
+
ownHeadShaSettled = value;
|
|
9868
|
+
});
|
|
9869
|
+
}
|
|
9870
|
+
return ownHeadSha;
|
|
9871
|
+
};
|
|
9872
|
+
const headShaIfSettled = () => headShaReaderIsReal ? headShaSettledByCwd.get(deps.cwd()) ?? null : ownHeadShaSettled;
|
|
9336
9873
|
let resolveRepoCache;
|
|
9337
9874
|
const resolveRepoOnce = () => {
|
|
9338
9875
|
if (resolveRepoCache === undefined)
|
|
@@ -9340,6 +9877,7 @@ function createLogSink(overrides = {}) {
|
|
|
9340
9877
|
return resolveRepoCache;
|
|
9341
9878
|
};
|
|
9342
9879
|
let contextCache;
|
|
9880
|
+
let settledContext;
|
|
9343
9881
|
const context = () => {
|
|
9344
9882
|
if (contextCache === undefined) {
|
|
9345
9883
|
const env = deps.env();
|
|
@@ -9348,11 +9886,16 @@ function createLogSink(overrides = {}) {
|
|
|
9348
9886
|
doctrine()
|
|
9349
9887
|
]).then(async ([resolved, doctrineValue]) => {
|
|
9350
9888
|
const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
|
|
9351
|
-
|
|
9889
|
+
settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
|
|
9890
|
+
return settledContext;
|
|
9352
9891
|
});
|
|
9353
9892
|
}
|
|
9354
9893
|
return contextCache;
|
|
9355
9894
|
};
|
|
9895
|
+
const resetContext = () => {
|
|
9896
|
+
contextCache = undefined;
|
|
9897
|
+
settledContext = undefined;
|
|
9898
|
+
};
|
|
9356
9899
|
let drainChain = Promise.resolve();
|
|
9357
9900
|
const pendingWrites = new Set;
|
|
9358
9901
|
let writeChain = Promise.resolve();
|
|
@@ -9364,63 +9907,88 @@ function createLogSink(overrides = {}) {
|
|
|
9364
9907
|
`);
|
|
9365
9908
|
});
|
|
9366
9909
|
};
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9910
|
+
const snapshot = () => {
|
|
9911
|
+
const env = deps.env();
|
|
9912
|
+
return {
|
|
9913
|
+
host: hostFromEnv(env),
|
|
9914
|
+
now: deps.now(),
|
|
9915
|
+
seq: seq++,
|
|
9916
|
+
envFields: {
|
|
9374
9917
|
role: env.VINAYA_ROLE,
|
|
9375
9918
|
task: env.VINAYA_TASK,
|
|
9376
9919
|
round: env.VINAYA_ROUND,
|
|
9920
|
+
pr: env.VINAYA_PR,
|
|
9377
9921
|
run: env.VINAYA_RUN || runId,
|
|
9378
9922
|
attempt: env.VINAYA_ATTEMPT,
|
|
9379
|
-
parent: env.VINAYA_PARENT_EVENT
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9923
|
+
parent: env.VINAYA_PARENT_EVENT,
|
|
9924
|
+
workRef: env.VINAYA_WORK_REF,
|
|
9925
|
+
flow: env.VINAYA_FLOW,
|
|
9926
|
+
flowVersion: env.VINAYA_FLOW_VERSION,
|
|
9927
|
+
runtime: env.VINAYA_RUNTIME,
|
|
9928
|
+
source: env.VINAYA_SOURCE
|
|
9929
|
+
}
|
|
9930
|
+
};
|
|
9931
|
+
};
|
|
9932
|
+
const writeEvent = (e, call, ctx, branchIssue, headSha, deliver) => {
|
|
9933
|
+
const { repo, doctrine: doctrineValue, destination } = ctx;
|
|
9934
|
+
if (destination.kind === "none") {
|
|
9935
|
+
warnOnce(`vinaya: not recording — ${destination.reason}
|
|
9385
9936
|
`);
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9937
|
+
return;
|
|
9938
|
+
}
|
|
9939
|
+
if (destination.kind === "folder" && destination.fallbackReason) {
|
|
9940
|
+
warnOnce(`vinaya: ${describeFolderFallback(destination.fallbackReason)}
|
|
9390
9941
|
`);
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9942
|
+
}
|
|
9943
|
+
const built = buildHeader({
|
|
9944
|
+
now: call.now,
|
|
9945
|
+
runId,
|
|
9946
|
+
seq: call.seq,
|
|
9947
|
+
repo: repo ? `${repo.owner}/${repo.repo}` : null,
|
|
9948
|
+
vinaya: deps.vinayaVersion(),
|
|
9949
|
+
doctrine: doctrineValue,
|
|
9950
|
+
host: call.host,
|
|
9951
|
+
hostname: deps.hostname(),
|
|
9952
|
+
env: call.envFields,
|
|
9953
|
+
branchIssue,
|
|
9954
|
+
eventId: randomUUID2(),
|
|
9955
|
+
processId,
|
|
9956
|
+
inputVersions: deps.inputVersions()
|
|
9957
|
+
});
|
|
9958
|
+
const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
|
|
9959
|
+
if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
|
|
9960
|
+
folderFallbackRecorded = true;
|
|
9961
|
+
recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder), join8(deps.home(), ".vinaya"));
|
|
9962
|
+
}
|
|
9963
|
+
const full = { ...e, ...header };
|
|
9964
|
+
const parsed = LogEventSchema.safeParse(full);
|
|
9965
|
+
if (!parsed.success) {
|
|
9966
|
+
warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
|
|
9412
9967
|
`);
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9968
|
+
return;
|
|
9969
|
+
}
|
|
9970
|
+
const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
|
|
9416
9971
|
`;
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9972
|
+
if (destination.kind === "server") {
|
|
9973
|
+
appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
|
|
9974
|
+
if (deliver)
|
|
9975
|
+
scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
|
|
9976
|
+
} else {
|
|
9977
|
+
appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
|
|
9978
|
+
}
|
|
9979
|
+
};
|
|
9980
|
+
function log(e) {
|
|
9981
|
+
try {
|
|
9982
|
+
const call = snapshot();
|
|
9983
|
+
const write = async () => {
|
|
9984
|
+
const ctx = await context();
|
|
9985
|
+
if (ctx.destination.kind === "none") {
|
|
9986
|
+
writeEvent(e, call, ctx, null, null, true);
|
|
9987
|
+
return;
|
|
9423
9988
|
}
|
|
9989
|
+
const branchIssue = call.envFields.task ? null : await branchIssueOnce(ctx.repo);
|
|
9990
|
+
const headSha = e.kind === "gate" ? await headShaOnce() : null;
|
|
9991
|
+
writeEvent(e, call, ctx, branchIssue, headSha, true);
|
|
9424
9992
|
};
|
|
9425
9993
|
const written = writeChain.then(write).catch((err) => {
|
|
9426
9994
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
@@ -9431,6 +9999,26 @@ function createLogSink(overrides = {}) {
|
|
|
9431
9999
|
written.finally(() => pendingWrites.delete(written));
|
|
9432
10000
|
} catch (err) {
|
|
9433
10001
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
10002
|
+
`);
|
|
10003
|
+
}
|
|
10004
|
+
}
|
|
10005
|
+
function logSync(e, opts = {}) {
|
|
10006
|
+
try {
|
|
10007
|
+
const call = snapshot();
|
|
10008
|
+
let ctx = settledContext;
|
|
10009
|
+
if (ctx === undefined) {
|
|
10010
|
+
const destination = deps.unresolvedLogDestination(deps.env());
|
|
10011
|
+
if (destination.kind === "folder" && !opts.quiet) {
|
|
10012
|
+
warnOnce(`vinaya: the process ended before its log destination was resolved — the event is written to ${destination.folder}; \`vinaya log send\` delivers it to a configured server later
|
|
10013
|
+
`);
|
|
10014
|
+
}
|
|
10015
|
+
ctx = { repo: null, doctrine: "unknown", destination };
|
|
10016
|
+
}
|
|
10017
|
+
const branchIssue = ctx.destination.kind === "none" || call.envFields.task ? null : branchIssueIfSettled(ctx.repo);
|
|
10018
|
+
const headSha = e.kind === "gate" && ctx.destination.kind !== "none" ? headShaIfSettled() : null;
|
|
10019
|
+
writeEvent(e, call, ctx, branchIssue, headSha, false);
|
|
10020
|
+
} catch (err) {
|
|
10021
|
+
warnOnce(`vinaya: logSync() failed — ${err instanceof Error ? err.message : String(err)}
|
|
9434
10022
|
`);
|
|
9435
10023
|
}
|
|
9436
10024
|
}
|
|
@@ -9451,7 +10039,7 @@ function createLogSink(overrides = {}) {
|
|
|
9451
10039
|
return;
|
|
9452
10040
|
});
|
|
9453
10041
|
};
|
|
9454
|
-
return { log, runId, warmup, drain };
|
|
10042
|
+
return { log, logSync, runId, warmup, drain, resetContext };
|
|
9455
10043
|
}
|
|
9456
10044
|
var defaultSink = createLogSink();
|
|
9457
10045
|
|
|
@@ -9577,7 +10165,7 @@ function findingsInThisDiff(findings) {
|
|
|
9577
10165
|
const abs = resolve2(diff.root, f.file);
|
|
9578
10166
|
if (!changed.has(abs))
|
|
9579
10167
|
return false;
|
|
9580
|
-
const relPath =
|
|
10168
|
+
const relPath = relative2(diff.root, abs);
|
|
9581
10169
|
if (!ranges.has(relPath))
|
|
9582
10170
|
ranges.set(relPath, changedLineRanges(diff.base, relPath));
|
|
9583
10171
|
const fileRanges = ranges.get(relPath) ?? null;
|
|
@@ -9614,7 +10202,7 @@ function collect(dir, out = []) {
|
|
|
9614
10202
|
const full = join10(dir, name);
|
|
9615
10203
|
let isDir;
|
|
9616
10204
|
try {
|
|
9617
|
-
isDir =
|
|
10205
|
+
isDir = statSync3(full).isDirectory();
|
|
9618
10206
|
} catch {
|
|
9619
10207
|
continue;
|
|
9620
10208
|
}
|
|
@@ -9629,7 +10217,7 @@ function collect(dir, out = []) {
|
|
|
9629
10217
|
return out;
|
|
9630
10218
|
}
|
|
9631
10219
|
function readAll(paths) {
|
|
9632
|
-
return paths.map((p) => ({ path: p, content:
|
|
10220
|
+
return paths.map((p) => ({ path: p, content: readFileSync8(p, "utf8") }));
|
|
9633
10221
|
}
|
|
9634
10222
|
function main() {
|
|
9635
10223
|
if (DOCTRINE_ROOT === null) {
|