@attalabs/vinaya 0.35.0 → 0.37.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 +9 -10
- package/aeg-root/process.md +3 -1
- package/aeg-root/roles/archivist.md +2 -2
- package/aeg-root/roles/developer/reference.md +13 -16
- package/aeg-root/roles/developer.md +7 -3
- package/aeg-root/roles/operator.md +18 -18
- package/aeg-root/roles/planner/reference.md +23 -8
- package/aeg-root/roles/planner.md +2 -0
- package/aeg-root/roles/principal.md +6 -1
- package/aeg-root/roles/reviewer.md +11 -3
- package/aeg-root/roles/security.md +19 -9
- package/aeg-root/roles/tranche-archivist.md +14 -2
- package/aeg-root/state-machine.md +11 -10
- package/aeg-root/templates/brief-template.md +10 -4
- package/aeg-root/templates/pr-report-template.md +1 -9
- package/aeg-root/tranche-model.md +4 -4
- package/dist/checks/bin/check-body-bare-digits.js +2081 -1883
- package/dist/checks/bin/check-branch-topology.js +1376 -1139
- package/dist/checks/bin/check-brief-shape.js +2081 -1883
- package/dist/checks/bin/check-changeset-coverage.js +2564 -2025
- package/dist/checks/bin/check-closes-n.js +1376 -1139
- package/dist/checks/bin/check-coherence.js +1480 -1228
- package/dist/checks/bin/check-dead-branch-push.js +1339 -1156
- package/dist/checks/bin/check-dispatch-readiness.js +1480 -1228
- package/dist/checks/bin/check-doc-coverage-push.js +2563 -2024
- package/dist/checks/bin/check-doc-coverage.js +2565 -2026
- package/dist/checks/bin/check-doctrine-no-procedures.js +2081 -1883
- package/dist/checks/bin/check-doctrine-portability.js +2563 -2024
- package/dist/checks/bin/check-evidence-fresh.js +1906 -1536
- package/dist/checks/bin/check-exec-bits.js +2136 -1597
- package/dist/checks/bin/check-first-push-dispatch.js +1480 -1228
- package/dist/checks/bin/check-issue-assignment.js +1376 -1139
- package/dist/checks/bin/check-issue-milestone-attach.js +1339 -1156
- package/dist/checks/bin/check-issue-objectives-numbering.js +2081 -1883
- package/dist/checks/bin/check-issue-parts-coverage.js +1339 -1156
- package/dist/checks/bin/check-issue-surface-globs.js +1488 -1227
- package/dist/checks/bin/check-issue-title-grammar.js +1339 -1156
- package/dist/checks/bin/check-issue-tranche-label.js +1339 -1156
- package/dist/checks/bin/check-main-branch-refusal.js +1342 -1159
- package/dist/checks/bin/check-no-disk-state.js +1342 -1159
- package/dist/checks/bin/check-pr-premise-reassert.js +2081 -1883
- package/dist/checks/bin/check-pr-report-density.js +1342 -1159
- package/dist/checks/bin/check-principal-test-plan-wait.js +1342 -1159
- package/dist/checks/bin/check-quoted-command.js +4063 -3526
- package/dist/checks/bin/check-reader-resolvable-prose.js +4082 -3533
- package/dist/checks/bin/check-registry-gates.js +1363 -1167
- package/dist/checks/bin/check-retired-vocabulary.js +4057 -3520
- package/dist/checks/bin/check-review-gate.js +2081 -1883
- package/dist/checks/bin/check-single-plan-pr.js +1339 -1156
- package/dist/checks/bin/check-surface-scope.js +1376 -1139
- package/dist/checks/bin/check-test-plan.js +1339 -1156
- package/dist/checks/bin/check-token-collection-wired.js +1342 -1159
- package/dist/checks/bin/check-token-report.js +1409 -1342
- package/dist/checks/bin/check-workspace-escape.js +2562 -2023
- package/dist/index.js +14171 -6490
- package/dist/lib/pre-push-cache-test-run.js +1044 -641
- package/dist/lib/pre-push-select-tests.js +641 -444
- package/package.json +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +38 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +19 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +257 -10
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +2 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +69 -11
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +139 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +32 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +27 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +757 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +8 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +52 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +163 -21
- 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.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]__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]__0zc_0gx._.js → [root-of-the-server]__14ui9sz._.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/0vtfb0g813gki.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/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/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/{3ip5z3cf43bgo.js → 3l56x8wjdzvaw.js} +5 -5
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3m310lbjj4p5u.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3goaig_rysc6p.js → 3qtt1v3ya-ofe.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
- package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/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/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/3u9emqjwpd0t9.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/{ca66rAHI_w9D7S7ceXDvR → yR5RsCxb1OGnYggiaO09S}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{ca66rAHI_w9D7S7ceXDvR → yR5RsCxb1OGnYggiaO09S}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{ca66rAHI_w9D7S7ceXDvR → yR5RsCxb1OGnYggiaO09S}/_ssgManifest.js +0 -0
|
@@ -1885,45 +1885,6 @@ var DERIVED_STATUSES = [
|
|
|
1885
1885
|
"incoherent"
|
|
1886
1886
|
];
|
|
1887
1887
|
var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
1888
|
-
// ../../packages/aeg-core/src/parse-ledger.ts
|
|
1889
|
-
function rowFromCells(cells) {
|
|
1890
|
-
if (cells.length < 7)
|
|
1891
|
-
return null;
|
|
1892
|
-
const phase = (cells[0] ?? "").trim();
|
|
1893
|
-
if (!phase)
|
|
1894
|
-
return null;
|
|
1895
|
-
return {
|
|
1896
|
-
phase,
|
|
1897
|
-
role: (cells[1] ?? "").trim(),
|
|
1898
|
-
agentModel: (cells[2] ?? "").trim(),
|
|
1899
|
-
tokensIn: parseIntCell(cells[3] ?? ""),
|
|
1900
|
-
tokensOut: parseIntCell(cells[4] ?? ""),
|
|
1901
|
-
cost: parseCostCell(cells[5] ?? ""),
|
|
1902
|
-
date: (cells[6] ?? "").trim()
|
|
1903
|
-
};
|
|
1904
|
-
}
|
|
1905
|
-
function parseIntCell(cell) {
|
|
1906
|
-
const trimmed = cell.replace(/`/g, "").trim();
|
|
1907
|
-
if (!trimmed || isEmDashOrDash(trimmed))
|
|
1908
|
-
return null;
|
|
1909
|
-
const normalized = trimmed.replace(/[,_\s]/g, "");
|
|
1910
|
-
if (!/^-?\d+$/.test(normalized))
|
|
1911
|
-
return null;
|
|
1912
|
-
return Number(normalized);
|
|
1913
|
-
}
|
|
1914
|
-
function parseCostCell(cell) {
|
|
1915
|
-
const trimmed = cell.replace(/`/g, "").trim();
|
|
1916
|
-
if (!trimmed || isEmDashOrDash(trimmed))
|
|
1917
|
-
return null;
|
|
1918
|
-
const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
|
|
1919
|
-
if (!/^-?\d+(\.\d+)?$/.test(normalized))
|
|
1920
|
-
return null;
|
|
1921
|
-
return Number(normalized);
|
|
1922
|
-
}
|
|
1923
|
-
function isEmDashOrDash(s) {
|
|
1924
|
-
const t = s.trim();
|
|
1925
|
-
return t === "—" || t === "-" || t === "–";
|
|
1926
|
-
}
|
|
1927
1888
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1928
1889
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1929
1890
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
@@ -1939,61 +1900,6 @@ function isWaiverLabelActorVerified(opts) {
|
|
|
1939
1900
|
return false;
|
|
1940
1901
|
return isPrincipal(opts.labelActor, opts.principalAllowlist);
|
|
1941
1902
|
}
|
|
1942
|
-
|
|
1943
|
-
// ../../packages/aeg-core/src/parse-token-report.ts
|
|
1944
|
-
var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
|
|
1945
|
-
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;
|
|
1946
|
-
function parseTokenReportEntries(body) {
|
|
1947
|
-
const lines = body.split(/\r?\n/);
|
|
1948
|
-
const headingIdxs = [];
|
|
1949
|
-
lines.forEach((line, i) => {
|
|
1950
|
-
if (TOKEN_REPORT_HEADING.test(line))
|
|
1951
|
-
headingIdxs.push(i);
|
|
1952
|
-
});
|
|
1953
|
-
const out = [];
|
|
1954
|
-
for (let h = 0;h < headingIdxs.length; h++) {
|
|
1955
|
-
const start = headingIdxs[h] + 1;
|
|
1956
|
-
const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
|
|
1957
|
-
const section = lines.slice(start, end).join(`
|
|
1958
|
-
`);
|
|
1959
|
-
const tableRows = parseTableSection(section);
|
|
1960
|
-
if (tableRows.length > 0) {
|
|
1961
|
-
out.push(...tableRows);
|
|
1962
|
-
continue;
|
|
1963
|
-
}
|
|
1964
|
-
const inlineRow = parseInlineFieldList(section);
|
|
1965
|
-
if (inlineRow)
|
|
1966
|
-
out.push(inlineRow);
|
|
1967
|
-
}
|
|
1968
|
-
return out;
|
|
1969
|
-
}
|
|
1970
|
-
function parseTableSection(section) {
|
|
1971
|
-
const lines = section.split(/\r?\n/);
|
|
1972
|
-
let i = 0;
|
|
1973
|
-
for (;i < lines.length; i++) {
|
|
1974
|
-
if ((lines[i] ?? "").trim().startsWith("|"))
|
|
1975
|
-
break;
|
|
1976
|
-
}
|
|
1977
|
-
if (i + 1 >= lines.length)
|
|
1978
|
-
return [];
|
|
1979
|
-
i += 2;
|
|
1980
|
-
const out = [];
|
|
1981
|
-
for (;i < lines.length; i++) {
|
|
1982
|
-
const trimmed = (lines[i] ?? "").trim();
|
|
1983
|
-
if (!trimmed.startsWith("|"))
|
|
1984
|
-
break;
|
|
1985
|
-
const row = rowFromCells(splitTableRow(trimmed));
|
|
1986
|
-
if (row)
|
|
1987
|
-
out.push(row);
|
|
1988
|
-
}
|
|
1989
|
-
return out;
|
|
1990
|
-
}
|
|
1991
|
-
function parseInlineFieldList(section) {
|
|
1992
|
-
const m = section.match(INLINE_FIELD_LIST);
|
|
1993
|
-
if (!m)
|
|
1994
|
-
return null;
|
|
1995
|
-
return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
|
|
1996
|
-
}
|
|
1997
1903
|
// ../../packages/aeg-core/src/verdict-extraction.ts
|
|
1998
1904
|
var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
1999
1905
|
var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
@@ -2442,10 +2348,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
|
|
|
2442
2348
|
var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
|
|
2443
2349
|
var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
|
|
2444
2350
|
var DEFAULT_MAX_ROUNDS = 3;
|
|
2351
|
+
var DEFAULT_MAX_TASK_MINUTES = 180;
|
|
2445
2352
|
var DEFAULT_REVIEW_POLICY = {
|
|
2446
2353
|
codeReviewThreshold: "BLOCKER",
|
|
2447
2354
|
securityThreshold: "HIGH",
|
|
2448
|
-
maxRounds: DEFAULT_MAX_ROUNDS
|
|
2355
|
+
maxRounds: DEFAULT_MAX_ROUNDS,
|
|
2356
|
+
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
|
|
2449
2357
|
};
|
|
2450
2358
|
var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
|
|
2451
2359
|
var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
|
|
@@ -2465,16 +2373,42 @@ function blockingSeverities(scale, threshold) {
|
|
|
2465
2373
|
}
|
|
2466
2374
|
return scale.slice(0, idx + 1);
|
|
2467
2375
|
}
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
}
|
|
2477
|
-
|
|
2376
|
+
var DEFERRAL_REASON_TEXT = {
|
|
2377
|
+
"unchanged-line": "unchanged line",
|
|
2378
|
+
"outside-surface": "outside the Surface"
|
|
2379
|
+
};
|
|
2380
|
+
var SECURITY_HIGH_AND_ABOVE = blockingSeverities(SECURITY_SEVERITY_ORDER, "HIGH");
|
|
2381
|
+
function classifyFinding(finding, scale, threshold, context = {}) {
|
|
2382
|
+
if (!scale.includes(finding.severity)) {
|
|
2383
|
+
throw new Error(`classifyFinding: severity "${finding.severity}" is not one of ${scale.join(" > ")}`);
|
|
2384
|
+
}
|
|
2385
|
+
const location = finding.location;
|
|
2386
|
+
const effectiveSeverity = location !== undefined && isProseLocation(location) ? PROSE_CAP_SEVERITY : finding.severity;
|
|
2387
|
+
const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
|
|
2388
|
+
if (!wouldBlock)
|
|
2389
|
+
return { outcome: "non_blocking", deferralReason: null };
|
|
2390
|
+
const hasLocation = location !== undefined && location.length > 0;
|
|
2391
|
+
if (hasLocation && context.inSurface && !context.inSurface(location)) {
|
|
2392
|
+
return { outcome: "deferred", deferralReason: "outside-surface" };
|
|
2393
|
+
}
|
|
2394
|
+
if (hasLocation && context.changedLine && !SECURITY_HIGH_AND_ABOVE.includes(effectiveSeverity)) {
|
|
2395
|
+
if (!context.changedLine(location)) {
|
|
2396
|
+
return { outcome: "deferred", deferralReason: "unchanged-line" };
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
return { outcome: "blocking", deferralReason: null };
|
|
2400
|
+
}
|
|
2401
|
+
function evaluateReviewFindings(findings, scale, threshold, context = {}) {
|
|
2402
|
+
const blockingFindings = [];
|
|
2403
|
+
const deferredFindings = [];
|
|
2404
|
+
for (const f of findings) {
|
|
2405
|
+
const c = classifyFinding(f, scale, threshold, context);
|
|
2406
|
+
if (c.outcome === "blocking")
|
|
2407
|
+
blockingFindings.push(f);
|
|
2408
|
+
else if (c.outcome === "deferred")
|
|
2409
|
+
deferredFindings.push({ finding: f, reason: c.deferralReason });
|
|
2410
|
+
}
|
|
2411
|
+
return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings, deferredFindings };
|
|
2478
2412
|
}
|
|
2479
2413
|
function isConsequentialFinding(finding) {
|
|
2480
2414
|
return finding.state !== "resolved";
|
|
@@ -2482,11 +2416,11 @@ function isConsequentialFinding(finding) {
|
|
|
2482
2416
|
function consequentialFindings(findings) {
|
|
2483
2417
|
return findings.filter((f) => isConsequentialFinding(f));
|
|
2484
2418
|
}
|
|
2485
|
-
function evaluateCodeReview(findings, policy) {
|
|
2486
|
-
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
|
|
2419
|
+
function evaluateCodeReview(findings, policy, context = {}) {
|
|
2420
|
+
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold, context);
|
|
2487
2421
|
}
|
|
2488
|
-
function evaluateSecurityReview(findings, policy) {
|
|
2489
|
-
return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold);
|
|
2422
|
+
function evaluateSecurityReview(findings, policy, context = {}) {
|
|
2423
|
+
return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold, context);
|
|
2490
2424
|
}
|
|
2491
2425
|
function isKnownSeverity(scale, value) {
|
|
2492
2426
|
return scale.includes(value);
|
|
@@ -2820,11 +2754,13 @@ function checkDocUpdateList(prBody) {
|
|
|
2820
2754
|
return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
|
|
2821
2755
|
}
|
|
2822
2756
|
function checkWorktreeStep0(prBody) {
|
|
2823
|
-
if (/git worktree add/.test(prBody))
|
|
2757
|
+
if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
|
|
2824
2758
|
return { status: "pass", errors: [] };
|
|
2825
2759
|
return {
|
|
2826
2760
|
status: "fail",
|
|
2827
|
-
errors: [
|
|
2761
|
+
errors: [
|
|
2762
|
+
"brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
|
|
2763
|
+
]
|
|
2828
2764
|
};
|
|
2829
2765
|
}
|
|
2830
2766
|
function checkStopConditions(prBody) {
|
|
@@ -3014,7 +2950,8 @@ function isCommandBlock(content) {
|
|
|
3014
2950
|
return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
|
|
3015
2951
|
}
|
|
3016
2952
|
function isStep0Block(content) {
|
|
3017
|
-
|
|
2953
|
+
const first = firstNonBlankLine(content);
|
|
2954
|
+
return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
|
|
3018
2955
|
}
|
|
3019
2956
|
function checkCommandsCarryOutput(prBody) {
|
|
3020
2957
|
const errors = [];
|
|
@@ -3400,161 +3337,592 @@ function checkPrReportDensity(prBody) {
|
|
|
3400
3337
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3401
3338
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3402
3339
|
}
|
|
3403
|
-
// ../../packages/aeg-core/src/
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
{ name: "Sizing", pattern: "Sizing" },
|
|
3411
|
-
{ name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
|
|
3412
|
-
{ name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
|
|
3413
|
-
{ name: "Traps to avoid", pattern: "Traps" },
|
|
3414
|
-
{ name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
|
|
3415
|
-
{ name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
|
|
3416
|
-
{ name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
|
|
3340
|
+
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3341
|
+
var PRODUCT_SLUG_SCOPE = [
|
|
3342
|
+
"apps/cli/src",
|
|
3343
|
+
".github/workflows",
|
|
3344
|
+
".vinaya",
|
|
3345
|
+
"apps/cli/README.md",
|
|
3346
|
+
"packages/sources/README.md"
|
|
3417
3347
|
];
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
const errors = [];
|
|
3421
|
-
for (const f of RATIONALE_FIELDS) {
|
|
3422
|
-
if (!hasRationaleField(body, f.pattern)) {
|
|
3423
|
-
errors.push(`issue-validation ${f.name}: rationale field not found in the Issue body — every task Issue carries the full Planner's rationale (aeg-root/contracts/planner-brief.md).`);
|
|
3424
|
-
continue;
|
|
3425
|
-
}
|
|
3426
|
-
if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
|
|
3427
|
-
errors.push(`issue-validation ${f.name}: rationale field found, but not in the form amend-deps requires — ` + "write `**Dependency rationale** — …`, not `**Dependency rationale:** …`. " + "`amendRationaleDeps` (the only sanctioned way to edit Depends-on/Conflicts-with) locates this " + "section by the exact anchor `**Dependency rationale**`; a colon inside the bold breaks that match " + "and the Issue becomes unamendable.");
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3431
|
-
}
|
|
3432
|
-
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3433
|
-
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3434
|
-
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3435
|
-
return { status: "pass", errors: [] };
|
|
3436
|
-
const result = objectivesOf(body);
|
|
3437
|
-
if (result.ok)
|
|
3438
|
-
return { status: "pass", errors: [] };
|
|
3439
|
-
return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
|
|
3348
|
+
function isUnderOrEqual(path, prefix) {
|
|
3349
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3440
3350
|
}
|
|
3441
|
-
function
|
|
3442
|
-
|
|
3443
|
-
const heading = headingRe.exec(body);
|
|
3444
|
-
if (!heading)
|
|
3445
|
-
return null;
|
|
3446
|
-
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
3447
|
-
const next = /^##[ \t]/m.exec(afterHeading);
|
|
3448
|
-
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
3351
|
+
function isProductScopeFile(path) {
|
|
3352
|
+
return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
|
|
3449
3353
|
}
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
const start = text.indexOf("`", i);
|
|
3454
|
-
if (start === -1)
|
|
3455
|
-
return false;
|
|
3456
|
-
const end = text.indexOf("`", start + 1);
|
|
3457
|
-
if (end === -1)
|
|
3458
|
-
return false;
|
|
3459
|
-
if (text.slice(start + 1, end).includes("/"))
|
|
3460
|
-
return true;
|
|
3461
|
-
i = end + 1;
|
|
3462
|
-
}
|
|
3463
|
-
return false;
|
|
3354
|
+
var SHIPS_PREFIX = "aeg-root/";
|
|
3355
|
+
function shipsArchivePrefix(shipsPrefix) {
|
|
3356
|
+
return `${shipsPrefix}tranches/completed/`;
|
|
3464
3357
|
}
|
|
3465
|
-
var
|
|
3466
|
-
function
|
|
3467
|
-
|
|
3358
|
+
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3359
|
+
function normalizeSpecPath(entry) {
|
|
3360
|
+
let out = entry.replace(/\\/g, "/");
|
|
3361
|
+
while (out.startsWith("./"))
|
|
3362
|
+
out = out.slice(2);
|
|
3363
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3364
|
+
while (out.endsWith("/"))
|
|
3365
|
+
out = out.slice(0, -1);
|
|
3366
|
+
return out;
|
|
3468
3367
|
}
|
|
3469
|
-
function
|
|
3470
|
-
|
|
3368
|
+
function isSpecFile2(path, specPaths) {
|
|
3369
|
+
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
3370
|
+
return true;
|
|
3371
|
+
if (!path.endsWith(".md"))
|
|
3372
|
+
return false;
|
|
3373
|
+
return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
|
|
3471
3374
|
}
|
|
3472
|
-
function
|
|
3473
|
-
|
|
3474
|
-
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3475
|
-
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3476
|
-
return extMatch !== null && extMatch.index > 0;
|
|
3375
|
+
function isClaudeMdFile(path) {
|
|
3376
|
+
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3477
3377
|
}
|
|
3478
|
-
function
|
|
3479
|
-
|
|
3378
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
3379
|
+
if (path.startsWith(shipsPrefix)) {
|
|
3380
|
+
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3381
|
+
}
|
|
3382
|
+
if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
|
|
3383
|
+
return "reader-facing";
|
|
3384
|
+
}
|
|
3385
|
+
if (isClaudeMdFile(path))
|
|
3386
|
+
return "internal";
|
|
3387
|
+
if (isSpecFile2(path, specPaths))
|
|
3388
|
+
return "spec";
|
|
3389
|
+
if (isProductScopeFile(path))
|
|
3390
|
+
return "product";
|
|
3391
|
+
return null;
|
|
3480
3392
|
}
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
if (
|
|
3484
|
-
return
|
|
3485
|
-
const inLine = /^in:\s*(.+)$/im.exec(section);
|
|
3486
|
-
const outLine = /^out:\s*(.+)$/im.exec(section);
|
|
3487
|
-
const errors = [];
|
|
3488
|
-
if (!inLine)
|
|
3489
|
-
errors.push("`## Surface` has no `in:` line.");
|
|
3490
|
-
if (!outLine)
|
|
3491
|
-
errors.push("`## Surface` has no `out:` line.");
|
|
3492
|
-
if (errors.length > 0)
|
|
3493
|
-
return { ok: false, errors };
|
|
3494
|
-
const inGlobs = splitGlobList(inLine[1]);
|
|
3495
|
-
const outGlobs = splitGlobList(outLine[1]);
|
|
3496
|
-
for (const g of [...inGlobs, ...outGlobs]) {
|
|
3497
|
-
if (looksLikeFilePath(g)) {
|
|
3498
|
-
errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
|
|
3499
|
-
}
|
|
3393
|
+
var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3394
|
+
function stripNonProse(path, content) {
|
|
3395
|
+
if (path.endsWith(".md")) {
|
|
3396
|
+
return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
|
|
3500
3397
|
}
|
|
3501
|
-
if (
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
return { ok: true, value: { in: inGlobs, out: outGlobs } };
|
|
3398
|
+
if (path.endsWith(".tsx") || path.endsWith(".ts")) {
|
|
3399
|
+
return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
|
|
3400
|
+
}
|
|
3401
|
+
return content;
|
|
3506
3402
|
}
|
|
3507
|
-
function
|
|
3508
|
-
|
|
3509
|
-
const p = path.replace(/\/+$/, "");
|
|
3510
|
-
if (g === "*")
|
|
3511
|
-
return !p.includes("/");
|
|
3512
|
-
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
3403
|
+
function stripNonProseForProduct(path, content) {
|
|
3404
|
+
return path.endsWith(".md") ? stripNonProse(path, content) : content;
|
|
3513
3405
|
}
|
|
3514
|
-
function
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
for (const glob of surface.value.in) {
|
|
3520
|
-
if (!resolvesToFile(glob)) {
|
|
3521
|
-
errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
|
|
3522
|
-
}
|
|
3406
|
+
function lineAt(content, index) {
|
|
3407
|
+
let line = 1;
|
|
3408
|
+
for (let i = 0;i < index; i++) {
|
|
3409
|
+
if (content.charCodeAt(i) === 10)
|
|
3410
|
+
line++;
|
|
3523
3411
|
}
|
|
3524
|
-
return
|
|
3412
|
+
return line;
|
|
3525
3413
|
}
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
}
|
|
3535
|
-
return violations.length > 0 ? { ok: false, violations } : { ok: true };
|
|
3414
|
+
var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
|
|
3415
|
+
var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
|
|
3416
|
+
var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
|
|
3417
|
+
function legacySlugPattern(legacySlugs) {
|
|
3418
|
+
if (legacySlugs.length === 0)
|
|
3419
|
+
return null;
|
|
3420
|
+
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
3421
|
+
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
3536
3422
|
}
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
const
|
|
3543
|
-
const
|
|
3544
|
-
const
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3423
|
+
function specGrandfatherPaths(specGrandfather) {
|
|
3424
|
+
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3425
|
+
}
|
|
3426
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3427
|
+
const findings = [];
|
|
3428
|
+
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3429
|
+
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3430
|
+
const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
|
|
3431
|
+
const patterns = [
|
|
3432
|
+
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3433
|
+
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3434
|
+
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3435
|
+
];
|
|
3436
|
+
const productPatterns = [
|
|
3437
|
+
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3438
|
+
];
|
|
3439
|
+
const specPatterns = [
|
|
3440
|
+
...patterns,
|
|
3441
|
+
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3442
|
+
];
|
|
3443
|
+
for (const file of files) {
|
|
3444
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3445
|
+
if (!cls || cls === "internal")
|
|
3446
|
+
continue;
|
|
3447
|
+
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
3448
|
+
continue;
|
|
3449
|
+
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3450
|
+
continue;
|
|
3451
|
+
const blocking = cls === "product" || cls === "spec";
|
|
3452
|
+
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3453
|
+
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3454
|
+
const fileFindings = [];
|
|
3455
|
+
for (const { pattern, what, group } of patternsToRun) {
|
|
3456
|
+
pattern.lastIndex = 0;
|
|
3457
|
+
let match = pattern.exec(scrubbed);
|
|
3458
|
+
while (match !== null) {
|
|
3459
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
3460
|
+
const citedIndex = match.index + match[0].indexOf(cited);
|
|
3461
|
+
fileFindings.push({
|
|
3462
|
+
file: file.path,
|
|
3463
|
+
line: lineAt(scrubbed, citedIndex),
|
|
3464
|
+
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3465
|
+
blocking
|
|
3466
|
+
});
|
|
3467
|
+
match = pattern.exec(scrubbed);
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
3471
|
+
if (limit !== undefined) {
|
|
3472
|
+
if (fileFindings.length <= limit)
|
|
3473
|
+
continue;
|
|
3474
|
+
for (const f of fileFindings) {
|
|
3475
|
+
f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
findings.push(...fileFindings);
|
|
3479
|
+
}
|
|
3480
|
+
return findings;
|
|
3481
|
+
}
|
|
3482
|
+
function escapeTerm(term) {
|
|
3483
|
+
return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3484
|
+
}
|
|
3485
|
+
function containsWholeWord(text, term) {
|
|
3486
|
+
const escaped = escapeTerm(term);
|
|
3487
|
+
const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
|
|
3488
|
+
return re.test(text);
|
|
3489
|
+
}
|
|
3490
|
+
function findWholeWordLine(content, term) {
|
|
3491
|
+
const lines = content.split(`
|
|
3492
|
+
`);
|
|
3493
|
+
let lineNo = 0;
|
|
3494
|
+
for (const line of lines) {
|
|
3495
|
+
lineNo++;
|
|
3496
|
+
if (containsWholeWord(line, term))
|
|
3497
|
+
return lineNo;
|
|
3498
|
+
}
|
|
3499
|
+
return null;
|
|
3500
|
+
}
|
|
3501
|
+
function definesOrLinksGlossary(content, term) {
|
|
3502
|
+
const escaped = escapeTerm(term);
|
|
3503
|
+
const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
|
|
3504
|
+
if (definesInline)
|
|
3505
|
+
return true;
|
|
3506
|
+
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3507
|
+
}
|
|
3508
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
3509
|
+
const findings = [];
|
|
3510
|
+
for (const file of files) {
|
|
3511
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3512
|
+
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
3513
|
+
continue;
|
|
3514
|
+
const scrubbed = stripNonProse(file.path, file.content);
|
|
3515
|
+
for (const term of glossaryTerms) {
|
|
3516
|
+
const line = findWholeWordLine(scrubbed, term);
|
|
3517
|
+
if (line === null)
|
|
3518
|
+
continue;
|
|
3519
|
+
if (definesOrLinksGlossary(scrubbed, term))
|
|
3520
|
+
continue;
|
|
3521
|
+
findings.push({
|
|
3522
|
+
file: file.path,
|
|
3523
|
+
line,
|
|
3524
|
+
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3525
|
+
blocking: false
|
|
3526
|
+
});
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
return findings;
|
|
3530
|
+
}
|
|
3531
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
|
|
3532
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
|
|
3533
|
+
function extractComments(path, content) {
|
|
3534
|
+
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3535
|
+
return content.replace(/[^\n]/g, "");
|
|
3536
|
+
let state = "code";
|
|
3537
|
+
let out = "";
|
|
3538
|
+
const n = content.length;
|
|
3539
|
+
let i = 0;
|
|
3540
|
+
const blank = (ch) => ch === `
|
|
3541
|
+
` ? `
|
|
3542
|
+
` : " ";
|
|
3543
|
+
while (i < n) {
|
|
3544
|
+
const c = content[i];
|
|
3545
|
+
const next = i + 1 < n ? content[i + 1] : "";
|
|
3546
|
+
if (state === "code") {
|
|
3547
|
+
if (c === "/" && next === "/") {
|
|
3548
|
+
state = "line-comment";
|
|
3549
|
+
out += c;
|
|
3550
|
+
i++;
|
|
3551
|
+
continue;
|
|
3552
|
+
}
|
|
3553
|
+
if (c === "/" && next === "*") {
|
|
3554
|
+
state = "block-comment";
|
|
3555
|
+
out += c;
|
|
3556
|
+
i++;
|
|
3557
|
+
continue;
|
|
3558
|
+
}
|
|
3559
|
+
if (c === "'") {
|
|
3560
|
+
state = "single-quote";
|
|
3561
|
+
out += blank(c);
|
|
3562
|
+
i++;
|
|
3563
|
+
continue;
|
|
3564
|
+
}
|
|
3565
|
+
if (c === '"') {
|
|
3566
|
+
state = "double-quote";
|
|
3567
|
+
out += blank(c);
|
|
3568
|
+
i++;
|
|
3569
|
+
continue;
|
|
3570
|
+
}
|
|
3571
|
+
if (c === "`") {
|
|
3572
|
+
state = "template";
|
|
3573
|
+
out += blank(c);
|
|
3574
|
+
i++;
|
|
3575
|
+
continue;
|
|
3576
|
+
}
|
|
3577
|
+
out += blank(c);
|
|
3578
|
+
i++;
|
|
3579
|
+
continue;
|
|
3580
|
+
}
|
|
3581
|
+
if (state === "line-comment") {
|
|
3582
|
+
if (c === `
|
|
3583
|
+
`) {
|
|
3584
|
+
state = "code";
|
|
3585
|
+
out += `
|
|
3586
|
+
`;
|
|
3587
|
+
i++;
|
|
3588
|
+
continue;
|
|
3589
|
+
}
|
|
3590
|
+
out += c;
|
|
3591
|
+
i++;
|
|
3592
|
+
continue;
|
|
3593
|
+
}
|
|
3594
|
+
if (state === "block-comment") {
|
|
3595
|
+
if (c === "*" && next === "/") {
|
|
3596
|
+
out += c;
|
|
3597
|
+
out += next;
|
|
3598
|
+
state = "code";
|
|
3599
|
+
i += 2;
|
|
3600
|
+
continue;
|
|
3601
|
+
}
|
|
3602
|
+
out += c === `
|
|
3603
|
+
` ? `
|
|
3604
|
+
` : c;
|
|
3605
|
+
i++;
|
|
3606
|
+
continue;
|
|
3607
|
+
}
|
|
3608
|
+
const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
|
|
3609
|
+
if (c === "\\") {
|
|
3610
|
+
out += blank(c);
|
|
3611
|
+
i++;
|
|
3612
|
+
if (i < n) {
|
|
3613
|
+
out += blank(content[i]);
|
|
3614
|
+
i++;
|
|
3615
|
+
}
|
|
3616
|
+
continue;
|
|
3617
|
+
}
|
|
3618
|
+
if (c === closer) {
|
|
3619
|
+
state = "code";
|
|
3620
|
+
out += blank(c);
|
|
3621
|
+
i++;
|
|
3622
|
+
continue;
|
|
3623
|
+
}
|
|
3624
|
+
out += blank(c);
|
|
3625
|
+
i++;
|
|
3626
|
+
}
|
|
3627
|
+
return out;
|
|
3628
|
+
}
|
|
3629
|
+
function checkSourceComments(files, allowlist = []) {
|
|
3630
|
+
const findings = [];
|
|
3631
|
+
const allowed = new Set(allowlist);
|
|
3632
|
+
const patterns = [
|
|
3633
|
+
{ pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
|
|
3634
|
+
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3635
|
+
];
|
|
3636
|
+
for (const file of files) {
|
|
3637
|
+
if (!file.path.endsWith(".ts"))
|
|
3638
|
+
continue;
|
|
3639
|
+
if (allowed.has(file.path))
|
|
3640
|
+
continue;
|
|
3641
|
+
const comments = extractComments(file.path, file.content);
|
|
3642
|
+
for (const { pattern, what } of patterns) {
|
|
3643
|
+
pattern.lastIndex = 0;
|
|
3644
|
+
let match = pattern.exec(comments);
|
|
3645
|
+
while (match !== null) {
|
|
3646
|
+
findings.push({
|
|
3647
|
+
file: file.path,
|
|
3648
|
+
line: lineAt(comments, match.index),
|
|
3649
|
+
message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
|
|
3650
|
+
blocking: false
|
|
3651
|
+
});
|
|
3652
|
+
match = pattern.exec(comments);
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
return findings;
|
|
3657
|
+
}
|
|
3658
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3659
|
+
return [
|
|
3660
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3661
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
3662
|
+
];
|
|
3663
|
+
}
|
|
3664
|
+
function parseGlossaryTerms(glossaryContent) {
|
|
3665
|
+
const terms = [];
|
|
3666
|
+
const re = /^\*\*(.+?)\*\* —/gm;
|
|
3667
|
+
let match = re.exec(glossaryContent);
|
|
3668
|
+
while (match !== null) {
|
|
3669
|
+
if (match[1] !== undefined)
|
|
3670
|
+
terms.push(match[1]);
|
|
3671
|
+
match = re.exec(glossaryContent);
|
|
3672
|
+
}
|
|
3673
|
+
return terms;
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
// ../../packages/aeg-core/src/quoted-command.ts
|
|
3677
|
+
var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
|
|
3678
|
+
var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3679
|
+
var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
|
|
3680
|
+
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
3681
|
+
function isValidCitedFilePath(path) {
|
|
3682
|
+
if (path.length === 0)
|
|
3683
|
+
return false;
|
|
3684
|
+
if (path.startsWith("/") || path.startsWith("\\"))
|
|
3685
|
+
return false;
|
|
3686
|
+
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
3687
|
+
return false;
|
|
3688
|
+
return !path.split(/[\\/]+/).includes("..");
|
|
3689
|
+
}
|
|
3690
|
+
function quotedCommandLineAt(content, index) {
|
|
3691
|
+
let line = 1;
|
|
3692
|
+
for (let i = 0;i < index; i++) {
|
|
3693
|
+
if (content.charCodeAt(i) === 10)
|
|
3694
|
+
line++;
|
|
3695
|
+
}
|
|
3696
|
+
return line;
|
|
3697
|
+
}
|
|
3698
|
+
function extractQuotedText(raw) {
|
|
3699
|
+
const trimmed = raw.trim();
|
|
3700
|
+
const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
|
|
3701
|
+
if (fenced)
|
|
3702
|
+
return (fenced[1] ?? "").trim();
|
|
3703
|
+
const inline = /^`([^`]+)`$/.exec(trimmed);
|
|
3704
|
+
if (inline)
|
|
3705
|
+
return (inline[1] ?? "").trim();
|
|
3706
|
+
return trimmed;
|
|
3707
|
+
}
|
|
3708
|
+
function findQuotesInFile(path, content) {
|
|
3709
|
+
const masked = maskCode(content);
|
|
3710
|
+
const quotes = [];
|
|
3711
|
+
START_PATTERN.lastIndex = 0;
|
|
3712
|
+
let start = START_PATTERN.exec(masked);
|
|
3713
|
+
while (start !== null) {
|
|
3714
|
+
const citedFile = start[1];
|
|
3715
|
+
const innerStart = start.index + start[0].length;
|
|
3716
|
+
const end = END_PATTERN.exec(masked.slice(innerStart));
|
|
3717
|
+
if (end === null) {
|
|
3718
|
+
START_PATTERN.lastIndex = innerStart;
|
|
3719
|
+
start = START_PATTERN.exec(masked);
|
|
3720
|
+
continue;
|
|
3721
|
+
}
|
|
3722
|
+
const innerEnd = innerStart + end.index;
|
|
3723
|
+
if (isValidCitedFilePath(citedFile)) {
|
|
3724
|
+
const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
|
|
3725
|
+
if (quotedText.length > 0) {
|
|
3726
|
+
quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
3730
|
+
start = START_PATTERN.exec(masked);
|
|
3731
|
+
}
|
|
3732
|
+
return quotes;
|
|
3733
|
+
}
|
|
3734
|
+
function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
|
|
3735
|
+
const quotes = [];
|
|
3736
|
+
for (const file of files) {
|
|
3737
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3738
|
+
if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
|
|
3739
|
+
continue;
|
|
3740
|
+
quotes.push(...findQuotesInFile(file.path, file.content));
|
|
3741
|
+
}
|
|
3742
|
+
return quotes;
|
|
3743
|
+
}
|
|
3744
|
+
function evaluateCitedQuotes(citedQuotes, citedFileContents) {
|
|
3745
|
+
const findings = [];
|
|
3746
|
+
for (const quote of citedQuotes) {
|
|
3747
|
+
const content = citedFileContents.get(quote.citedFile);
|
|
3748
|
+
if (content === undefined) {
|
|
3749
|
+
findings.push({
|
|
3750
|
+
file: quote.file,
|
|
3751
|
+
line: quote.line,
|
|
3752
|
+
citedFile: quote.citedFile,
|
|
3753
|
+
quotedText: quote.quotedText,
|
|
3754
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
3755
|
+
});
|
|
3756
|
+
continue;
|
|
3757
|
+
}
|
|
3758
|
+
if (!content.includes(quote.quotedText)) {
|
|
3759
|
+
findings.push({
|
|
3760
|
+
file: quote.file,
|
|
3761
|
+
line: quote.line,
|
|
3762
|
+
citedFile: quote.citedFile,
|
|
3763
|
+
quotedText: quote.quotedText,
|
|
3764
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
3765
|
+
});
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
return findings;
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3772
|
+
function hasRationaleField(body, labelPattern) {
|
|
3773
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
3774
|
+
return re.test(body);
|
|
3775
|
+
}
|
|
3776
|
+
var RATIONALE_FIELDS = [
|
|
3777
|
+
{ name: "Boundary", pattern: "Boundary" },
|
|
3778
|
+
{ name: "Sizing", pattern: "Sizing" },
|
|
3779
|
+
{ name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
|
|
3780
|
+
{ name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
|
|
3781
|
+
{ name: "Traps to avoid", pattern: "Traps" },
|
|
3782
|
+
{ name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
|
|
3783
|
+
{ name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
|
|
3784
|
+
{ name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
|
|
3785
|
+
];
|
|
3786
|
+
var DEPENDENCY_RATIONALE_FIELD_NAME = "Dependency rationale";
|
|
3787
|
+
function checkIssueRationale(body) {
|
|
3788
|
+
const errors = [];
|
|
3789
|
+
for (const f of RATIONALE_FIELDS) {
|
|
3790
|
+
if (!hasRationaleField(body, f.pattern)) {
|
|
3791
|
+
errors.push(`issue-validation ${f.name}: rationale field not found in the Issue body — every task Issue carries the full Planner's rationale (aeg-root/contracts/planner-brief.md).`);
|
|
3792
|
+
continue;
|
|
3793
|
+
}
|
|
3794
|
+
if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
|
|
3795
|
+
errors.push(`issue-validation ${f.name}: rationale field found, but not in the form amend-deps requires — ` + "write `**Dependency rationale** — …`, not `**Dependency rationale:** …`. " + "`amendRationaleDeps` (the only sanctioned way to edit Depends-on/Conflicts-with) locates this " + "section by the exact anchor `**Dependency rationale**`; a colon inside the bold breaks that match " + "and the Issue becomes unamendable.");
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3799
|
+
}
|
|
3800
|
+
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3801
|
+
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3802
|
+
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3803
|
+
return { status: "pass", errors: [] };
|
|
3804
|
+
const result = objectivesOf(body);
|
|
3805
|
+
if (result.ok)
|
|
3806
|
+
return { status: "pass", errors: [] };
|
|
3807
|
+
return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
|
|
3808
|
+
}
|
|
3809
|
+
function topLevelSectionText(body, headingName) {
|
|
3810
|
+
const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
|
|
3811
|
+
const heading = headingRe.exec(body);
|
|
3812
|
+
if (!heading)
|
|
3813
|
+
return null;
|
|
3814
|
+
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
3815
|
+
const next = /^##[ \t]/m.exec(afterHeading);
|
|
3816
|
+
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
3817
|
+
}
|
|
3818
|
+
function partHasBacktickedPath(text) {
|
|
3819
|
+
let i = 0;
|
|
3820
|
+
while (i < text.length) {
|
|
3821
|
+
const start = text.indexOf("`", i);
|
|
3822
|
+
if (start === -1)
|
|
3823
|
+
return false;
|
|
3824
|
+
const end = text.indexOf("`", start + 1);
|
|
3825
|
+
if (end === -1)
|
|
3826
|
+
return false;
|
|
3827
|
+
if (text.slice(start + 1, end).includes("/"))
|
|
3828
|
+
return true;
|
|
3829
|
+
i = end + 1;
|
|
3830
|
+
}
|
|
3831
|
+
return false;
|
|
3832
|
+
}
|
|
3833
|
+
var PART_MIN_WORDS_OUTSIDE_BACKTICKS = 3;
|
|
3834
|
+
function stripPartBackticks(text) {
|
|
3835
|
+
return text.replace(/`[^`\n]*`/g, " ");
|
|
3836
|
+
}
|
|
3837
|
+
function partWordCount(text) {
|
|
3838
|
+
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
3839
|
+
}
|
|
3840
|
+
function looksLikeFilePath(entry) {
|
|
3841
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3842
|
+
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3843
|
+
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3844
|
+
return extMatch !== null && extMatch.index > 0;
|
|
3845
|
+
}
|
|
3846
|
+
function splitGlobList(raw) {
|
|
3847
|
+
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
3848
|
+
}
|
|
3849
|
+
function parseIssueSurface(body) {
|
|
3850
|
+
const section = topLevelSectionText(body, "Surface");
|
|
3851
|
+
if (section === null)
|
|
3852
|
+
return { ok: false, errors: ["no `## Surface` heading found in the body."] };
|
|
3853
|
+
const inLine = /^in:\s*(.+)$/im.exec(section);
|
|
3854
|
+
const outLine = /^out:\s*(.+)$/im.exec(section);
|
|
3855
|
+
const errors = [];
|
|
3856
|
+
if (!inLine)
|
|
3857
|
+
errors.push("`## Surface` has no `in:` line.");
|
|
3858
|
+
if (!outLine)
|
|
3859
|
+
errors.push("`## Surface` has no `out:` line.");
|
|
3860
|
+
if (errors.length > 0)
|
|
3861
|
+
return { ok: false, errors };
|
|
3862
|
+
const inGlobs = splitGlobList(inLine[1]);
|
|
3863
|
+
const outGlobs = splitGlobList(outLine[1]);
|
|
3864
|
+
for (const g of [...inGlobs, ...outGlobs]) {
|
|
3865
|
+
if (looksLikeFilePath(g)) {
|
|
3866
|
+
errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
if (inGlobs.length === 0)
|
|
3870
|
+
errors.push("`## Surface`'s `in:` line resolved to zero globs.");
|
|
3871
|
+
if (errors.length > 0)
|
|
3872
|
+
return { ok: false, errors };
|
|
3873
|
+
return { ok: true, value: { in: inGlobs, out: outGlobs } };
|
|
3874
|
+
}
|
|
3875
|
+
function globCoversPath(glob, path) {
|
|
3876
|
+
const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
3877
|
+
const p = path.replace(/\/+$/, "");
|
|
3878
|
+
if (g === "*")
|
|
3879
|
+
return !p.includes("/");
|
|
3880
|
+
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
3881
|
+
}
|
|
3882
|
+
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
3883
|
+
const surface = parseIssueSurface(body);
|
|
3884
|
+
if (!surface.ok)
|
|
3885
|
+
return { status: "pass", errors: [] };
|
|
3886
|
+
const errors = [];
|
|
3887
|
+
for (const glob of surface.value.in) {
|
|
3888
|
+
if (!resolvesToFile(glob)) {
|
|
3889
|
+
errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3893
|
+
}
|
|
3894
|
+
function checkSurfaceScope(changedFiles, outGlobs) {
|
|
3895
|
+
if (outGlobs.length === 0)
|
|
3896
|
+
return { ok: true };
|
|
3897
|
+
const violations = [];
|
|
3898
|
+
for (const file of changedFiles) {
|
|
3899
|
+
const glob = outGlobs.find((g) => globCoversPath(g, file));
|
|
3900
|
+
if (glob)
|
|
3901
|
+
violations.push({ file, glob });
|
|
3902
|
+
}
|
|
3903
|
+
return violations.length > 0 ? { ok: false, violations } : { ok: true };
|
|
3904
|
+
}
|
|
3905
|
+
var ISSUE_PART_LINE_RE = /^Part\s+(\d+)\s*\(([^)]*)\)\s*[-—–]\s*(.*)$/i;
|
|
3906
|
+
function parseIssueParts(body) {
|
|
3907
|
+
const section = topLevelSectionText(body, "Parts");
|
|
3908
|
+
if (section === null)
|
|
3909
|
+
return { ok: false, errors: ["no `## Parts` heading found in the body."] };
|
|
3910
|
+
const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
|
|
3911
|
+
const parts = [];
|
|
3912
|
+
const errors = [];
|
|
3913
|
+
for (const line of lines) {
|
|
3914
|
+
const m = ISSUE_PART_LINE_RE.exec(line);
|
|
3915
|
+
if (!m) {
|
|
3916
|
+
errors.push(`"${line}" is not a well-formed Parts line — expected \`Part <n> (<refs>) — <outcome>\`.`);
|
|
3917
|
+
continue;
|
|
3918
|
+
}
|
|
3919
|
+
const n = Number.parseInt(m[1], 10);
|
|
3920
|
+
const refs = m[2];
|
|
3921
|
+
const text = m[3].trim();
|
|
3922
|
+
if (text.length === 0) {
|
|
3923
|
+
errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
|
|
3924
|
+
continue;
|
|
3925
|
+
}
|
|
3558
3926
|
if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
|
|
3559
3927
|
errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
|
|
3560
3928
|
continue;
|
|
@@ -3668,6 +4036,27 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
|
3668
4036
|
}
|
|
3669
4037
|
var DOC_PATH_RE = /(?:(?:aeg-root|apps|packages|specs|docs|tools|\.claude|\.github)\/[\w./@-]*\.(?:md|mdx)|\.claude\/(?:skills|rules)\/[\w./-]+|\b(?:docs-index|decisions|projects|state-machine|enforcement|process|README|CLAUDE)\.md\b|\b[\w-]+-(?:spec|decisions|backlog)\.md\b)/i;
|
|
3670
4038
|
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
4039
|
+
var FILE_EXTENSIONS = new Set([
|
|
4040
|
+
"ts",
|
|
4041
|
+
"tsx",
|
|
4042
|
+
"js",
|
|
4043
|
+
"jsx",
|
|
4044
|
+
"mjs",
|
|
4045
|
+
"cjs",
|
|
4046
|
+
"json",
|
|
4047
|
+
"jsonc",
|
|
4048
|
+
"md",
|
|
4049
|
+
"mdx",
|
|
4050
|
+
"yml",
|
|
4051
|
+
"yaml",
|
|
4052
|
+
"txt",
|
|
4053
|
+
"sh",
|
|
4054
|
+
"lock",
|
|
4055
|
+
"toml",
|
|
4056
|
+
"ndjson",
|
|
4057
|
+
"html",
|
|
4058
|
+
"css"
|
|
4059
|
+
]);
|
|
3671
4060
|
|
|
3672
4061
|
// ../../packages/aeg-core/src/task-branch-identity.ts
|
|
3673
4062
|
var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
|
|
@@ -4046,8 +4435,7 @@ function briefHash(brief) {
|
|
|
4046
4435
|
function policyDigest(policy) {
|
|
4047
4436
|
return createHash4("sha256").update(JSON.stringify({
|
|
4048
4437
|
codeReviewThreshold: policy.codeReviewThreshold,
|
|
4049
|
-
securityThreshold: policy.securityThreshold
|
|
4050
|
-
maxRounds: policy.maxRounds
|
|
4438
|
+
securityThreshold: policy.securityThreshold
|
|
4051
4439
|
})).digest("hex");
|
|
4052
4440
|
}
|
|
4053
4441
|
function isBoundToHead(echoed, headSha) {
|
|
@@ -4113,6 +4501,15 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4113
4501
|
}
|
|
4114
4502
|
|
|
4115
4503
|
// ../../packages/aeg-core/src/review-gate.ts
|
|
4504
|
+
function renderGateDeferred(deferred) {
|
|
4505
|
+
if (deferred.length === 0)
|
|
4506
|
+
return "";
|
|
4507
|
+
const items = deferred.map((d) => {
|
|
4508
|
+
const where = d.finding.location && d.finding.location.length > 0 ? d.finding.location : "(no location)";
|
|
4509
|
+
return `${d.finding.severity} ${where} (${DEFERRAL_REASON_TEXT[d.reason]})`;
|
|
4510
|
+
}).join("; ");
|
|
4511
|
+
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4512
|
+
}
|
|
4116
4513
|
function checkReviewGate(input) {
|
|
4117
4514
|
const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
|
|
4118
4515
|
const waived = isWaiverLabelActorVerified({
|
|
@@ -4137,8 +4534,8 @@ function checkReviewGate(input) {
|
|
|
4137
4534
|
let codeReviewPolicyEvaluation;
|
|
4138
4535
|
let securityPolicyEvaluation;
|
|
4139
4536
|
try {
|
|
4140
|
-
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
|
|
4141
|
-
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
|
|
4537
|
+
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy, input.deferralContext);
|
|
4538
|
+
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy, input.deferralContext);
|
|
4142
4539
|
} catch (err) {
|
|
4143
4540
|
return {
|
|
4144
4541
|
verdict: "fail",
|
|
@@ -4184,10 +4581,14 @@ function checkReviewGate(input) {
|
|
|
4184
4581
|
const securityObjectivesBound = securityBinding.objectivesVersion;
|
|
4185
4582
|
const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
|
|
4186
4583
|
const securityRulingsBound = securityBinding.rulingOrdinal;
|
|
4584
|
+
const deferredNote = renderGateDeferred([
|
|
4585
|
+
...codeReviewPolicyEvaluation.deferredFindings,
|
|
4586
|
+
...securityPolicyEvaluation.deferredFindings
|
|
4587
|
+
]);
|
|
4187
4588
|
if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
|
|
4188
4589
|
return {
|
|
4189
4590
|
verdict: "pass",
|
|
4190
|
-
reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}
|
|
4591
|
+
reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.${deferredNote}`,
|
|
4191
4592
|
waived: false
|
|
4192
4593
|
};
|
|
4193
4594
|
}
|
|
@@ -4229,7 +4630,7 @@ function checkReviewGate(input) {
|
|
|
4229
4630
|
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4230
4631
|
return {
|
|
4231
4632
|
verdict: "fail",
|
|
4232
|
-
reason: `${problems.join("; ")}. A principal can apply an actor-verified \`${WAIVER_LABEL_REVIEW}\` label to skip this requirement, or post the missing/clean verdict comment(s).${ignoredNote}`,
|
|
4633
|
+
reason: `${problems.join("; ")}. A principal can apply an actor-verified \`${WAIVER_LABEL_REVIEW}\` label to skip this requirement, or post the missing/clean verdict comment(s).${ignoredNote}${deferredNote}`,
|
|
4233
4634
|
waived: false
|
|
4234
4635
|
};
|
|
4235
4636
|
}
|
|
@@ -4341,572 +4742,197 @@ function parseEnforcementRegistry(content) {
|
|
|
4341
4742
|
const specIndex = (audienceIndex === -1 ? cells.length - 1 : audienceIndex) - 1;
|
|
4342
4743
|
const spec = specIndex >= 3 ? stripBackticks2(cells[specIndex] ?? "") || undefined : undefined;
|
|
4343
4744
|
const audience = audienceIndex === -1 ? "repo-own" : stripBackticks2(cells[audienceIndex] ?? "") === "product" ? "product" : "repo-own";
|
|
4344
|
-
result.push({ ring, action, summary, category, description, spec, implementation, audience, line: row.line });
|
|
4345
|
-
}
|
|
4346
|
-
}
|
|
4347
|
-
return result;
|
|
4348
|
-
}
|
|
4349
|
-
// ../../packages/aeg-core/src/registry-checks.ts
|
|
4350
|
-
function checkG1(rows, existsFn) {
|
|
4351
|
-
const findings = [];
|
|
4352
|
-
for (const row of rows) {
|
|
4353
|
-
if (row.implementation === "")
|
|
4354
|
-
continue;
|
|
4355
|
-
if (!existsFn(row.implementation)) {
|
|
4356
|
-
findings.push({
|
|
4357
|
-
row: row.action,
|
|
4358
|
-
path: row.implementation,
|
|
4359
|
-
reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
|
|
4360
|
-
});
|
|
4361
|
-
}
|
|
4362
|
-
}
|
|
4363
|
-
return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4364
|
-
}
|
|
4365
|
-
var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
4366
|
-
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
4367
|
-
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
4368
|
-
"apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
|
|
4369
|
-
"apps/cli/src/checks/bin/check-issue-assignment.ts": `Ring 0 "A task branch's first push (Issue self-assignment)" (implementation: assign-task-issue.ts)`,
|
|
4370
|
-
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
4371
|
-
};
|
|
4372
|
-
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
4373
|
-
function checkG2(rows, candidateFiles) {
|
|
4374
|
-
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
4375
|
-
const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
|
|
4376
|
-
const findings = [];
|
|
4377
|
-
for (const path of candidateFiles) {
|
|
4378
|
-
if (implementations.has(path))
|
|
4379
|
-
continue;
|
|
4380
|
-
if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
|
|
4381
|
-
continue;
|
|
4382
|
-
if (NON_GATE_HOOK_SCRIPTS.includes(path))
|
|
4383
|
-
continue;
|
|
4384
|
-
if (path in TWIN_CANDIDATE_EXCEPTIONS)
|
|
4385
|
-
continue;
|
|
4386
|
-
const candidateNames = claimedCheckNames(path);
|
|
4387
|
-
if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
|
|
4388
|
-
continue;
|
|
4389
|
-
findings.push({
|
|
4390
|
-
path,
|
|
4391
|
-
reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
|
|
4392
|
-
});
|
|
4393
|
-
}
|
|
4394
|
-
for (const row of rows) {
|
|
4395
|
-
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
4396
|
-
if (carriesPlaceholder) {
|
|
4397
|
-
findings.push({
|
|
4398
|
-
row: row.action,
|
|
4399
|
-
path: row.implementation,
|
|
4400
|
-
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
4401
|
-
});
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
4404
|
-
return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4405
|
-
}
|
|
4406
|
-
function checkG3(ring0Rows, crossingFiles) {
|
|
4407
|
-
const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
|
|
4408
|
-
const findings = [];
|
|
4409
|
-
for (const path of crossingFiles) {
|
|
4410
|
-
if (!ring0Implementations.has(path)) {
|
|
4411
|
-
findings.push({
|
|
4412
|
-
path,
|
|
4413
|
-
reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
|
|
4414
|
-
});
|
|
4415
|
-
}
|
|
4416
|
-
}
|
|
4417
|
-
return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4418
|
-
}
|
|
4419
|
-
function checkG4(content, resolveFn) {
|
|
4420
|
-
const cited = new Set;
|
|
4421
|
-
for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
|
|
4422
|
-
cited.add(Number(hit[1]));
|
|
4423
|
-
}
|
|
4424
|
-
const findings = [];
|
|
4425
|
-
for (const n of cited) {
|
|
4426
|
-
if (!resolveFn(n)) {
|
|
4427
|
-
findings.push({
|
|
4428
|
-
reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
|
|
4429
|
-
});
|
|
4430
|
-
}
|
|
4431
|
-
}
|
|
4432
|
-
return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4433
|
-
}
|
|
4434
|
-
function checkG5(roles, contracts) {
|
|
4435
|
-
const roleIds = new Set(roles.map((r) => r.role_id));
|
|
4436
|
-
const findings = [];
|
|
4437
|
-
for (const contract of contracts) {
|
|
4438
|
-
if (!roleIds.has(contract.producer)) {
|
|
4439
|
-
findings.push({
|
|
4440
|
-
path: contract.file,
|
|
4441
|
-
reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
|
|
4442
|
-
});
|
|
4443
|
-
}
|
|
4444
|
-
if (!roleIds.has(contract.consumer)) {
|
|
4445
|
-
findings.push({
|
|
4446
|
-
path: contract.file,
|
|
4447
|
-
reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
|
|
4448
|
-
});
|
|
4449
|
-
}
|
|
4450
|
-
}
|
|
4451
|
-
for (const role of roles) {
|
|
4452
|
-
if (role.performs.length === 0) {
|
|
4453
|
-
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
|
|
4454
|
-
}
|
|
4455
|
-
if (role.refuses_when.trim() === "") {
|
|
4456
|
-
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
|
|
4457
|
-
}
|
|
4458
|
-
}
|
|
4459
|
-
return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4460
|
-
}
|
|
4461
|
-
var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
|
|
4462
|
-
var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
|
|
4463
|
-
function basenameNoExt(path) {
|
|
4464
|
-
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
4465
|
-
return base.replace(/\.ts$/, "");
|
|
4466
|
-
}
|
|
4467
|
-
function claimedCheckNames(implementation) {
|
|
4468
|
-
if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
|
|
4469
|
-
return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
|
|
4470
|
-
}
|
|
4471
|
-
if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
|
|
4472
|
-
const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
|
|
4473
|
-
if (audience && isShipped(audience)) {
|
|
4474
|
-
return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
|
|
4475
|
-
}
|
|
4476
|
-
}
|
|
4477
|
-
return [];
|
|
4478
|
-
}
|
|
4479
|
-
function checkG6(rows, registeredCheckNames) {
|
|
4480
|
-
const findings = [];
|
|
4481
|
-
for (const row of rows) {
|
|
4482
|
-
if (row.audience !== "product")
|
|
4483
|
-
continue;
|
|
4484
|
-
const candidates = claimedCheckNames(row.implementation);
|
|
4485
|
-
if (!candidates.some((name) => registeredCheckNames.has(name))) {
|
|
4486
|
-
findings.push({
|
|
4487
|
-
row: row.action,
|
|
4488
|
-
path: row.implementation,
|
|
4489
|
-
reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
|
|
4490
|
-
});
|
|
4491
|
-
}
|
|
4492
|
-
}
|
|
4493
|
-
return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4494
|
-
}
|
|
4495
|
-
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
4496
|
-
var PRODUCT_SLUG_SCOPE = [
|
|
4497
|
-
"apps/cli/src",
|
|
4498
|
-
".github/workflows",
|
|
4499
|
-
".vinaya",
|
|
4500
|
-
"apps/cli/README.md",
|
|
4501
|
-
"packages/sources/README.md"
|
|
4502
|
-
];
|
|
4503
|
-
function isUnderOrEqual(path, prefix) {
|
|
4504
|
-
return path === prefix || path.startsWith(`${prefix}/`);
|
|
4505
|
-
}
|
|
4506
|
-
function isProductScopeFile(path) {
|
|
4507
|
-
return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
|
|
4508
|
-
}
|
|
4509
|
-
var SHIPS_PREFIX = "aeg-root/";
|
|
4510
|
-
function shipsArchivePrefix(shipsPrefix) {
|
|
4511
|
-
return `${shipsPrefix}tranches/completed/`;
|
|
4512
|
-
}
|
|
4513
|
-
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
4514
|
-
function normalizeSpecPath(entry) {
|
|
4515
|
-
let out = entry.replace(/\\/g, "/");
|
|
4516
|
-
while (out.startsWith("./"))
|
|
4517
|
-
out = out.slice(2);
|
|
4518
|
-
out = out.replace(/\/{2,}/g, "/");
|
|
4519
|
-
while (out.endsWith("/"))
|
|
4520
|
-
out = out.slice(0, -1);
|
|
4521
|
-
return out;
|
|
4522
|
-
}
|
|
4523
|
-
function isSpecFile2(path, specPaths) {
|
|
4524
|
-
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
4525
|
-
return true;
|
|
4526
|
-
if (!path.endsWith(".md"))
|
|
4527
|
-
return false;
|
|
4528
|
-
return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
|
|
4529
|
-
}
|
|
4530
|
-
function isClaudeMdFile(path) {
|
|
4531
|
-
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
4532
|
-
}
|
|
4533
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4534
|
-
if (path.startsWith(shipsPrefix)) {
|
|
4535
|
-
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
4536
|
-
}
|
|
4537
|
-
if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
|
|
4538
|
-
return "reader-facing";
|
|
4539
|
-
}
|
|
4540
|
-
if (isClaudeMdFile(path))
|
|
4541
|
-
return "internal";
|
|
4542
|
-
if (isSpecFile2(path, specPaths))
|
|
4543
|
-
return "spec";
|
|
4544
|
-
if (isProductScopeFile(path))
|
|
4545
|
-
return "product";
|
|
4546
|
-
return null;
|
|
4547
|
-
}
|
|
4548
|
-
var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
4549
|
-
function stripNonProse(path, content) {
|
|
4550
|
-
if (path.endsWith(".md")) {
|
|
4551
|
-
return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
|
|
4552
|
-
}
|
|
4553
|
-
if (path.endsWith(".tsx") || path.endsWith(".ts")) {
|
|
4554
|
-
return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
|
|
4745
|
+
result.push({ ring, action, summary, category, description, spec, implementation, audience, line: row.line });
|
|
4746
|
+
}
|
|
4555
4747
|
}
|
|
4556
|
-
return
|
|
4748
|
+
return result;
|
|
4557
4749
|
}
|
|
4558
|
-
|
|
4559
|
-
|
|
4750
|
+
// ../../packages/aeg-core/src/registry-checks.ts
|
|
4751
|
+
var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
|
|
4752
|
+
var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
|
|
4753
|
+
function basename(path) {
|
|
4754
|
+
return path.slice(path.lastIndexOf("/") + 1);
|
|
4560
4755
|
}
|
|
4561
|
-
function
|
|
4756
|
+
function lineOf(content, index) {
|
|
4562
4757
|
let line = 1;
|
|
4563
|
-
for (let i = 0;i < index; i++)
|
|
4758
|
+
for (let i = 0;i < index; i++)
|
|
4564
4759
|
if (content.charCodeAt(i) === 10)
|
|
4565
4760
|
line++;
|
|
4566
|
-
}
|
|
4567
4761
|
return line;
|
|
4568
4762
|
}
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
|
|
4572
|
-
function legacySlugPattern(legacySlugs) {
|
|
4573
|
-
if (legacySlugs.length === 0)
|
|
4574
|
-
return null;
|
|
4575
|
-
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
4576
|
-
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
4577
|
-
}
|
|
4578
|
-
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4763
|
+
function findUnshippedHookRefs(docs, shipped) {
|
|
4764
|
+
const shippedNames = new Set([...shipped].map(basename));
|
|
4579
4765
|
const findings = [];
|
|
4580
|
-
const
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
if (cls === "spec" && grandfathered.has(file.path))
|
|
4601
|
-
continue;
|
|
4602
|
-
const blocking = cls === "product" || cls === "spec";
|
|
4603
|
-
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
4604
|
-
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
4605
|
-
for (const { pattern, what, group } of patternsToRun) {
|
|
4606
|
-
pattern.lastIndex = 0;
|
|
4607
|
-
let match = pattern.exec(scrubbed);
|
|
4608
|
-
while (match !== null) {
|
|
4609
|
-
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4610
|
-
const citedIndex = match.index + match[0].indexOf(cited);
|
|
4611
|
-
findings.push({
|
|
4612
|
-
file: file.path,
|
|
4613
|
-
line: lineAt(scrubbed, citedIndex),
|
|
4614
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4615
|
-
blocking
|
|
4616
|
-
});
|
|
4617
|
-
match = pattern.exec(scrubbed);
|
|
4618
|
-
}
|
|
4766
|
+
const flag = (doc, token, index) => {
|
|
4767
|
+
findings.push({
|
|
4768
|
+
path: doc.path,
|
|
4769
|
+
reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
|
|
4770
|
+
});
|
|
4771
|
+
};
|
|
4772
|
+
for (const doc of docs) {
|
|
4773
|
+
for (const { cited, index } of extractCitedPaths(doc.content)) {
|
|
4774
|
+
if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
|
|
4775
|
+
continue;
|
|
4776
|
+
if (!shipped.has(cited))
|
|
4777
|
+
flag(doc, cited, index);
|
|
4778
|
+
}
|
|
4779
|
+
const spanPattern = /`([^`\n]+)`/g;
|
|
4780
|
+
let match = spanPattern.exec(doc.content);
|
|
4781
|
+
while (match !== null) {
|
|
4782
|
+
const token = match[1] ?? "";
|
|
4783
|
+
if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
|
|
4784
|
+
flag(doc, token, match.index);
|
|
4785
|
+
match = spanPattern.exec(doc.content);
|
|
4619
4786
|
}
|
|
4620
4787
|
}
|
|
4621
4788
|
return findings;
|
|
4622
4789
|
}
|
|
4623
|
-
function
|
|
4624
|
-
return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4625
|
-
}
|
|
4626
|
-
function containsWholeWord(text, term) {
|
|
4627
|
-
const escaped = escapeTerm(term);
|
|
4628
|
-
const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
|
|
4629
|
-
return re.test(text);
|
|
4630
|
-
}
|
|
4631
|
-
function findWholeWordLine(content, term) {
|
|
4632
|
-
const lines = content.split(`
|
|
4633
|
-
`);
|
|
4634
|
-
let lineNo = 0;
|
|
4635
|
-
for (const line of lines) {
|
|
4636
|
-
lineNo++;
|
|
4637
|
-
if (containsWholeWord(line, term))
|
|
4638
|
-
return lineNo;
|
|
4639
|
-
}
|
|
4640
|
-
return null;
|
|
4641
|
-
}
|
|
4642
|
-
function definesOrLinksGlossary(content, term) {
|
|
4643
|
-
const escaped = escapeTerm(term);
|
|
4644
|
-
const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
|
|
4645
|
-
if (definesInline)
|
|
4646
|
-
return true;
|
|
4647
|
-
return /docs\/glossary|glossary\.md/i.test(content);
|
|
4648
|
-
}
|
|
4649
|
-
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4790
|
+
function checkG1(rows, existsFn, hookRefs) {
|
|
4650
4791
|
const findings = [];
|
|
4651
|
-
for (const
|
|
4652
|
-
|
|
4653
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4792
|
+
for (const row of rows) {
|
|
4793
|
+
if (row.implementation === "")
|
|
4654
4794
|
continue;
|
|
4655
|
-
|
|
4656
|
-
for (const term of glossaryTerms) {
|
|
4657
|
-
const line = findWholeWordLine(scrubbed, term);
|
|
4658
|
-
if (line === null)
|
|
4659
|
-
continue;
|
|
4660
|
-
if (definesOrLinksGlossary(scrubbed, term))
|
|
4661
|
-
continue;
|
|
4795
|
+
if (!existsFn(row.implementation)) {
|
|
4662
4796
|
findings.push({
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
blocking: false
|
|
4797
|
+
row: row.action,
|
|
4798
|
+
path: row.implementation,
|
|
4799
|
+
reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
|
|
4667
4800
|
});
|
|
4668
4801
|
}
|
|
4669
4802
|
}
|
|
4670
|
-
|
|
4803
|
+
if (hookRefs)
|
|
4804
|
+
findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
|
|
4805
|
+
return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4671
4806
|
}
|
|
4672
|
-
var
|
|
4673
|
-
var
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
const
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
const next = i + 1 < n ? content[i + 1] : "";
|
|
4687
|
-
if (state === "code") {
|
|
4688
|
-
if (c === "/" && next === "/") {
|
|
4689
|
-
state = "line-comment";
|
|
4690
|
-
out += c;
|
|
4691
|
-
i++;
|
|
4692
|
-
continue;
|
|
4693
|
-
}
|
|
4694
|
-
if (c === "/" && next === "*") {
|
|
4695
|
-
state = "block-comment";
|
|
4696
|
-
out += c;
|
|
4697
|
-
i++;
|
|
4698
|
-
continue;
|
|
4699
|
-
}
|
|
4700
|
-
if (c === "'") {
|
|
4701
|
-
state = "single-quote";
|
|
4702
|
-
out += blank(c);
|
|
4703
|
-
i++;
|
|
4704
|
-
continue;
|
|
4705
|
-
}
|
|
4706
|
-
if (c === '"') {
|
|
4707
|
-
state = "double-quote";
|
|
4708
|
-
out += blank(c);
|
|
4709
|
-
i++;
|
|
4710
|
-
continue;
|
|
4711
|
-
}
|
|
4712
|
-
if (c === "`") {
|
|
4713
|
-
state = "template";
|
|
4714
|
-
out += blank(c);
|
|
4715
|
-
i++;
|
|
4716
|
-
continue;
|
|
4717
|
-
}
|
|
4718
|
-
out += blank(c);
|
|
4719
|
-
i++;
|
|
4807
|
+
var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
4808
|
+
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
4809
|
+
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
4810
|
+
"apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
|
|
4811
|
+
"apps/cli/src/checks/bin/check-issue-assignment.ts": `Ring 0 "A task branch's first push (Issue self-assignment)" (implementation: assign-task-issue.ts)`,
|
|
4812
|
+
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
4813
|
+
};
|
|
4814
|
+
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
4815
|
+
function checkG2(rows, candidateFiles) {
|
|
4816
|
+
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
4817
|
+
const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
|
|
4818
|
+
const findings = [];
|
|
4819
|
+
for (const path of candidateFiles) {
|
|
4820
|
+
if (implementations.has(path))
|
|
4720
4821
|
continue;
|
|
4721
|
-
|
|
4722
|
-
if (state === "line-comment") {
|
|
4723
|
-
if (c === `
|
|
4724
|
-
`) {
|
|
4725
|
-
state = "code";
|
|
4726
|
-
out += `
|
|
4727
|
-
`;
|
|
4728
|
-
i++;
|
|
4729
|
-
continue;
|
|
4730
|
-
}
|
|
4731
|
-
out += c;
|
|
4732
|
-
i++;
|
|
4822
|
+
if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
|
|
4733
4823
|
continue;
|
|
4734
|
-
|
|
4735
|
-
if (state === "block-comment") {
|
|
4736
|
-
if (c === "*" && next === "/") {
|
|
4737
|
-
out += c;
|
|
4738
|
-
out += next;
|
|
4739
|
-
state = "code";
|
|
4740
|
-
i += 2;
|
|
4741
|
-
continue;
|
|
4742
|
-
}
|
|
4743
|
-
out += c === `
|
|
4744
|
-
` ? `
|
|
4745
|
-
` : c;
|
|
4746
|
-
i++;
|
|
4824
|
+
if (NON_GATE_HOOK_SCRIPTS.includes(path))
|
|
4747
4825
|
continue;
|
|
4748
|
-
|
|
4749
|
-
const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
|
|
4750
|
-
if (c === "\\") {
|
|
4751
|
-
out += blank(c);
|
|
4752
|
-
i++;
|
|
4753
|
-
if (i < n) {
|
|
4754
|
-
out += blank(content[i]);
|
|
4755
|
-
i++;
|
|
4756
|
-
}
|
|
4826
|
+
if (path in TWIN_CANDIDATE_EXCEPTIONS)
|
|
4757
4827
|
continue;
|
|
4758
|
-
|
|
4759
|
-
if (
|
|
4760
|
-
state = "code";
|
|
4761
|
-
out += blank(c);
|
|
4762
|
-
i++;
|
|
4828
|
+
const candidateNames = claimedCheckNames(path);
|
|
4829
|
+
if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
|
|
4763
4830
|
continue;
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4831
|
+
findings.push({
|
|
4832
|
+
path,
|
|
4833
|
+
reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
|
|
4834
|
+
});
|
|
4767
4835
|
}
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
];
|
|
4777
|
-
for (const file of files) {
|
|
4778
|
-
if (!file.path.endsWith(".ts"))
|
|
4779
|
-
continue;
|
|
4780
|
-
if (allowed.has(file.path))
|
|
4781
|
-
continue;
|
|
4782
|
-
const comments = extractComments(file.path, file.content);
|
|
4783
|
-
for (const { pattern, what } of patterns) {
|
|
4784
|
-
pattern.lastIndex = 0;
|
|
4785
|
-
let match = pattern.exec(comments);
|
|
4786
|
-
while (match !== null) {
|
|
4787
|
-
findings.push({
|
|
4788
|
-
file: file.path,
|
|
4789
|
-
line: lineAt(comments, match.index),
|
|
4790
|
-
message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
|
|
4791
|
-
blocking: false
|
|
4792
|
-
});
|
|
4793
|
-
match = pattern.exec(comments);
|
|
4794
|
-
}
|
|
4836
|
+
for (const row of rows) {
|
|
4837
|
+
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
4838
|
+
if (carriesPlaceholder) {
|
|
4839
|
+
findings.push({
|
|
4840
|
+
row: row.action,
|
|
4841
|
+
path: row.implementation,
|
|
4842
|
+
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
4843
|
+
});
|
|
4795
4844
|
}
|
|
4796
4845
|
}
|
|
4797
|
-
return findings;
|
|
4798
|
-
}
|
|
4799
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4800
|
-
return [
|
|
4801
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
4802
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4803
|
-
];
|
|
4846
|
+
return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4804
4847
|
}
|
|
4805
|
-
function
|
|
4806
|
-
const
|
|
4807
|
-
const
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4848
|
+
function checkG3(ring0Rows, crossingFiles) {
|
|
4849
|
+
const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
|
|
4850
|
+
const findings = [];
|
|
4851
|
+
for (const path of crossingFiles) {
|
|
4852
|
+
if (!ring0Implementations.has(path)) {
|
|
4853
|
+
findings.push({
|
|
4854
|
+
path,
|
|
4855
|
+
reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
|
|
4856
|
+
});
|
|
4857
|
+
}
|
|
4813
4858
|
}
|
|
4814
|
-
return
|
|
4815
|
-
}
|
|
4816
|
-
|
|
4817
|
-
// ../../packages/aeg-core/src/quoted-command.ts
|
|
4818
|
-
var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
|
|
4819
|
-
var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
4820
|
-
var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
|
|
4821
|
-
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
4822
|
-
function isValidCitedFilePath(path) {
|
|
4823
|
-
if (path.length === 0)
|
|
4824
|
-
return false;
|
|
4825
|
-
if (path.startsWith("/") || path.startsWith("\\"))
|
|
4826
|
-
return false;
|
|
4827
|
-
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
4828
|
-
return false;
|
|
4829
|
-
return !path.split(/[\\/]+/).includes("..");
|
|
4859
|
+
return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4830
4860
|
}
|
|
4831
|
-
function
|
|
4832
|
-
|
|
4833
|
-
for (
|
|
4834
|
-
|
|
4835
|
-
line++;
|
|
4861
|
+
function checkG4(content, resolveFn) {
|
|
4862
|
+
const cited = new Set;
|
|
4863
|
+
for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
|
|
4864
|
+
cited.add(Number(hit[1]));
|
|
4836
4865
|
}
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
return (inline[1] ?? "").trim();
|
|
4847
|
-
return trimmed;
|
|
4866
|
+
const findings = [];
|
|
4867
|
+
for (const n of cited) {
|
|
4868
|
+
if (!resolveFn(n)) {
|
|
4869
|
+
findings.push({
|
|
4870
|
+
reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
|
|
4871
|
+
});
|
|
4872
|
+
}
|
|
4873
|
+
}
|
|
4874
|
+
return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4848
4875
|
}
|
|
4849
|
-
function
|
|
4850
|
-
const
|
|
4851
|
-
const
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
if (end === null) {
|
|
4859
|
-
START_PATTERN.lastIndex = innerStart;
|
|
4860
|
-
start = START_PATTERN.exec(masked);
|
|
4861
|
-
continue;
|
|
4876
|
+
function checkG5(roles, contracts) {
|
|
4877
|
+
const roleIds = new Set(roles.map((r) => r.role_id));
|
|
4878
|
+
const findings = [];
|
|
4879
|
+
for (const contract of contracts) {
|
|
4880
|
+
if (!roleIds.has(contract.producer)) {
|
|
4881
|
+
findings.push({
|
|
4882
|
+
path: contract.file,
|
|
4883
|
+
reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
|
|
4884
|
+
});
|
|
4862
4885
|
}
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
}
|
|
4886
|
+
if (!roleIds.has(contract.consumer)) {
|
|
4887
|
+
findings.push({
|
|
4888
|
+
path: contract.file,
|
|
4889
|
+
reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
|
|
4890
|
+
});
|
|
4869
4891
|
}
|
|
4870
|
-
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
4871
|
-
start = START_PATTERN.exec(masked);
|
|
4872
4892
|
}
|
|
4873
|
-
|
|
4893
|
+
for (const role of roles) {
|
|
4894
|
+
if (role.performs.length === 0) {
|
|
4895
|
+
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
|
|
4896
|
+
}
|
|
4897
|
+
if (role.refuses_when.trim() === "") {
|
|
4898
|
+
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4874
4902
|
}
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4903
|
+
var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
|
|
4904
|
+
var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
|
|
4905
|
+
function basenameNoExt(path) {
|
|
4906
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
4907
|
+
return base.replace(/\.ts$/, "");
|
|
4908
|
+
}
|
|
4909
|
+
function claimedCheckNames(implementation) {
|
|
4910
|
+
if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
|
|
4911
|
+
return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
|
|
4882
4912
|
}
|
|
4883
|
-
|
|
4913
|
+
if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
|
|
4914
|
+
const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
|
|
4915
|
+
if (audience && isShipped(audience)) {
|
|
4916
|
+
return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
return [];
|
|
4884
4920
|
}
|
|
4885
|
-
function
|
|
4921
|
+
function checkG6(rows, registeredCheckNames) {
|
|
4886
4922
|
const findings = [];
|
|
4887
|
-
for (const
|
|
4888
|
-
|
|
4889
|
-
if (content === undefined) {
|
|
4890
|
-
findings.push({
|
|
4891
|
-
file: quote.file,
|
|
4892
|
-
line: quote.line,
|
|
4893
|
-
citedFile: quote.citedFile,
|
|
4894
|
-
quotedText: quote.quotedText,
|
|
4895
|
-
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
4896
|
-
});
|
|
4923
|
+
for (const row of rows) {
|
|
4924
|
+
if (row.audience !== "product")
|
|
4897
4925
|
continue;
|
|
4898
|
-
|
|
4899
|
-
if (!
|
|
4926
|
+
const candidates = claimedCheckNames(row.implementation);
|
|
4927
|
+
if (!candidates.some((name) => registeredCheckNames.has(name))) {
|
|
4900
4928
|
findings.push({
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
quotedText: quote.quotedText,
|
|
4905
|
-
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
4929
|
+
row: row.action,
|
|
4930
|
+
path: row.implementation,
|
|
4931
|
+
reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
|
|
4906
4932
|
});
|
|
4907
4933
|
}
|
|
4908
4934
|
}
|
|
4909
|
-
return findings;
|
|
4935
|
+
return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4910
4936
|
}
|
|
4911
4937
|
// ../../packages/aeg-core/src/dead-branch-push-guard.ts
|
|
4912
4938
|
function checkDeadBranchPush(input) {
|
|
@@ -5329,7 +5355,6 @@ var TaskPrPauseSchema = z.object({
|
|
|
5329
5355
|
var TaskPrReviewRecordSchema = z.object({
|
|
5330
5356
|
verdicts: z.array(TaskPrVerdictSchema),
|
|
5331
5357
|
roundMarkers: z.array(z.number().int().nonnegative()),
|
|
5332
|
-
summaryTable: z.string().nullable(),
|
|
5333
5358
|
pause: TaskPrPauseSchema.nullable()
|
|
5334
5359
|
});
|
|
5335
5360
|
var TaskPrReadInputSchema = z.object({
|
|
@@ -5376,16 +5401,6 @@ var TaskCancelResultSchema = z.object({
|
|
|
5376
5401
|
authenticatedFrom: z.string().min(1),
|
|
5377
5402
|
fencedEffectKeys: z.array(z.string())
|
|
5378
5403
|
});
|
|
5379
|
-
var TASK_TOOL_NAMES = [
|
|
5380
|
-
"task_start",
|
|
5381
|
-
"task_status",
|
|
5382
|
-
"task_escalation_read",
|
|
5383
|
-
"task_pr_read",
|
|
5384
|
-
"task_resume",
|
|
5385
|
-
"task_cancel"
|
|
5386
|
-
];
|
|
5387
|
-
var OPERATOR_STATUS_FOLLOW = "task_status_follow";
|
|
5388
|
-
var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
|
|
5389
5404
|
// ../../packages/aeg-core/src/first-push-dispatch-gate.ts
|
|
5390
5405
|
function parseTaskBranch(branch) {
|
|
5391
5406
|
const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
|
|
@@ -5616,15 +5631,69 @@ var NO_GATE_CUTOVERS = {
|
|
|
5616
5631
|
briefRulesSincePr: null,
|
|
5617
5632
|
agentBoxesRefusedSincePr: null
|
|
5618
5633
|
};
|
|
5619
|
-
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5620
|
-
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5621
|
-
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
5622
|
-
var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
|
|
5623
|
-
// ../../packages/aeg-core/src/log/envelope.ts
|
|
5624
|
-
import { createHash as createHash5 } from "node:crypto";
|
|
5625
|
-
|
|
5626
5634
|
// ../../packages/aeg-core/src/log/schema.ts
|
|
5635
|
+
import { z as z3 } from "zod";
|
|
5636
|
+
|
|
5637
|
+
// ../../packages/aeg-core/src/log/custom.ts
|
|
5627
5638
|
import { z as z2 } from "zod";
|
|
5639
|
+
var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
|
|
5640
|
+
var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
|
|
5641
|
+
var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
|
|
5642
|
+
var CUSTOM_EVENT_MAX_FIELDS = 20;
|
|
5643
|
+
var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
5644
|
+
var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
|
|
5645
|
+
var CUSTOM_TEXT_MAX_LENGTH = 500;
|
|
5646
|
+
var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
5647
|
+
var CUSTOM_WORD_MAX_LENGTH = 64;
|
|
5648
|
+
var CUSTOM_FIELD_MAX_WORDS = 50;
|
|
5649
|
+
var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
|
|
5650
|
+
var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
|
|
5651
|
+
fields: z2.record(z2.string(), CustomFieldTypeSchema)
|
|
5652
|
+
}).strict()).superRefine((events, ctx) => {
|
|
5653
|
+
for (const [name, declaration] of Object.entries(events)) {
|
|
5654
|
+
const refuse = (message, path = []) => {
|
|
5655
|
+
ctx.addIssue({
|
|
5656
|
+
code: z2.ZodIssueCode.custom,
|
|
5657
|
+
path: [name, ...path],
|
|
5658
|
+
message: `logs.events "${name}": ${message}`
|
|
5659
|
+
});
|
|
5660
|
+
};
|
|
5661
|
+
if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
|
|
5662
|
+
refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
|
|
5663
|
+
}
|
|
5664
|
+
if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
|
|
5665
|
+
refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
|
|
5666
|
+
} else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
|
|
5667
|
+
refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
|
|
5668
|
+
}
|
|
5669
|
+
const fieldEntries = Object.entries(declaration.fields);
|
|
5670
|
+
if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
|
|
5671
|
+
refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
|
|
5672
|
+
}
|
|
5673
|
+
for (const [field, type] of fieldEntries) {
|
|
5674
|
+
if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
|
|
5675
|
+
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]);
|
|
5676
|
+
}
|
|
5677
|
+
if (typeof type === "string")
|
|
5678
|
+
continue;
|
|
5679
|
+
if (type.length === 0) {
|
|
5680
|
+
refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
|
|
5681
|
+
}
|
|
5682
|
+
if (type.length > CUSTOM_FIELD_MAX_WORDS) {
|
|
5683
|
+
refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
|
|
5684
|
+
}
|
|
5685
|
+
const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
|
|
5686
|
+
if (bad.length > 0) {
|
|
5687
|
+
refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
|
|
5688
|
+
}
|
|
5689
|
+
if (new Set(type).size !== type.length) {
|
|
5690
|
+
refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
}
|
|
5694
|
+
});
|
|
5695
|
+
|
|
5696
|
+
// ../../packages/aeg-core/src/log/schema.ts
|
|
5628
5697
|
var CONFIDENCE_REASON_MAX_LENGTH = 280;
|
|
5629
5698
|
var ROLE_VALUES = [
|
|
5630
5699
|
"planner",
|
|
@@ -5635,244 +5704,297 @@ var ROLE_VALUES = [
|
|
|
5635
5704
|
"archivist",
|
|
5636
5705
|
"architect"
|
|
5637
5706
|
];
|
|
5638
|
-
var RoleSchema =
|
|
5707
|
+
var RoleSchema = z3.enum(ROLE_VALUES);
|
|
5639
5708
|
var HOST_VALUES = ["hook", "ci", "cli", "loop"];
|
|
5640
|
-
var HostSchema =
|
|
5709
|
+
var HostSchema = z3.enum(HOST_VALUES);
|
|
5641
5710
|
var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
|
|
5642
5711
|
var headerMetaCore = {
|
|
5643
|
-
ts:
|
|
5644
|
-
run_id:
|
|
5645
|
-
seq:
|
|
5646
|
-
repo:
|
|
5647
|
-
vinaya:
|
|
5648
|
-
doctrine:
|
|
5712
|
+
ts: z3.string(),
|
|
5713
|
+
run_id: z3.string().regex(RUN_ID_PATTERN),
|
|
5714
|
+
seq: z3.number().int().nonnegative(),
|
|
5715
|
+
repo: z3.string().nullable(),
|
|
5716
|
+
vinaya: z3.string(),
|
|
5717
|
+
doctrine: z3.string(),
|
|
5649
5718
|
host: HostSchema,
|
|
5650
|
-
machine:
|
|
5719
|
+
machine: z3.string()
|
|
5651
5720
|
};
|
|
5652
|
-
var HeaderMetaV1Schema =
|
|
5653
|
-
schema:
|
|
5721
|
+
var HeaderMetaV1Schema = z3.object({
|
|
5722
|
+
schema: z3.literal(1),
|
|
5654
5723
|
...headerMetaCore
|
|
5655
5724
|
}).strict();
|
|
5656
|
-
var LineageSchema =
|
|
5657
|
-
run:
|
|
5658
|
-
attempt:
|
|
5659
|
-
parent:
|
|
5725
|
+
var LineageSchema = z3.object({
|
|
5726
|
+
run: z3.string().nullable(),
|
|
5727
|
+
attempt: z3.number().int().nullable(),
|
|
5728
|
+
parent: z3.string().nullable()
|
|
5660
5729
|
}).strict();
|
|
5661
|
-
var InputVersionsSchema =
|
|
5662
|
-
objectives_version:
|
|
5663
|
-
brief_hash:
|
|
5664
|
-
ruling_ordinal:
|
|
5665
|
-
policy_digest:
|
|
5730
|
+
var InputVersionsSchema = z3.object({
|
|
5731
|
+
objectives_version: z3.string().nullable(),
|
|
5732
|
+
brief_hash: z3.string().nullable(),
|
|
5733
|
+
ruling_ordinal: z3.number().int().nullable(),
|
|
5734
|
+
policy_digest: z3.string().nullable()
|
|
5666
5735
|
}).strict();
|
|
5667
|
-
var ProvenanceSchema =
|
|
5668
|
-
var HeaderMetaV2Schema =
|
|
5669
|
-
schema:
|
|
5736
|
+
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
5737
|
+
var HeaderMetaV2Schema = z3.object({
|
|
5738
|
+
schema: z3.literal(2),
|
|
5670
5739
|
...headerMetaCore,
|
|
5671
|
-
event_id:
|
|
5672
|
-
process_id:
|
|
5673
|
-
actor_id:
|
|
5740
|
+
event_id: z3.string().min(1),
|
|
5741
|
+
process_id: z3.string().min(1),
|
|
5742
|
+
actor_id: z3.string().nullable(),
|
|
5674
5743
|
lineage: LineageSchema,
|
|
5675
5744
|
input_versions: InputVersionsSchema,
|
|
5676
5745
|
provenance: ProvenanceSchema
|
|
5677
5746
|
}).strict();
|
|
5678
|
-
var
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5747
|
+
var WorkSchema = z3.object({
|
|
5748
|
+
ref: z3.string().nullable(),
|
|
5749
|
+
repo: z3.string().nullable(),
|
|
5750
|
+
change: z3.string().nullable(),
|
|
5751
|
+
revision: z3.string().nullable()
|
|
5752
|
+
}).strict();
|
|
5753
|
+
var FlowSchema = z3.object({
|
|
5754
|
+
id: z3.string().nullable(),
|
|
5755
|
+
version: z3.string().nullable()
|
|
5756
|
+
}).strict();
|
|
5757
|
+
var HeaderMetaV3Schema = z3.object({
|
|
5758
|
+
schema: z3.literal(3),
|
|
5759
|
+
...headerMetaCore,
|
|
5760
|
+
event_id: z3.string().min(1),
|
|
5761
|
+
process_id: z3.string().min(1),
|
|
5762
|
+
actor_id: z3.string().nullable(),
|
|
5763
|
+
lineage: LineageSchema,
|
|
5764
|
+
input_versions: InputVersionsSchema,
|
|
5765
|
+
provenance: ProvenanceSchema,
|
|
5766
|
+
work: WorkSchema,
|
|
5767
|
+
flow: FlowSchema,
|
|
5768
|
+
runtime: z3.string().nullable(),
|
|
5769
|
+
source: z3.string().nullable()
|
|
5770
|
+
}).strict();
|
|
5771
|
+
var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
|
|
5772
|
+
var SubjectSchema = z3.object({
|
|
5773
|
+
issue: z3.number().int().nullable(),
|
|
5774
|
+
pr: z3.number().int().optional(),
|
|
5775
|
+
sha: z3.string().optional(),
|
|
5776
|
+
role: z3.union([RoleSchema, z3.literal("unattributed")]),
|
|
5777
|
+
round: z3.number().int().optional(),
|
|
5778
|
+
objectives_version: z3.string().optional()
|
|
5686
5779
|
}).strict();
|
|
5687
|
-
var HeaderSchema =
|
|
5780
|
+
var HeaderSchema = z3.object({
|
|
5688
5781
|
meta: HeaderMetaSchema,
|
|
5689
5782
|
subject: SubjectSchema
|
|
5690
5783
|
}).strict();
|
|
5691
5784
|
var envelopeTail = {
|
|
5692
|
-
duration_ms:
|
|
5693
|
-
payload:
|
|
5785
|
+
duration_ms: z3.number().nonnegative().optional(),
|
|
5786
|
+
payload: z3.object({}).strict()
|
|
5694
5787
|
};
|
|
5695
|
-
var ReviewFindingSchema =
|
|
5696
|
-
id:
|
|
5697
|
-
severity:
|
|
5698
|
-
state:
|
|
5699
|
-
severity_scale:
|
|
5700
|
-
policy_treatment:
|
|
5701
|
-
confidence:
|
|
5702
|
-
confidence_scale:
|
|
5703
|
-
confidence_source:
|
|
5788
|
+
var ReviewFindingSchema = z3.object({
|
|
5789
|
+
id: z3.string(),
|
|
5790
|
+
severity: z3.string(),
|
|
5791
|
+
state: z3.string().optional(),
|
|
5792
|
+
severity_scale: z3.string().optional(),
|
|
5793
|
+
policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
|
|
5794
|
+
confidence: z3.number().min(0).max(1).optional(),
|
|
5795
|
+
confidence_scale: z3.string().optional(),
|
|
5796
|
+
confidence_source: z3.string().optional()
|
|
5704
5797
|
}).strict();
|
|
5705
|
-
var DispatchOutcomeSchema =
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
type:
|
|
5709
|
-
pr:
|
|
5710
|
-
head:
|
|
5711
|
-
comment_id:
|
|
5798
|
+
var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
|
|
5799
|
+
z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
|
|
5800
|
+
z3.object({
|
|
5801
|
+
type: z3.literal("round_pushed"),
|
|
5802
|
+
pr: z3.number().int(),
|
|
5803
|
+
head: z3.string(),
|
|
5804
|
+
comment_id: z3.number().int()
|
|
5712
5805
|
}).strict(),
|
|
5713
|
-
|
|
5714
|
-
type:
|
|
5715
|
-
verdict:
|
|
5716
|
-
head:
|
|
5717
|
-
comment_id:
|
|
5718
|
-
objectives:
|
|
5719
|
-
findings:
|
|
5806
|
+
z3.object({
|
|
5807
|
+
type: z3.literal("verdict"),
|
|
5808
|
+
verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
|
|
5809
|
+
head: z3.string(),
|
|
5810
|
+
comment_id: z3.number().int(),
|
|
5811
|
+
objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
|
|
5812
|
+
findings: z3.array(ReviewFindingSchema)
|
|
5720
5813
|
}).strict(),
|
|
5721
|
-
|
|
5722
|
-
type:
|
|
5723
|
-
class:
|
|
5724
|
-
comment_id:
|
|
5814
|
+
z3.object({
|
|
5815
|
+
type: z3.literal("escalation"),
|
|
5816
|
+
class: z3.enum(["authority", "strategy", "product"]),
|
|
5817
|
+
comment_id: z3.number().int()
|
|
5725
5818
|
}).strict(),
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5819
|
+
z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
|
|
5820
|
+
z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
|
|
5821
|
+
z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
|
|
5822
|
+
z3.object({ type: z3.literal("completed") }).strict()
|
|
5730
5823
|
]);
|
|
5731
5824
|
var dispatchShared = {
|
|
5732
5825
|
meta: HeaderMetaSchema,
|
|
5733
5826
|
subject: SubjectSchema,
|
|
5734
|
-
kind:
|
|
5827
|
+
kind: z3.literal("dispatch"),
|
|
5735
5828
|
...envelopeTail,
|
|
5736
5829
|
target_role: RoleSchema,
|
|
5737
|
-
model:
|
|
5738
|
-
round:
|
|
5739
|
-
effect_id:
|
|
5830
|
+
model: z3.string(),
|
|
5831
|
+
round: z3.number().int().optional(),
|
|
5832
|
+
effect_id: z3.string()
|
|
5740
5833
|
};
|
|
5741
|
-
var dispatchUsageField =
|
|
5742
|
-
var DispatchEventSchema =
|
|
5743
|
-
|
|
5744
|
-
|
|
5834
|
+
var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
|
|
5835
|
+
var DispatchEventSchema = z3.discriminatedUnion("event", [
|
|
5836
|
+
z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
|
|
5837
|
+
z3.object({
|
|
5745
5838
|
...dispatchShared,
|
|
5746
|
-
event:
|
|
5839
|
+
event: z3.literal("outcome_received"),
|
|
5747
5840
|
outcome: DispatchOutcomeSchema,
|
|
5748
5841
|
usage: dispatchUsageField
|
|
5749
5842
|
}).strict(),
|
|
5750
|
-
|
|
5843
|
+
z3.object({
|
|
5751
5844
|
...dispatchShared,
|
|
5752
|
-
event:
|
|
5753
|
-
reason:
|
|
5845
|
+
event: z3.literal("dispatch_failed"),
|
|
5846
|
+
reason: z3.enum(["timeout", "crash", "refused", "unattributed_write"]),
|
|
5754
5847
|
usage: dispatchUsageField
|
|
5755
5848
|
}).strict()
|
|
5756
5849
|
]);
|
|
5850
|
+
var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
|
|
5851
|
+
var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
|
|
5852
|
+
var ReviewerVerdictSchema = z3.object({
|
|
5853
|
+
role: RoleSchema,
|
|
5854
|
+
outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
|
|
5855
|
+
blockers: z3.number().int().nonnegative()
|
|
5856
|
+
}).strict();
|
|
5757
5857
|
var loopShared = {
|
|
5758
5858
|
meta: HeaderMetaSchema,
|
|
5759
5859
|
subject: SubjectSchema,
|
|
5760
|
-
kind:
|
|
5860
|
+
kind: z3.literal("dev_review_loop"),
|
|
5761
5861
|
...envelopeTail,
|
|
5762
|
-
loop_id:
|
|
5862
|
+
loop_id: z3.string()
|
|
5763
5863
|
};
|
|
5764
|
-
var DevReviewLoopEventSchema =
|
|
5765
|
-
|
|
5864
|
+
var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
|
|
5865
|
+
z3.object({
|
|
5766
5866
|
...loopShared,
|
|
5767
|
-
event:
|
|
5768
|
-
task:
|
|
5769
|
-
policy:
|
|
5770
|
-
max_rounds:
|
|
5771
|
-
reviewers:
|
|
5772
|
-
models:
|
|
5867
|
+
event: z3.literal("loop_started"),
|
|
5868
|
+
task: z3.number().int(),
|
|
5869
|
+
policy: z3.object({
|
|
5870
|
+
max_rounds: z3.number().int().nonnegative(),
|
|
5871
|
+
reviewers: z3.array(RoleSchema),
|
|
5872
|
+
models: z3.record(RoleSchema, z3.string())
|
|
5773
5873
|
}).strict()
|
|
5774
5874
|
}).strict(),
|
|
5775
|
-
|
|
5776
|
-
|
|
5875
|
+
z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
|
|
5876
|
+
z3.object({
|
|
5777
5877
|
...loopShared,
|
|
5778
|
-
event:
|
|
5779
|
-
round:
|
|
5780
|
-
head:
|
|
5781
|
-
green:
|
|
5782
|
-
confidence_value:
|
|
5783
|
-
confidence_reason:
|
|
5784
|
-
confidence_unavailable:
|
|
5785
|
-
extra_turn_spent:
|
|
5878
|
+
event: z3.literal("gate_result_read"),
|
|
5879
|
+
round: z3.number().int(),
|
|
5880
|
+
head: z3.string(),
|
|
5881
|
+
green: z3.boolean(),
|
|
5882
|
+
confidence_value: z3.number().int().min(0).max(100).optional(),
|
|
5883
|
+
confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
|
|
5884
|
+
confidence_unavailable: z3.boolean().optional(),
|
|
5885
|
+
extra_turn_spent: z3.boolean().optional()
|
|
5786
5886
|
}).strict(),
|
|
5787
|
-
|
|
5887
|
+
z3.object({
|
|
5788
5888
|
...loopShared,
|
|
5789
|
-
event:
|
|
5790
|
-
round:
|
|
5791
|
-
head:
|
|
5792
|
-
all_approve:
|
|
5793
|
-
blockers:
|
|
5794
|
-
findings:
|
|
5889
|
+
event: z3.literal("verdicts_read"),
|
|
5890
|
+
round: z3.number().int(),
|
|
5891
|
+
head: z3.string(),
|
|
5892
|
+
all_approve: z3.boolean(),
|
|
5893
|
+
blockers: z3.number().int().nonnegative(),
|
|
5894
|
+
findings: z3.array(ReviewFindingSchema).optional(),
|
|
5895
|
+
reviewers: z3.array(ReviewerVerdictSchema).optional()
|
|
5795
5896
|
}).strict(),
|
|
5796
|
-
|
|
5897
|
+
z3.object({
|
|
5797
5898
|
...loopShared,
|
|
5798
|
-
event:
|
|
5799
|
-
round:
|
|
5800
|
-
open:
|
|
5801
|
-
resolved:
|
|
5802
|
-
new:
|
|
5803
|
-
recurring:
|
|
5899
|
+
event: z3.literal("findings_compared"),
|
|
5900
|
+
round: z3.number().int(),
|
|
5901
|
+
open: z3.array(z3.string()),
|
|
5902
|
+
resolved: z3.array(z3.string()),
|
|
5903
|
+
new: z3.array(z3.string()),
|
|
5904
|
+
recurring: z3.array(z3.string())
|
|
5804
5905
|
}).strict(),
|
|
5805
|
-
|
|
5906
|
+
z3.object({
|
|
5806
5907
|
...loopShared,
|
|
5807
|
-
event:
|
|
5808
|
-
round:
|
|
5809
|
-
condition:
|
|
5908
|
+
event: z3.literal("stop_condition_met"),
|
|
5909
|
+
round: z3.number().int(),
|
|
5910
|
+
condition: z3.enum([
|
|
5810
5911
|
"green",
|
|
5811
5912
|
"max_rounds",
|
|
5812
5913
|
"no_progress",
|
|
5813
5914
|
"escalated",
|
|
5814
5915
|
"principal_stop",
|
|
5815
5916
|
"confidence",
|
|
5816
|
-
"reappearance"
|
|
5917
|
+
"reappearance",
|
|
5918
|
+
"repeat_finding",
|
|
5919
|
+
"repeat_failure",
|
|
5920
|
+
"time_budget"
|
|
5817
5921
|
])
|
|
5818
5922
|
}).strict(),
|
|
5819
|
-
|
|
5923
|
+
z3.object({
|
|
5924
|
+
...loopShared,
|
|
5925
|
+
event: z3.literal("paused"),
|
|
5926
|
+
round: z3.number().int(),
|
|
5927
|
+
reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
|
|
5928
|
+
reason_code: CodeTokenSchema.optional()
|
|
5929
|
+
}).strict(),
|
|
5930
|
+
z3.object({
|
|
5931
|
+
...loopShared,
|
|
5932
|
+
event: z3.literal("resumed"),
|
|
5933
|
+
round: z3.number().int(),
|
|
5934
|
+
by: z3.enum(["principal", "driver"])
|
|
5935
|
+
}).strict(),
|
|
5936
|
+
z3.object({
|
|
5820
5937
|
...loopShared,
|
|
5821
|
-
event:
|
|
5822
|
-
round:
|
|
5823
|
-
|
|
5938
|
+
event: z3.literal("cancelled"),
|
|
5939
|
+
round: z3.number().int(),
|
|
5940
|
+
by: z3.literal("principal")
|
|
5824
5941
|
}).strict(),
|
|
5825
|
-
|
|
5942
|
+
z3.object({
|
|
5826
5943
|
...loopShared,
|
|
5827
|
-
event:
|
|
5828
|
-
round:
|
|
5829
|
-
|
|
5944
|
+
event: z3.literal("unpushed_work_resume"),
|
|
5945
|
+
round: z3.number().int(),
|
|
5946
|
+
branch: z3.string(),
|
|
5947
|
+
detail: z3.string()
|
|
5830
5948
|
}).strict(),
|
|
5831
|
-
|
|
5949
|
+
z3.object({
|
|
5832
5950
|
...loopShared,
|
|
5833
|
-
event:
|
|
5834
|
-
round:
|
|
5835
|
-
|
|
5951
|
+
event: z3.literal("round_ended"),
|
|
5952
|
+
round: z3.number().int(),
|
|
5953
|
+
base_head: z3.string(),
|
|
5954
|
+
head: z3.string(),
|
|
5955
|
+
files_changed: z3.number().int().nonnegative(),
|
|
5956
|
+
insertions: z3.number().int().nonnegative(),
|
|
5957
|
+
deletions: z3.number().int().nonnegative(),
|
|
5958
|
+
wall_ms: z3.number().nonnegative(),
|
|
5959
|
+
outcome: z3.enum(["green", "changes_requested", "escalated"])
|
|
5836
5960
|
}).strict(),
|
|
5837
|
-
|
|
5961
|
+
z3.object({
|
|
5838
5962
|
...loopShared,
|
|
5839
|
-
event:
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5963
|
+
event: z3.literal("journal_finalized"),
|
|
5964
|
+
rounds: z3.number().int().nonnegative(),
|
|
5965
|
+
total_wall_ms: z3.number().nonnegative(),
|
|
5966
|
+
time_to_green_ms: z3.number().nonnegative().nullable(),
|
|
5967
|
+
files_changed_total: z3.number().int().nonnegative(),
|
|
5968
|
+
final_head: z3.string(),
|
|
5969
|
+
result: z3.enum(["merged_ready", "stopped"])
|
|
5843
5970
|
}).strict(),
|
|
5844
|
-
|
|
5971
|
+
z3.object({
|
|
5845
5972
|
...loopShared,
|
|
5846
|
-
event:
|
|
5847
|
-
round:
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
insertions: z2.number().int().nonnegative(),
|
|
5852
|
-
deletions: z2.number().int().nonnegative(),
|
|
5853
|
-
wall_ms: z2.number().nonnegative(),
|
|
5854
|
-
outcome: z2.enum(["green", "changes_requested", "escalated"])
|
|
5973
|
+
event: z3.literal("infrastructure_retry"),
|
|
5974
|
+
round: z3.number().int(),
|
|
5975
|
+
failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
|
|
5976
|
+
attempts: z3.number().int().positive(),
|
|
5977
|
+
outcome: z3.enum(["recovered", "exhausted"])
|
|
5855
5978
|
}).strict(),
|
|
5856
|
-
|
|
5979
|
+
z3.object({
|
|
5857
5980
|
...loopShared,
|
|
5858
|
-
event:
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
final_head: z2.string(),
|
|
5864
|
-
result: z2.enum(["merged_ready", "stopped"])
|
|
5981
|
+
event: z3.literal("driver_heartbeat"),
|
|
5982
|
+
task: z3.number().int(),
|
|
5983
|
+
pr: z3.number().int().positive().optional(),
|
|
5984
|
+
round: z3.number().int(),
|
|
5985
|
+
phase: z3.string()
|
|
5865
5986
|
}).strict(),
|
|
5866
|
-
|
|
5987
|
+
z3.object({
|
|
5867
5988
|
...loopShared,
|
|
5868
|
-
event:
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5989
|
+
event: z3.literal("driver_exited"),
|
|
5990
|
+
task: z3.number().int(),
|
|
5991
|
+
reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
|
|
5992
|
+
last_decision: z3.string(),
|
|
5993
|
+
exit_code: z3.number().int().optional(),
|
|
5994
|
+
error_class: CodeTokenSchema.optional()
|
|
5873
5995
|
}).strict()
|
|
5874
5996
|
]);
|
|
5875
|
-
var ForgeOpSchema =
|
|
5997
|
+
var ForgeOpSchema = z3.enum([
|
|
5876
5998
|
"pr.create",
|
|
5877
5999
|
"pr.comment",
|
|
5878
6000
|
"pr.body.replace",
|
|
@@ -5886,24 +6008,24 @@ var ForgeOpSchema = z2.enum([
|
|
|
5886
6008
|
"label.add",
|
|
5887
6009
|
"label.remove"
|
|
5888
6010
|
]);
|
|
5889
|
-
var ForgeWriteTargetSchema =
|
|
5890
|
-
issue:
|
|
5891
|
-
pr:
|
|
6011
|
+
var ForgeWriteTargetSchema = z3.object({
|
|
6012
|
+
issue: z3.number().int().optional(),
|
|
6013
|
+
pr: z3.number().int().optional()
|
|
5892
6014
|
}).strict();
|
|
5893
6015
|
var forgeWriteShared = {
|
|
5894
6016
|
meta: HeaderMetaSchema,
|
|
5895
6017
|
subject: SubjectSchema,
|
|
5896
|
-
kind:
|
|
6018
|
+
kind: z3.literal("forge_write"),
|
|
5897
6019
|
...envelopeTail,
|
|
5898
6020
|
op: ForgeOpSchema,
|
|
5899
6021
|
target: ForgeWriteTargetSchema
|
|
5900
6022
|
};
|
|
5901
|
-
var ForgeWriteEventSchema =
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
6023
|
+
var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
|
|
6024
|
+
z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
|
|
6025
|
+
z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
|
|
6026
|
+
z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
|
|
5905
6027
|
]);
|
|
5906
|
-
var GateOutcomeSchema =
|
|
6028
|
+
var GateOutcomeSchema = z3.enum([
|
|
5907
6029
|
"pass",
|
|
5908
6030
|
"fail",
|
|
5909
6031
|
"wait",
|
|
@@ -5916,61 +6038,74 @@ var GateOutcomeSchema = z2.enum([
|
|
|
5916
6038
|
var gateShared = {
|
|
5917
6039
|
meta: HeaderMetaSchema,
|
|
5918
6040
|
subject: SubjectSchema,
|
|
5919
|
-
kind:
|
|
6041
|
+
kind: z3.literal("gate"),
|
|
5920
6042
|
...envelopeTail,
|
|
5921
|
-
check:
|
|
5922
|
-
check_version:
|
|
5923
|
-
policy_version:
|
|
5924
|
-
input_fingerprint:
|
|
6043
|
+
check: z3.string(),
|
|
6044
|
+
check_version: z3.string().nullable(),
|
|
6045
|
+
policy_version: z3.string().nullable(),
|
|
6046
|
+
input_fingerprint: z3.string().nullable()
|
|
5925
6047
|
};
|
|
5926
|
-
var GateEventSchema =
|
|
5927
|
-
|
|
6048
|
+
var GateEventSchema = z3.discriminatedUnion("event", [
|
|
6049
|
+
z3.object({
|
|
5928
6050
|
...gateShared,
|
|
5929
|
-
event:
|
|
6051
|
+
event: z3.literal("checked"),
|
|
5930
6052
|
outcome: GateOutcomeSchema,
|
|
5931
|
-
reason:
|
|
6053
|
+
reason: z3.string().optional()
|
|
6054
|
+
}).strict(),
|
|
6055
|
+
z3.object({
|
|
6056
|
+
meta: HeaderMetaSchema,
|
|
6057
|
+
subject: SubjectSchema,
|
|
6058
|
+
kind: z3.literal("gate"),
|
|
6059
|
+
...envelopeTail,
|
|
6060
|
+
event: z3.literal("summary"),
|
|
6061
|
+
ran: z3.number().int().nonnegative(),
|
|
6062
|
+
passed: z3.number().int().nonnegative(),
|
|
6063
|
+
failed: z3.number().int().nonnegative(),
|
|
6064
|
+
skipped: z3.number().int().nonnegative(),
|
|
6065
|
+
failed_checks: z3.array(z3.string())
|
|
5932
6066
|
}).strict()
|
|
5933
6067
|
]);
|
|
5934
|
-
var OperationResultSchema =
|
|
6068
|
+
var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
|
|
5935
6069
|
var operationShared = {
|
|
5936
6070
|
meta: HeaderMetaSchema,
|
|
5937
6071
|
subject: SubjectSchema,
|
|
5938
|
-
kind:
|
|
6072
|
+
kind: z3.literal("operation"),
|
|
5939
6073
|
...envelopeTail,
|
|
5940
|
-
operation:
|
|
5941
|
-
target:
|
|
6074
|
+
operation: z3.string(),
|
|
6075
|
+
target: z3.string().nullable()
|
|
5942
6076
|
};
|
|
5943
|
-
var OperationEventSchema =
|
|
5944
|
-
|
|
6077
|
+
var OperationEventSchema = z3.discriminatedUnion("event", [
|
|
6078
|
+
z3.object({
|
|
5945
6079
|
...operationShared,
|
|
5946
|
-
event:
|
|
6080
|
+
event: z3.literal("completed"),
|
|
5947
6081
|
result: OperationResultSchema,
|
|
5948
|
-
error_class:
|
|
6082
|
+
error_class: z3.string().nullable(),
|
|
6083
|
+
field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
|
|
5949
6084
|
}).strict()
|
|
5950
6085
|
]);
|
|
5951
|
-
var UsageUnitsSchema =
|
|
5952
|
-
input:
|
|
5953
|
-
output:
|
|
5954
|
-
cache:
|
|
6086
|
+
var UsageUnitsSchema = z3.object({
|
|
6087
|
+
input: z3.number().nonnegative().nullable(),
|
|
6088
|
+
output: z3.number().nonnegative().nullable(),
|
|
6089
|
+
cache: z3.number().nonnegative().nullable()
|
|
5955
6090
|
}).strict();
|
|
5956
6091
|
var usageShared = {
|
|
5957
6092
|
meta: HeaderMetaSchema,
|
|
5958
6093
|
subject: SubjectSchema,
|
|
5959
|
-
kind:
|
|
6094
|
+
kind: z3.literal("usage"),
|
|
5960
6095
|
...envelopeTail,
|
|
5961
|
-
model:
|
|
5962
|
-
source:
|
|
5963
|
-
semantics:
|
|
6096
|
+
model: z3.string().nullable(),
|
|
6097
|
+
source: z3.string(),
|
|
6098
|
+
semantics: z3.enum(["cumulative", "delta"])
|
|
5964
6099
|
};
|
|
5965
|
-
var UsageEventSchema =
|
|
5966
|
-
|
|
6100
|
+
var UsageEventSchema = z3.discriminatedUnion("event", [
|
|
6101
|
+
z3.object({
|
|
5967
6102
|
...usageShared,
|
|
5968
|
-
event:
|
|
6103
|
+
event: z3.literal("observed"),
|
|
5969
6104
|
units: UsageUnitsSchema,
|
|
5970
|
-
unknown_reason:
|
|
6105
|
+
unknown_reason: z3.string().nullable()
|
|
5971
6106
|
}).strict()
|
|
5972
6107
|
]);
|
|
5973
|
-
var RoleAttemptOutcomeSchema =
|
|
6108
|
+
var RoleAttemptOutcomeSchema = z3.enum([
|
|
5974
6109
|
"completed",
|
|
5975
6110
|
"incomplete",
|
|
5976
6111
|
"infrastructure_failed",
|
|
@@ -5981,17 +6116,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
|
|
|
5981
6116
|
var roleAttemptShared = {
|
|
5982
6117
|
meta: HeaderMetaSchema,
|
|
5983
6118
|
subject: SubjectSchema,
|
|
5984
|
-
kind:
|
|
6119
|
+
kind: z3.literal("role_attempt"),
|
|
5985
6120
|
...envelopeTail,
|
|
5986
|
-
actor:
|
|
5987
|
-
attempt:
|
|
5988
|
-
effect_id:
|
|
5989
|
-
model:
|
|
6121
|
+
actor: z3.string().nullable(),
|
|
6122
|
+
attempt: z3.number().int().nullable(),
|
|
6123
|
+
effect_id: z3.string(),
|
|
6124
|
+
model: z3.string().nullable()
|
|
5990
6125
|
};
|
|
5991
|
-
var RoleAttemptEventSchema =
|
|
5992
|
-
|
|
6126
|
+
var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
|
|
6127
|
+
z3.object({
|
|
5993
6128
|
...roleAttemptShared,
|
|
5994
|
-
event:
|
|
6129
|
+
event: z3.literal("attempted"),
|
|
5995
6130
|
outcome: RoleAttemptOutcomeSchema,
|
|
5996
6131
|
usage: dispatchUsageField
|
|
5997
6132
|
}).strict()
|
|
@@ -5999,42 +6134,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
|
|
|
5999
6134
|
var handoffShared = {
|
|
6000
6135
|
meta: HeaderMetaSchema,
|
|
6001
6136
|
subject: SubjectSchema,
|
|
6002
|
-
kind:
|
|
6137
|
+
kind: z3.literal("handoff"),
|
|
6003
6138
|
...envelopeTail,
|
|
6004
|
-
class:
|
|
6005
|
-
reason:
|
|
6139
|
+
class: z3.enum(["authority", "strategy", "product"]),
|
|
6140
|
+
reason: z3.string()
|
|
6006
6141
|
};
|
|
6007
|
-
var HandoffEventSchema =
|
|
6008
|
-
|
|
6142
|
+
var HandoffEventSchema = z3.discriminatedUnion("event", [
|
|
6143
|
+
z3.object({
|
|
6009
6144
|
...handoffShared,
|
|
6010
|
-
event:
|
|
6011
|
-
requested_decision:
|
|
6145
|
+
event: z3.literal("raised"),
|
|
6146
|
+
requested_decision: z3.string().nullable()
|
|
6012
6147
|
}).strict(),
|
|
6013
|
-
|
|
6148
|
+
z3.object({
|
|
6014
6149
|
...handoffShared,
|
|
6015
|
-
event:
|
|
6016
|
-
resolution:
|
|
6017
|
-
resolved_by:
|
|
6150
|
+
event: z3.literal("resolved"),
|
|
6151
|
+
resolution: z3.string().nullable(),
|
|
6152
|
+
resolved_by: z3.string().nullable()
|
|
6018
6153
|
}).strict()
|
|
6019
6154
|
]);
|
|
6020
|
-
var EffectTargetSchema =
|
|
6021
|
-
kind:
|
|
6022
|
-
ref:
|
|
6155
|
+
var EffectTargetSchema = z3.object({
|
|
6156
|
+
kind: z3.string(),
|
|
6157
|
+
ref: z3.string()
|
|
6023
6158
|
}).strict();
|
|
6024
6159
|
var effectShared = {
|
|
6025
6160
|
meta: HeaderMetaSchema,
|
|
6026
6161
|
subject: SubjectSchema,
|
|
6027
|
-
kind:
|
|
6162
|
+
kind: z3.literal("effect"),
|
|
6028
6163
|
...envelopeTail,
|
|
6029
|
-
effect_id:
|
|
6164
|
+
effect_id: z3.string(),
|
|
6030
6165
|
target: EffectTargetSchema
|
|
6031
6166
|
};
|
|
6032
|
-
var EffectEventSchema =
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6167
|
+
var EffectEventSchema = z3.discriminatedUnion("event", [
|
|
6168
|
+
z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
|
|
6169
|
+
z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
|
|
6170
|
+
z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
|
|
6171
|
+
]);
|
|
6172
|
+
var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
|
|
6173
|
+
var customShared = {
|
|
6174
|
+
meta: HeaderMetaV3Schema,
|
|
6175
|
+
subject: SubjectSchema,
|
|
6176
|
+
kind: z3.literal("custom"),
|
|
6177
|
+
...envelopeTail
|
|
6178
|
+
};
|
|
6179
|
+
var CustomEventSchema = z3.discriminatedUnion("event", [
|
|
6180
|
+
z3.object({
|
|
6181
|
+
...customShared,
|
|
6182
|
+
event: z3.literal("recorded"),
|
|
6183
|
+
name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
|
|
6184
|
+
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, {
|
|
6185
|
+
message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
|
|
6186
|
+
})
|
|
6187
|
+
}).strict()
|
|
6036
6188
|
]);
|
|
6037
|
-
var LogEventSchema =
|
|
6189
|
+
var LogEventSchema = z3.union([
|
|
6038
6190
|
DispatchEventSchema,
|
|
6039
6191
|
DevReviewLoopEventSchema,
|
|
6040
6192
|
ForgeWriteEventSchema,
|
|
@@ -6043,10 +6195,11 @@ var LogEventSchema = z2.union([
|
|
|
6043
6195
|
UsageEventSchema,
|
|
6044
6196
|
RoleAttemptEventSchema,
|
|
6045
6197
|
HandoffEventSchema,
|
|
6046
|
-
EffectEventSchema
|
|
6198
|
+
EffectEventSchema,
|
|
6199
|
+
CustomEventSchema
|
|
6047
6200
|
]);
|
|
6048
|
-
|
|
6049
6201
|
// ../../packages/aeg-core/src/log/envelope.ts
|
|
6202
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
6050
6203
|
function isRole(value) {
|
|
6051
6204
|
return value !== undefined && ROLE_VALUES.includes(value);
|
|
6052
6205
|
}
|
|
@@ -6083,18 +6236,27 @@ function roundFromEnv(round) {
|
|
|
6083
6236
|
const n = Number(round);
|
|
6084
6237
|
return Number.isInteger(n) ? n : undefined;
|
|
6085
6238
|
}
|
|
6239
|
+
function prFromEnv(pr) {
|
|
6240
|
+
if (pr === undefined || pr === "")
|
|
6241
|
+
return;
|
|
6242
|
+
const n = Number(pr);
|
|
6243
|
+
return Number.isInteger(n) && n > 0 ? n : undefined;
|
|
6244
|
+
}
|
|
6086
6245
|
function buildHeader(input) {
|
|
6087
6246
|
const role = isRole(input.env.role) ? input.env.role : "unattributed";
|
|
6088
6247
|
const round = roundFromEnv(input.env.round);
|
|
6248
|
+
const pr = prFromEnv(input.env.pr);
|
|
6089
6249
|
const subject = {
|
|
6090
6250
|
issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
|
|
6091
6251
|
role,
|
|
6092
6252
|
...round !== undefined ? { round } : {},
|
|
6253
|
+
...pr !== undefined ? { pr } : {},
|
|
6093
6254
|
...input.subject ?? {}
|
|
6094
6255
|
};
|
|
6256
|
+
const issue = subject.issue;
|
|
6095
6257
|
return {
|
|
6096
6258
|
meta: {
|
|
6097
|
-
schema:
|
|
6259
|
+
schema: 3,
|
|
6098
6260
|
ts: input.now.toISOString(),
|
|
6099
6261
|
run_id: input.runId,
|
|
6100
6262
|
seq: input.seq,
|
|
@@ -6117,7 +6279,19 @@ function buildHeader(input) {
|
|
|
6117
6279
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
6118
6280
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6119
6281
|
},
|
|
6120
|
-
provenance: provenanceFor(input)
|
|
6282
|
+
provenance: provenanceFor(input),
|
|
6283
|
+
work: {
|
|
6284
|
+
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6285
|
+
repo: input.repo,
|
|
6286
|
+
change: null,
|
|
6287
|
+
revision: null
|
|
6288
|
+
},
|
|
6289
|
+
flow: {
|
|
6290
|
+
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
6291
|
+
version: lineageFieldFromEnv(input.env.flowVersion)
|
|
6292
|
+
},
|
|
6293
|
+
runtime: lineageFieldFromEnv(input.env.runtime),
|
|
6294
|
+
source: lineageFieldFromEnv(input.env.source)
|
|
6121
6295
|
},
|
|
6122
6296
|
subject
|
|
6123
6297
|
};
|
|
@@ -6160,7 +6334,7 @@ function redact(value, home) {
|
|
|
6160
6334
|
return value;
|
|
6161
6335
|
}
|
|
6162
6336
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6163
|
-
var KNOWN_SCHEMA_VERSIONS = [1, 2];
|
|
6337
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
|
|
6164
6338
|
function metaOf(obj) {
|
|
6165
6339
|
if (obj === null || typeof obj !== "object")
|
|
6166
6340
|
return null;
|
|
@@ -6226,7 +6400,7 @@ function classifyStoredLine(raw, home) {
|
|
|
6226
6400
|
return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
|
|
6227
6401
|
}
|
|
6228
6402
|
const redacted = redact(event, home);
|
|
6229
|
-
const provenance = version
|
|
6403
|
+
const provenance = version >= 2 ? event.meta.provenance ?? null : null;
|
|
6230
6404
|
return {
|
|
6231
6405
|
status: "ok",
|
|
6232
6406
|
identity,
|
|
@@ -6239,141 +6413,150 @@ function classifyStoredLine(raw, home) {
|
|
|
6239
6413
|
};
|
|
6240
6414
|
}
|
|
6241
6415
|
// ../../packages/aeg-core/src/control-store/records.ts
|
|
6242
|
-
import { z as
|
|
6243
|
-
var isoTimestamp =
|
|
6244
|
-
var taskId =
|
|
6245
|
-
var epochNumber =
|
|
6246
|
-
var RunRecordSchema =
|
|
6247
|
-
version:
|
|
6248
|
-
kind:
|
|
6416
|
+
import { z as z4 } from "zod";
|
|
6417
|
+
var isoTimestamp = z4.string().min(1);
|
|
6418
|
+
var taskId = z4.number().int().positive();
|
|
6419
|
+
var epochNumber = z4.number().int().nonnegative();
|
|
6420
|
+
var RunRecordSchema = z4.object({
|
|
6421
|
+
version: z4.literal(1),
|
|
6422
|
+
kind: z4.literal("run"),
|
|
6249
6423
|
task: taskId,
|
|
6250
|
-
runId:
|
|
6251
|
-
pid:
|
|
6252
|
-
host:
|
|
6424
|
+
runId: z4.string().min(1),
|
|
6425
|
+
pid: z4.number().int().positive(),
|
|
6426
|
+
host: z4.string().min(1),
|
|
6253
6427
|
startedAt: isoTimestamp,
|
|
6254
|
-
childStartedAt:
|
|
6255
|
-
childCommand:
|
|
6428
|
+
childStartedAt: z4.string().min(1).nullable().optional(),
|
|
6429
|
+
childCommand: z4.string().min(1).nullable().optional()
|
|
6256
6430
|
}).strict();
|
|
6257
|
-
var InputRecordSchema =
|
|
6258
|
-
version:
|
|
6259
|
-
kind:
|
|
6431
|
+
var InputRecordSchema = z4.object({
|
|
6432
|
+
version: z4.literal(1),
|
|
6433
|
+
kind: z4.literal("input"),
|
|
6260
6434
|
task: taskId,
|
|
6261
|
-
runId:
|
|
6262
|
-
source:
|
|
6263
|
-
pr:
|
|
6264
|
-
round:
|
|
6435
|
+
runId: z4.string().min(1),
|
|
6436
|
+
source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
|
|
6437
|
+
pr: z4.number().int().positive().nullable(),
|
|
6438
|
+
round: z4.number().int().nonnegative(),
|
|
6265
6439
|
recordedAt: isoTimestamp
|
|
6266
6440
|
}).strict();
|
|
6267
|
-
var OwnershipRecordSchema =
|
|
6268
|
-
version:
|
|
6269
|
-
kind:
|
|
6441
|
+
var OwnershipRecordSchema = z4.object({
|
|
6442
|
+
version: z4.literal(1),
|
|
6443
|
+
kind: z4.literal("ownership"),
|
|
6270
6444
|
task: taskId,
|
|
6271
6445
|
epoch: epochNumber,
|
|
6272
|
-
ownerId:
|
|
6273
|
-
pid:
|
|
6274
|
-
host:
|
|
6446
|
+
ownerId: z4.string().min(1),
|
|
6447
|
+
pid: z4.number().int().positive(),
|
|
6448
|
+
host: z4.string().min(1),
|
|
6275
6449
|
acquiredAt: isoTimestamp
|
|
6276
6450
|
}).strict();
|
|
6277
|
-
var TransitionRecordSchema =
|
|
6278
|
-
version:
|
|
6279
|
-
kind:
|
|
6451
|
+
var TransitionRecordSchema = z4.object({
|
|
6452
|
+
version: z4.literal(1),
|
|
6453
|
+
kind: z4.literal("transition"),
|
|
6280
6454
|
task: taskId,
|
|
6281
6455
|
epoch: epochNumber,
|
|
6282
|
-
seq:
|
|
6283
|
-
from:
|
|
6284
|
-
to:
|
|
6285
|
-
detail:
|
|
6456
|
+
seq: z4.number().int().nonnegative(),
|
|
6457
|
+
from: z4.string().min(1),
|
|
6458
|
+
to: z4.string().min(1),
|
|
6459
|
+
detail: z4.string().optional(),
|
|
6286
6460
|
at: isoTimestamp
|
|
6287
6461
|
}).strict();
|
|
6288
|
-
var ManifestRecordSchema =
|
|
6289
|
-
version:
|
|
6290
|
-
kind:
|
|
6462
|
+
var ManifestRecordSchema = z4.object({
|
|
6463
|
+
version: z4.literal(1),
|
|
6464
|
+
kind: z4.literal("manifest"),
|
|
6291
6465
|
task: taskId,
|
|
6292
6466
|
round: epochNumber,
|
|
6293
|
-
repository:
|
|
6294
|
-
pr:
|
|
6295
|
-
branch:
|
|
6296
|
-
baseSha:
|
|
6297
|
-
headSha:
|
|
6298
|
-
briefHash:
|
|
6299
|
-
objectivesVersion:
|
|
6467
|
+
repository: z4.string().min(1),
|
|
6468
|
+
pr: z4.number().int().positive(),
|
|
6469
|
+
branch: z4.string().min(1),
|
|
6470
|
+
baseSha: z4.string().min(1).nullable(),
|
|
6471
|
+
headSha: z4.string().min(1),
|
|
6472
|
+
briefHash: z4.string().min(1).nullable(),
|
|
6473
|
+
objectivesVersion: z4.string().min(1).nullable(),
|
|
6300
6474
|
rulingOrdinal: epochNumber,
|
|
6301
|
-
policyDigest:
|
|
6475
|
+
policyDigest: z4.string().min(1),
|
|
6302
6476
|
recordedAt: isoTimestamp
|
|
6303
6477
|
}).strict();
|
|
6304
|
-
var roundHeadIdentity =
|
|
6305
|
-
var LoopBudgetsSchema =
|
|
6306
|
-
mechanicalRetries:
|
|
6307
|
-
reviewRounds:
|
|
6308
|
-
infrastructureRetries:
|
|
6478
|
+
var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
|
|
6479
|
+
var LoopBudgetsSchema = z4.object({
|
|
6480
|
+
mechanicalRetries: z4.number().int().nonnegative(),
|
|
6481
|
+
reviewRounds: z4.number().int().nonnegative(),
|
|
6482
|
+
infrastructureRetries: z4.number().int().nonnegative()
|
|
6309
6483
|
}).strict();
|
|
6310
|
-
var LoopStateRecordSchema =
|
|
6311
|
-
version:
|
|
6312
|
-
kind:
|
|
6484
|
+
var LoopStateRecordSchema = z4.object({
|
|
6485
|
+
version: z4.literal(1),
|
|
6486
|
+
kind: z4.literal("loop_state"),
|
|
6313
6487
|
task: taskId,
|
|
6314
|
-
round:
|
|
6315
|
-
phase:
|
|
6316
|
-
pauseReason:
|
|
6488
|
+
round: z4.number().int().positive(),
|
|
6489
|
+
phase: z4.string().min(1),
|
|
6490
|
+
pauseReason: z4.string().min(1).nullable(),
|
|
6317
6491
|
budgets: LoopBudgetsSchema,
|
|
6318
6492
|
heldResult: roundHeadIdentity.nullable(),
|
|
6319
6493
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6494
|
+
repeatMemory: z4.object({
|
|
6495
|
+
blockingFindings: z4.array(z4.string()),
|
|
6496
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
6497
|
+
}).strict().optional(),
|
|
6498
|
+
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6499
|
+
taskStartedAt: isoTimestamp.optional(),
|
|
6500
|
+
phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
|
|
6320
6501
|
recordedAt: isoTimestamp
|
|
6321
6502
|
}).strict();
|
|
6322
|
-
var EffectRecordSchema =
|
|
6323
|
-
version:
|
|
6324
|
-
kind:
|
|
6503
|
+
var EffectRecordSchema = z4.object({
|
|
6504
|
+
version: z4.literal(1),
|
|
6505
|
+
kind: z4.literal("effect"),
|
|
6325
6506
|
task: taskId,
|
|
6326
|
-
key:
|
|
6327
|
-
operation:
|
|
6328
|
-
target:
|
|
6329
|
-
inputVersion:
|
|
6330
|
-
payloadDigest:
|
|
6331
|
-
status:
|
|
6332
|
-
url:
|
|
6507
|
+
key: z4.string().min(1),
|
|
6508
|
+
operation: z4.string().min(1),
|
|
6509
|
+
target: z4.string().min(1),
|
|
6510
|
+
inputVersion: z4.number().int().nonnegative(),
|
|
6511
|
+
payloadDigest: z4.string().min(1),
|
|
6512
|
+
status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
|
|
6513
|
+
url: z4.string().optional(),
|
|
6333
6514
|
recordedAt: isoTimestamp
|
|
6334
6515
|
}).strict();
|
|
6335
|
-
var EscalationRecordSchema =
|
|
6336
|
-
version:
|
|
6337
|
-
kind:
|
|
6516
|
+
var EscalationRecordSchema = z4.object({
|
|
6517
|
+
version: z4.literal(1),
|
|
6518
|
+
kind: z4.literal("escalation"),
|
|
6338
6519
|
task: taskId,
|
|
6339
|
-
escalationId:
|
|
6520
|
+
escalationId: z4.string().min(1),
|
|
6340
6521
|
round: epochNumber,
|
|
6341
|
-
head:
|
|
6342
|
-
branch:
|
|
6343
|
-
pr:
|
|
6344
|
-
runId:
|
|
6345
|
-
pid:
|
|
6346
|
-
host:
|
|
6347
|
-
agent:
|
|
6348
|
-
reason:
|
|
6349
|
-
detail:
|
|
6350
|
-
evidence:
|
|
6351
|
-
attemptedRecovery:
|
|
6352
|
-
requestedDecision:
|
|
6353
|
-
recipient:
|
|
6354
|
-
briefHash:
|
|
6355
|
-
objectivesVersion:
|
|
6522
|
+
head: z4.string().min(1),
|
|
6523
|
+
branch: z4.string().min(1),
|
|
6524
|
+
pr: z4.number().int().positive().nullable(),
|
|
6525
|
+
runId: z4.string().min(1),
|
|
6526
|
+
pid: z4.number().int().positive(),
|
|
6527
|
+
host: z4.string().min(1),
|
|
6528
|
+
agent: z4.string().min(1).optional(),
|
|
6529
|
+
reason: z4.string().min(1),
|
|
6530
|
+
detail: z4.string().optional(),
|
|
6531
|
+
evidence: z4.string().optional(),
|
|
6532
|
+
attemptedRecovery: z4.string().min(1),
|
|
6533
|
+
requestedDecision: z4.string().min(1),
|
|
6534
|
+
recipient: z4.string().min(1),
|
|
6535
|
+
briefHash: z4.string().min(1).nullable(),
|
|
6536
|
+
objectivesVersion: z4.string().min(1).nullable(),
|
|
6356
6537
|
rulingOrdinal: epochNumber,
|
|
6357
|
-
policyDigest:
|
|
6538
|
+
policyDigest: z4.string().min(1),
|
|
6358
6539
|
recordedAt: isoTimestamp
|
|
6359
6540
|
}).strict();
|
|
6360
|
-
var ResolutionRecordSchema =
|
|
6361
|
-
version:
|
|
6362
|
-
kind:
|
|
6541
|
+
var ResolutionRecordSchema = z4.object({
|
|
6542
|
+
version: z4.literal(1),
|
|
6543
|
+
kind: z4.literal("resolution"),
|
|
6363
6544
|
task: taskId,
|
|
6364
|
-
escalationId:
|
|
6365
|
-
decision:
|
|
6366
|
-
authenticatedBy:
|
|
6367
|
-
authenticatedFrom:
|
|
6545
|
+
escalationId: z4.string().min(1),
|
|
6546
|
+
decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
|
|
6547
|
+
authenticatedBy: z4.string().min(1),
|
|
6548
|
+
authenticatedFrom: z4.string().min(1),
|
|
6368
6549
|
consumedAt: isoTimestamp
|
|
6369
6550
|
}).strict();
|
|
6551
|
+
// ../../packages/aeg-core/src/control-store/local.ts
|
|
6552
|
+
var CONTROL_AREA_DIRNAME = "control";
|
|
6370
6553
|
// src/lib/pr-report-engine.ts
|
|
6371
6554
|
import { execFile as execFile6 } from "node:child_process";
|
|
6372
6555
|
import { promisify as promisify6 } from "node:util";
|
|
6373
6556
|
|
|
6374
6557
|
// src/checks/registry.ts
|
|
6375
|
-
import {
|
|
6376
|
-
import {
|
|
6558
|
+
import { join as join2, relative, sep } from "node:path";
|
|
6559
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
6377
6560
|
|
|
6378
6561
|
// src/lib/package-root.ts
|
|
6379
6562
|
import { existsSync } from "node:fs";
|
|
@@ -6393,10 +6576,14 @@ function packageRoot(moduleUrl) {
|
|
|
6393
6576
|
}
|
|
6394
6577
|
|
|
6395
6578
|
// src/checks/registry.ts
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6579
|
+
function resolveCheckBin(packageDir, moduleUrl) {
|
|
6580
|
+
const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
|
|
6581
|
+
const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep}`);
|
|
6582
|
+
return bundled ? { dir: join2(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join2(packageDir, "src", "checks", "bin"), ext: ".ts" };
|
|
6583
|
+
}
|
|
6584
|
+
var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
|
|
6585
|
+
var BIN_DIR = CHECK_BIN.dir;
|
|
6586
|
+
var BIN_EXT = CHECK_BIN.ext;
|
|
6400
6587
|
function bin(name) {
|
|
6401
6588
|
return join2(BIN_DIR, `${name}${BIN_EXT}`);
|
|
6402
6589
|
}
|
|
@@ -6594,23 +6781,6 @@ var REGISTRY = [
|
|
|
6594
6781
|
},
|
|
6595
6782
|
1
|
|
6596
6783
|
],
|
|
6597
|
-
[
|
|
6598
|
-
{
|
|
6599
|
-
name: "token-report",
|
|
6600
|
-
validates: "body",
|
|
6601
|
-
run: bin("check-token-report"),
|
|
6602
|
-
scope: "diff",
|
|
6603
|
-
timeoutMs: 15000,
|
|
6604
|
-
requiresOpenPr: true,
|
|
6605
|
-
env: {
|
|
6606
|
-
PR_BODY: { optional: true },
|
|
6607
|
-
BRANCH: { optional: true },
|
|
6608
|
-
CLAUDE_PROJECT_DIR: { optional: true },
|
|
6609
|
-
CLAUDE_CODE_SESSION_ID: { optional: true }
|
|
6610
|
-
}
|
|
6611
|
-
},
|
|
6612
|
-
1
|
|
6613
|
-
],
|
|
6614
6784
|
[
|
|
6615
6785
|
{
|
|
6616
6786
|
name: "no-disk-state",
|
|
@@ -6960,49 +7130,52 @@ var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.na
|
|
|
6960
7130
|
import { execFile as execFile5 } from "node:child_process";
|
|
6961
7131
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
6962
7132
|
import {
|
|
6963
|
-
|
|
6964
|
-
|
|
7133
|
+
appendFileSync,
|
|
7134
|
+
closeSync as closeSync4,
|
|
7135
|
+
constants as fsConstants4,
|
|
6965
7136
|
existsSync as existsSync5,
|
|
6966
|
-
fstatSync as
|
|
6967
|
-
mkdirSync as
|
|
6968
|
-
|
|
6969
|
-
|
|
7137
|
+
fstatSync as fstatSync3,
|
|
7138
|
+
mkdirSync as mkdirSync4,
|
|
7139
|
+
lstatSync as lstatSync2,
|
|
7140
|
+
openSync as openSync4,
|
|
7141
|
+
readFileSync as readFileSync5,
|
|
6970
7142
|
renameSync as renameSync2,
|
|
6971
|
-
|
|
7143
|
+
writeFileSync as writeFileSync3,
|
|
7144
|
+
writeSync as writeSync3
|
|
6972
7145
|
} from "node:fs";
|
|
6973
7146
|
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
6974
|
-
import { dirname as
|
|
7147
|
+
import { dirname as dirname6, join as join6 } from "node:path";
|
|
6975
7148
|
import { promisify as promisify5 } from "node:util";
|
|
6976
7149
|
|
|
6977
7150
|
// src/lib/config.ts
|
|
6978
7151
|
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
6979
7152
|
import { promisify as promisify4 } from "node:util";
|
|
6980
|
-
import { existsSync as
|
|
7153
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
|
|
6981
7154
|
import { homedir } from "node:os";
|
|
6982
7155
|
import { dirname as dirname2, isAbsolute, join as join3, resolve } from "node:path";
|
|
6983
|
-
import { z as
|
|
7156
|
+
import { z as z5 } from "zod";
|
|
6984
7157
|
|
|
6985
7158
|
// src/lib/agent-vendors.ts
|
|
6986
7159
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6987
7160
|
|
|
6988
7161
|
// src/lib/config.ts
|
|
6989
|
-
var EnvEntrySchema =
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
7162
|
+
var EnvEntrySchema = z5.union([
|
|
7163
|
+
z5.literal(true),
|
|
7164
|
+
z5.object({ optional: z5.literal(true) }),
|
|
7165
|
+
z5.object({ anyOf: z5.array(z5.string()).min(2) }),
|
|
7166
|
+
z5.string()
|
|
6994
7167
|
]);
|
|
6995
|
-
var CheckEntrySchema =
|
|
6996
|
-
run:
|
|
6997
|
-
scope:
|
|
6998
|
-
include:
|
|
6999
|
-
args:
|
|
7000
|
-
timeoutMs:
|
|
7001
|
-
env:
|
|
7002
|
-
requiresOpenPr:
|
|
7003
|
-
ownWorkflow:
|
|
7004
|
-
principalOwed:
|
|
7005
|
-
validates:
|
|
7168
|
+
var CheckEntrySchema = z5.object({
|
|
7169
|
+
run: z5.string(),
|
|
7170
|
+
scope: z5.enum(["diff", "full"]),
|
|
7171
|
+
include: z5.array(z5.string()).optional(),
|
|
7172
|
+
args: z5.array(z5.string()).optional(),
|
|
7173
|
+
timeoutMs: z5.number().optional(),
|
|
7174
|
+
env: z5.record(z5.string(), EnvEntrySchema).optional(),
|
|
7175
|
+
requiresOpenPr: z5.boolean().optional(),
|
|
7176
|
+
ownWorkflow: z5.boolean().optional(),
|
|
7177
|
+
principalOwed: z5.literal(true).optional(),
|
|
7178
|
+
validates: z5.enum(["body", "issue"]).optional()
|
|
7006
7179
|
}).superRefine((entry, ctx) => {
|
|
7007
7180
|
if (!entry.env)
|
|
7008
7181
|
return;
|
|
@@ -7012,22 +7185,22 @@ var CheckEntrySchema = z4.object({
|
|
|
7012
7185
|
const members = value.anyOf;
|
|
7013
7186
|
if (new Set(members).size !== members.length) {
|
|
7014
7187
|
ctx.addIssue({
|
|
7015
|
-
code:
|
|
7188
|
+
code: z5.ZodIssueCode.custom,
|
|
7016
7189
|
message: `env.${key}.anyOf has duplicate members`,
|
|
7017
7190
|
path: ["env", key, "anyOf"]
|
|
7018
7191
|
});
|
|
7019
7192
|
}
|
|
7020
7193
|
if (!members.includes(key)) {
|
|
7021
7194
|
ctx.addIssue({
|
|
7022
|
-
code:
|
|
7195
|
+
code: z5.ZodIssueCode.custom,
|
|
7023
7196
|
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
7024
7197
|
path: ["env", key, "anyOf"]
|
|
7025
7198
|
});
|
|
7026
7199
|
}
|
|
7027
7200
|
}
|
|
7028
7201
|
});
|
|
7029
|
-
var RoleEntrySchema =
|
|
7030
|
-
contract:
|
|
7202
|
+
var RoleEntrySchema = z5.object({
|
|
7203
|
+
contract: z5.string().refine((p) => p.includes("/"), {
|
|
7031
7204
|
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
7032
7205
|
})
|
|
7033
7206
|
});
|
|
@@ -7051,17 +7224,17 @@ var BRIEF_BUILTINS = [
|
|
|
7051
7224
|
"briefSections",
|
|
7052
7225
|
"milestoneShape"
|
|
7053
7226
|
];
|
|
7054
|
-
var BriefSectionSchema =
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7227
|
+
var BriefSectionSchema = z5.union([
|
|
7228
|
+
z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
|
|
7229
|
+
z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
|
|
7230
|
+
z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
|
|
7231
|
+
z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
|
|
7059
7232
|
]);
|
|
7060
|
-
var BriefSchemaSchema =
|
|
7061
|
-
pr:
|
|
7062
|
-
issue:
|
|
7063
|
-
milestone:
|
|
7064
|
-
ack:
|
|
7233
|
+
var BriefSchemaSchema = z5.object({
|
|
7234
|
+
pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
|
|
7235
|
+
issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
|
|
7236
|
+
milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
|
|
7237
|
+
ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
|
|
7065
7238
|
});
|
|
7066
7239
|
function isSafeRepoRelPath(p) {
|
|
7067
7240
|
if (p.length === 0)
|
|
@@ -7070,7 +7243,7 @@ function isSafeRepoRelPath(p) {
|
|
|
7070
7243
|
return false;
|
|
7071
7244
|
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
7072
7245
|
}
|
|
7073
|
-
var SafeRepoRelPath =
|
|
7246
|
+
var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
|
|
7074
7247
|
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
7075
7248
|
});
|
|
7076
7249
|
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
@@ -7080,22 +7253,22 @@ function isCanonicalHookBlockPath(p) {
|
|
|
7080
7253
|
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
7081
7254
|
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
7082
7255
|
});
|
|
7083
|
-
var ManagedBlockRecordSchema =
|
|
7256
|
+
var ManagedBlockRecordSchema = z5.object({
|
|
7084
7257
|
path: ManagedHookBlockPath,
|
|
7085
|
-
marker:
|
|
7086
|
-
comment:
|
|
7258
|
+
marker: z5.string(),
|
|
7259
|
+
comment: z5.enum(["hash", "html"])
|
|
7087
7260
|
});
|
|
7088
|
-
var ManagedManifestSchema =
|
|
7089
|
-
version:
|
|
7090
|
-
files:
|
|
7091
|
-
blocks:
|
|
7092
|
-
labels:
|
|
7093
|
-
agents:
|
|
7261
|
+
var ManagedManifestSchema = z5.object({
|
|
7262
|
+
version: z5.number().int().positive(),
|
|
7263
|
+
files: z5.array(SafeRepoRelPath),
|
|
7264
|
+
blocks: z5.array(ManagedBlockRecordSchema),
|
|
7265
|
+
labels: z5.array(z5.string()),
|
|
7266
|
+
agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
|
|
7094
7267
|
});
|
|
7095
|
-
var ProjectEntrySchema =
|
|
7096
|
-
name:
|
|
7097
|
-
description:
|
|
7098
|
-
path:
|
|
7268
|
+
var ProjectEntrySchema = z5.object({
|
|
7269
|
+
name: z5.string().min(1),
|
|
7270
|
+
description: z5.string().min(1).optional(),
|
|
7271
|
+
path: z5.string().min(1).optional()
|
|
7099
7272
|
});
|
|
7100
7273
|
function parseTokensCollectDeclaration(value) {
|
|
7101
7274
|
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
@@ -7106,87 +7279,97 @@ function parseTokensCollectDeclaration(value) {
|
|
|
7106
7279
|
return null;
|
|
7107
7280
|
return { interpreter, script };
|
|
7108
7281
|
}
|
|
7109
|
-
var VinayaConfigSchema =
|
|
7110
|
-
rings:
|
|
7111
|
-
ring1_forgeWriteInterception:
|
|
7112
|
-
ring2_asyncAudits:
|
|
7282
|
+
var VinayaConfigSchema = z5.object({
|
|
7283
|
+
rings: z5.object({
|
|
7284
|
+
ring1_forgeWriteInterception: z5.boolean(),
|
|
7285
|
+
ring2_asyncAudits: z5.boolean()
|
|
7113
7286
|
}).optional(),
|
|
7114
|
-
checks:
|
|
7115
|
-
roles:
|
|
7287
|
+
checks: z5.record(z5.string(), CheckEntrySchema).optional(),
|
|
7288
|
+
roles: z5.record(z5.string(), RoleEntrySchema).optional(),
|
|
7116
7289
|
briefSchema: BriefSchemaSchema.optional(),
|
|
7117
7290
|
managed: ManagedManifestSchema.optional(),
|
|
7118
|
-
principals:
|
|
7119
|
-
releaseActor:
|
|
7120
|
-
ci:
|
|
7121
|
-
tokens:
|
|
7122
|
-
collect:
|
|
7291
|
+
principals: z5.array(z5.string()).min(1).optional(),
|
|
7292
|
+
releaseActor: z5.string().min(1).optional(),
|
|
7293
|
+
ci: z5.object({ setup: z5.string().min(1) }).optional(),
|
|
7294
|
+
tokens: z5.object({
|
|
7295
|
+
collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
7123
7296
|
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
7124
7297
|
})
|
|
7125
7298
|
}).optional(),
|
|
7126
|
-
blastRadius:
|
|
7127
|
-
proseGates:
|
|
7128
|
-
doctrineRoot:
|
|
7129
|
-
readerFacingPrefix:
|
|
7130
|
-
readerFacingSuffix:
|
|
7131
|
-
legacySlugDir:
|
|
7132
|
-
sourceComments:
|
|
7133
|
-
globs:
|
|
7134
|
-
allowlist:
|
|
7135
|
-
severity:
|
|
7299
|
+
blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
|
|
7300
|
+
proseGates: z5.object({
|
|
7301
|
+
doctrineRoot: z5.string().min(1).optional(),
|
|
7302
|
+
readerFacingPrefix: z5.string().min(1).optional(),
|
|
7303
|
+
readerFacingSuffix: z5.string().min(1).optional(),
|
|
7304
|
+
legacySlugDir: z5.string().min(1).optional(),
|
|
7305
|
+
sourceComments: z5.object({
|
|
7306
|
+
globs: z5.array(z5.string().min(1)).optional(),
|
|
7307
|
+
allowlist: z5.array(z5.string().min(1)).optional(),
|
|
7308
|
+
severity: z5.enum(["warning", "error"]).optional()
|
|
7136
7309
|
}).optional(),
|
|
7137
|
-
specGrandfather:
|
|
7138
|
-
specPaths:
|
|
7310
|
+
specGrandfather: z5.union([z5.array(z5.string().min(1)), z5.record(z5.string().min(1), z5.number().int().min(0))]).optional(),
|
|
7311
|
+
specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
|
|
7139
7312
|
message: "must be a repository-relative path, not an absolute one"
|
|
7140
7313
|
}).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
|
|
7141
7314
|
message: "must stay inside the repository — no `..` segment"
|
|
7142
7315
|
})).optional()
|
|
7143
7316
|
}).optional(),
|
|
7144
|
-
projects:
|
|
7145
|
-
dispatch:
|
|
7146
|
-
timeoutMs:
|
|
7147
|
-
killGraceMs:
|
|
7148
|
-
agent:
|
|
7149
|
-
requireWorkerIsolation: z4.boolean().optional()
|
|
7317
|
+
projects: z5.array(ProjectEntrySchema).optional(),
|
|
7318
|
+
dispatch: z5.object({
|
|
7319
|
+
timeoutMs: z5.number().int().positive().optional(),
|
|
7320
|
+
killGraceMs: z5.number().int().positive().optional(),
|
|
7321
|
+
agent: z5.enum(["claude", "codex", "gemini"]).optional()
|
|
7150
7322
|
}).optional(),
|
|
7151
|
-
reviewPolicy:
|
|
7152
|
-
codeReviewThreshold:
|
|
7153
|
-
securityThreshold:
|
|
7154
|
-
maxRounds:
|
|
7323
|
+
reviewPolicy: z5.object({
|
|
7324
|
+
codeReviewThreshold: z5.string().min(1).optional(),
|
|
7325
|
+
securityThreshold: z5.string().min(1).optional(),
|
|
7326
|
+
maxRounds: z5.number().optional(),
|
|
7327
|
+
maxTaskMinutes: z5.number().optional()
|
|
7155
7328
|
}).optional(),
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
|
|
7159
|
-
documentationSinceIssue: z4.number().int().nonnegative().optional(),
|
|
7160
|
-
briefRulesSincePr: z4.number().int().nonnegative().optional(),
|
|
7161
|
-
agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
|
|
7329
|
+
securityScan: z5.object({
|
|
7330
|
+
command: z5.array(z5.string().min(1)).min(1)
|
|
7162
7331
|
}).optional(),
|
|
7163
|
-
|
|
7164
|
-
|
|
7332
|
+
gateCutovers: z5.object({
|
|
7333
|
+
objectivesSinceIssue: z5.number().int().nonnegative().optional(),
|
|
7334
|
+
briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
|
|
7335
|
+
documentationSinceIssue: z5.number().int().nonnegative().optional(),
|
|
7336
|
+
briefRulesSincePr: z5.number().int().nonnegative().optional(),
|
|
7337
|
+
agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
|
|
7165
7338
|
}).optional(),
|
|
7166
|
-
|
|
7167
|
-
|
|
7339
|
+
planning: z5.object({
|
|
7340
|
+
collisionThreshold: z5.number().int().nonnegative().optional()
|
|
7341
|
+
}).optional(),
|
|
7342
|
+
prePush: z5.object({
|
|
7343
|
+
alwaysRun: z5.array(z5.string()).optional()
|
|
7344
|
+
}).optional(),
|
|
7345
|
+
report: z5.object({
|
|
7346
|
+
commandTimeoutMs: z5.number().int().positive().optional()
|
|
7168
7347
|
}).superRefine((report, ctx) => {
|
|
7169
7348
|
const commandTimeoutMs = report.commandTimeoutMs;
|
|
7170
7349
|
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
7171
7350
|
ctx.addIssue({
|
|
7172
|
-
code:
|
|
7351
|
+
code: z5.ZodIssueCode.custom,
|
|
7173
7352
|
path: ["commandTimeoutMs"],
|
|
7174
7353
|
message: "must be at most 3600000 (1 hour)"
|
|
7175
7354
|
});
|
|
7176
7355
|
}
|
|
7177
7356
|
}).optional(),
|
|
7178
|
-
logPublish:
|
|
7357
|
+
logPublish: z5.unknown().refine((v) => v === undefined, {
|
|
7179
7358
|
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
7180
7359
|
}),
|
|
7181
|
-
runtimeDir:
|
|
7182
|
-
logs:
|
|
7183
|
-
folder:
|
|
7184
|
-
url:
|
|
7185
|
-
headers:
|
|
7360
|
+
runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
7361
|
+
logs: z5.object({
|
|
7362
|
+
folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
7363
|
+
url: z5.string().url().optional(),
|
|
7364
|
+
headers: z5.record(z5.string()).optional(),
|
|
7365
|
+
readHeaders: z5.record(z5.string()).optional(),
|
|
7366
|
+
events: CustomEventDeclarationsSchema.optional()
|
|
7186
7367
|
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
7187
7368
|
message: "logs: set at most one of folder/url"
|
|
7188
7369
|
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
7189
7370
|
message: "logs: headers requires url"
|
|
7371
|
+
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
7372
|
+
message: "logs: readHeaders requires url"
|
|
7190
7373
|
}).optional()
|
|
7191
7374
|
});
|
|
7192
7375
|
var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
|
|
@@ -7196,9 +7379,9 @@ function findLocalConfig() {
|
|
|
7196
7379
|
let dir = process.cwd();
|
|
7197
7380
|
while (true) {
|
|
7198
7381
|
const candidate = join3(dir, LOCAL_CONFIG_FILENAME);
|
|
7199
|
-
if (
|
|
7382
|
+
if (existsSync2(candidate))
|
|
7200
7383
|
return candidate;
|
|
7201
|
-
if (
|
|
7384
|
+
if (existsSync2(join3(dir, ".git")))
|
|
7202
7385
|
return null;
|
|
7203
7386
|
const parent = dirname2(dir);
|
|
7204
7387
|
if (parent === dir)
|
|
@@ -7210,7 +7393,7 @@ function configPath() {
|
|
|
7210
7393
|
const local = findLocalConfig();
|
|
7211
7394
|
if (local)
|
|
7212
7395
|
return local;
|
|
7213
|
-
if (
|
|
7396
|
+
if (existsSync2(GLOBAL_CONFIG_PATH))
|
|
7214
7397
|
return GLOBAL_CONFIG_PATH;
|
|
7215
7398
|
return null;
|
|
7216
7399
|
}
|
|
@@ -7291,10 +7474,15 @@ function resolveReviewPolicy(config) {
|
|
|
7291
7474
|
if (!Number.isInteger(maxRounds) || maxRounds < 1) {
|
|
7292
7475
|
throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
|
|
7293
7476
|
}
|
|
7477
|
+
const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
|
|
7478
|
+
if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
|
|
7479
|
+
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.`);
|
|
7480
|
+
}
|
|
7294
7481
|
return {
|
|
7295
7482
|
codeReviewThreshold,
|
|
7296
7483
|
securityThreshold,
|
|
7297
|
-
maxRounds
|
|
7484
|
+
maxRounds,
|
|
7485
|
+
maxTaskMinutes
|
|
7298
7486
|
};
|
|
7299
7487
|
}
|
|
7300
7488
|
function resolveGateCutovers(config) {
|
|
@@ -7500,8 +7688,17 @@ function loadConfig() {
|
|
|
7500
7688
|
var TOKENS_COLLECT_TRUST_PATH = join3(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
7501
7689
|
|
|
7502
7690
|
// src/lib/run-paths.ts
|
|
7503
|
-
import {
|
|
7691
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
7692
|
+
import { chmodSync, existsSync as existsSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
7504
7693
|
import { dirname as dirname3, join as join4, resolve as resolvePath } from "node:path";
|
|
7694
|
+
var TASKS_EXECUTION_DIRNAME = "tasks-execution";
|
|
7695
|
+
var RUN_AREA_DIRNAMES = {
|
|
7696
|
+
control: CONTROL_AREA_DIRNAME,
|
|
7697
|
+
sessions: "sessions",
|
|
7698
|
+
hooks: "hooks",
|
|
7699
|
+
output: "output",
|
|
7700
|
+
rounds: "rounds"
|
|
7701
|
+
};
|
|
7505
7702
|
var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
7506
7703
|
function isSafeRepoSegment(segment) {
|
|
7507
7704
|
return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
|
|
@@ -7532,12 +7729,52 @@ function isInsideRepo(candidate, repoRoot) {
|
|
|
7532
7729
|
const target = resolvePath(candidate);
|
|
7533
7730
|
return target === root || target.startsWith(`${root}/`);
|
|
7534
7731
|
}
|
|
7732
|
+
function runPath(runtimeDir, scope, location) {
|
|
7733
|
+
const dir = join4(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
|
|
7734
|
+
switch (location.area) {
|
|
7735
|
+
case "task":
|
|
7736
|
+
return location.file ? join4(dir, location.file) : dir;
|
|
7737
|
+
case "control": {
|
|
7738
|
+
const controlDir = join4(dir, RUN_AREA_DIRNAMES.control);
|
|
7739
|
+
return location.file ? join4(controlDir, location.file) : controlDir;
|
|
7740
|
+
}
|
|
7741
|
+
case "rounds":
|
|
7742
|
+
return join4(dir, RUN_AREA_DIRNAMES.rounds);
|
|
7743
|
+
case "round": {
|
|
7744
|
+
const roundDir = join4(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
|
|
7745
|
+
return location.file ? join4(roundDir, location.file) : roundDir;
|
|
7746
|
+
}
|
|
7747
|
+
case "developer": {
|
|
7748
|
+
const developerDir = join4(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
|
|
7749
|
+
return location.file ? join4(developerDir, location.file) : developerDir;
|
|
7750
|
+
}
|
|
7751
|
+
default: {
|
|
7752
|
+
const areaDir = join4(dir, RUN_AREA_DIRNAMES[location.area]);
|
|
7753
|
+
return location.file ? join4(areaDir, location.file) : areaDir;
|
|
7754
|
+
}
|
|
7755
|
+
}
|
|
7756
|
+
}
|
|
7757
|
+
function scopeSegment(scope) {
|
|
7758
|
+
if (scope === "unscoped")
|
|
7759
|
+
return "unscoped";
|
|
7760
|
+
if (typeof scope === "number")
|
|
7761
|
+
return String(scope);
|
|
7762
|
+
return `pr-${scope.pr}`;
|
|
7763
|
+
}
|
|
7535
7764
|
var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
|
|
7536
7765
|
var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
|
|
7537
7766
|
function isUnattendedProcess(env = process.env) {
|
|
7538
7767
|
return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
|
|
7539
7768
|
}
|
|
7540
7769
|
var memoized = null;
|
|
7770
|
+
function runtimeDirForRepo(repo) {
|
|
7771
|
+
const key = repoSegment(repo);
|
|
7772
|
+
if (memoized?.key === key)
|
|
7773
|
+
return memoized.value;
|
|
7774
|
+
const value = resolveRuntimeDirUncached(repo);
|
|
7775
|
+
memoized = { key, value };
|
|
7776
|
+
return value;
|
|
7777
|
+
}
|
|
7541
7778
|
async function runtimeDirForRepoAsync(repo) {
|
|
7542
7779
|
const key = repoSegment(repo);
|
|
7543
7780
|
if (memoized?.key === key)
|
|
@@ -7553,6 +7790,16 @@ async function runtimeDirForRepoAsync(repo) {
|
|
|
7553
7790
|
memoized = { key, value };
|
|
7554
7791
|
return value;
|
|
7555
7792
|
}
|
|
7793
|
+
function resolveRuntimeDirUncached(repo) {
|
|
7794
|
+
const inputs = runtimeDirInputs();
|
|
7795
|
+
if (typeof inputs === "string")
|
|
7796
|
+
return inputs;
|
|
7797
|
+
return resolveRuntimeDir({
|
|
7798
|
+
repo,
|
|
7799
|
+
...inputs.base,
|
|
7800
|
+
trustAnchorConfig: inputs.needsAnchor ? loadTrustAnchorConfig() : null
|
|
7801
|
+
});
|
|
7802
|
+
}
|
|
7556
7803
|
function runtimeDirInputs() {
|
|
7557
7804
|
const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
|
|
7558
7805
|
if (handedDown)
|
|
@@ -7572,7 +7819,7 @@ function repoRootSync(start = process.cwd()) {
|
|
|
7572
7819
|
return null;
|
|
7573
7820
|
}
|
|
7574
7821
|
for (;; ) {
|
|
7575
|
-
if (
|
|
7822
|
+
if (existsSync3(join4(dir, ".git")))
|
|
7576
7823
|
return dir;
|
|
7577
7824
|
const parent = dirname3(dir);
|
|
7578
7825
|
if (parent === dir)
|
|
@@ -7580,26 +7827,94 @@ function repoRootSync(start = process.cwd()) {
|
|
|
7580
7827
|
dir = parent;
|
|
7581
7828
|
}
|
|
7582
7829
|
}
|
|
7830
|
+
function resolveRepoSync() {
|
|
7831
|
+
const fromEnv = process.env.AEG_REPO;
|
|
7832
|
+
if (fromEnv) {
|
|
7833
|
+
const m = /^([^/]+)\/(.+)$/.exec(fromEnv);
|
|
7834
|
+
if (m?.[1] && m[2])
|
|
7835
|
+
return { owner: m[1], repo: m[2] };
|
|
7836
|
+
}
|
|
7837
|
+
let url;
|
|
7838
|
+
try {
|
|
7839
|
+
url = execFileSync3("git", ["remote", "get-url", "origin"], {
|
|
7840
|
+
encoding: "utf-8",
|
|
7841
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
7842
|
+
}).trim();
|
|
7843
|
+
} catch {
|
|
7844
|
+
return null;
|
|
7845
|
+
}
|
|
7846
|
+
const ssh = /^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/.exec(url);
|
|
7847
|
+
if (ssh?.[1] && ssh[2])
|
|
7848
|
+
return { owner: ssh[1], repo: ssh[2] };
|
|
7849
|
+
const https = /^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(url);
|
|
7850
|
+
if (https?.[1] && https[2])
|
|
7851
|
+
return { owner: https[1], repo: https[2] };
|
|
7852
|
+
return null;
|
|
7853
|
+
}
|
|
7854
|
+
var memoizedThisRepo = null;
|
|
7855
|
+
function runtimeDirForThisRepo() {
|
|
7856
|
+
if (memoizedThisRepo !== null)
|
|
7857
|
+
return memoizedThisRepo;
|
|
7858
|
+
memoizedThisRepo = runtimeDirForRepo(resolveRepoSync());
|
|
7859
|
+
return memoizedThisRepo;
|
|
7860
|
+
}
|
|
7583
7861
|
|
|
7584
|
-
// src/lib/log
|
|
7862
|
+
// src/lib/loop-log.ts
|
|
7585
7863
|
import {
|
|
7586
7864
|
closeSync as closeSync2,
|
|
7587
7865
|
constants as fsConstants2,
|
|
7588
|
-
|
|
7866
|
+
existsSync as existsSync4,
|
|
7867
|
+
fstatSync as fstatSync2,
|
|
7589
7868
|
mkdirSync as mkdirSync2,
|
|
7590
7869
|
openSync as openSync2,
|
|
7591
|
-
linkSync,
|
|
7592
7870
|
readFileSync as readFileSync3,
|
|
7593
|
-
|
|
7871
|
+
readSync,
|
|
7594
7872
|
statSync,
|
|
7873
|
+
writeSync
|
|
7874
|
+
} from "node:fs";
|
|
7875
|
+
import { dirname as dirname4 } from "node:path";
|
|
7876
|
+
function loopsRoot() {
|
|
7877
|
+
return runtimeDirForThisRepo();
|
|
7878
|
+
}
|
|
7879
|
+
function loopLogPathFor(_repo, issue, root = loopsRoot()) {
|
|
7880
|
+
return runPath(root, issue, { area: "output", file: "driver.log" });
|
|
7881
|
+
}
|
|
7882
|
+
var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
|
|
7883
|
+
function appendLoopLogLine(path, line) {
|
|
7884
|
+
try {
|
|
7885
|
+
mkdirSync2(dirname4(path), { recursive: true, mode: 448 });
|
|
7886
|
+
const fd = openSync2(path, fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW, 384);
|
|
7887
|
+
try {
|
|
7888
|
+
const stat = fstatSync2(fd);
|
|
7889
|
+
if (stat.isFile() && stat.size < LOOP_LOG_MAX_BYTES) {
|
|
7890
|
+
writeSync(fd, `${line}
|
|
7891
|
+
`);
|
|
7892
|
+
}
|
|
7893
|
+
} finally {
|
|
7894
|
+
closeSync2(fd);
|
|
7895
|
+
}
|
|
7896
|
+
} catch {}
|
|
7897
|
+
}
|
|
7898
|
+
|
|
7899
|
+
// src/lib/log-webhook-drain.ts
|
|
7900
|
+
import {
|
|
7901
|
+
closeSync as closeSync3,
|
|
7902
|
+
constants as fsConstants3,
|
|
7903
|
+
lstatSync,
|
|
7904
|
+
mkdirSync as mkdirSync3,
|
|
7905
|
+
openSync as openSync3,
|
|
7906
|
+
linkSync,
|
|
7907
|
+
readFileSync as readFileSync4,
|
|
7908
|
+
renameSync,
|
|
7909
|
+
statSync as statSync2,
|
|
7595
7910
|
unlinkSync,
|
|
7596
7911
|
utimesSync,
|
|
7597
7912
|
writeFileSync as writeFileSync2,
|
|
7598
|
-
writeSync
|
|
7913
|
+
writeSync as writeSync2
|
|
7599
7914
|
} from "node:fs";
|
|
7600
7915
|
import { randomUUID } from "node:crypto";
|
|
7601
7916
|
import { homedir as homedir2 } from "node:os";
|
|
7602
|
-
import { dirname as
|
|
7917
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
7603
7918
|
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
7604
7919
|
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
7605
7920
|
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
@@ -7615,13 +7930,13 @@ function isEnoent(err) {
|
|
|
7615
7930
|
var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
|
|
7616
7931
|
function tryCreateLock(lockPath, token) {
|
|
7617
7932
|
try {
|
|
7618
|
-
|
|
7619
|
-
const fd =
|
|
7933
|
+
mkdirSync3(dirname5(lockPath), { recursive: true, mode: 448 });
|
|
7934
|
+
const fd = openSync3(lockPath, fsConstants3.O_WRONLY | fsConstants3.O_CREAT | fsConstants3.O_EXCL, 384);
|
|
7620
7935
|
try {
|
|
7621
|
-
|
|
7936
|
+
writeSync2(fd, `${token}
|
|
7622
7937
|
`);
|
|
7623
7938
|
} finally {
|
|
7624
|
-
|
|
7939
|
+
closeSync3(fd);
|
|
7625
7940
|
}
|
|
7626
7941
|
return true;
|
|
7627
7942
|
} catch (err) {
|
|
@@ -7636,7 +7951,7 @@ function acquireDrainLock(lockPath) {
|
|
|
7636
7951
|
return token;
|
|
7637
7952
|
let observedMtimeMs;
|
|
7638
7953
|
try {
|
|
7639
|
-
observedMtimeMs =
|
|
7954
|
+
observedMtimeMs = statSync2(lockPath).mtimeMs;
|
|
7640
7955
|
} catch (err) {
|
|
7641
7956
|
if (!isEnoent(err))
|
|
7642
7957
|
throw err;
|
|
@@ -7654,7 +7969,7 @@ function acquireDrainLock(lockPath) {
|
|
|
7654
7969
|
}
|
|
7655
7970
|
let claimedMtimeMs = null;
|
|
7656
7971
|
try {
|
|
7657
|
-
claimedMtimeMs =
|
|
7972
|
+
claimedMtimeMs = statSync2(claimed).mtimeMs;
|
|
7658
7973
|
} catch (err) {
|
|
7659
7974
|
if (!isEnoent(err))
|
|
7660
7975
|
throw err;
|
|
@@ -7680,7 +7995,7 @@ function acquireDrainLock(lockPath) {
|
|
|
7680
7995
|
function renewDrainLock(lockPath, token) {
|
|
7681
7996
|
let holder;
|
|
7682
7997
|
try {
|
|
7683
|
-
holder =
|
|
7998
|
+
holder = readFileSync4(lockPath, "utf8").trim();
|
|
7684
7999
|
} catch (err) {
|
|
7685
8000
|
if (!isEnoent(err))
|
|
7686
8001
|
throw err;
|
|
@@ -7700,7 +8015,7 @@ function renewDrainLock(lockPath, token) {
|
|
|
7700
8015
|
}
|
|
7701
8016
|
function releaseDrainLock(lockPath, token) {
|
|
7702
8017
|
try {
|
|
7703
|
-
const holder =
|
|
8018
|
+
const holder = readFileSync4(lockPath, "utf8").trim();
|
|
7704
8019
|
if (holder !== token)
|
|
7705
8020
|
return;
|
|
7706
8021
|
unlinkSync(lockPath);
|
|
@@ -7750,7 +8065,7 @@ function queueLines(buf) {
|
|
|
7750
8065
|
return lines;
|
|
7751
8066
|
}
|
|
7752
8067
|
function removeQueueHead(path, cut) {
|
|
7753
|
-
const remaining =
|
|
8068
|
+
const remaining = readFileSync4(path);
|
|
7754
8069
|
writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
|
|
7755
8070
|
}
|
|
7756
8071
|
function queueBucketSize(path) {
|
|
@@ -7771,7 +8086,7 @@ function queueBucketSize(path) {
|
|
|
7771
8086
|
function readQueueFile(path) {
|
|
7772
8087
|
if (queueBucketSize(path) === null)
|
|
7773
8088
|
return null;
|
|
7774
|
-
return
|
|
8089
|
+
return readFileSync4(path);
|
|
7775
8090
|
}
|
|
7776
8091
|
function rejectLine(rejectedPath, reason, status, identity, raw) {
|
|
7777
8092
|
const record = JSON.stringify({
|
|
@@ -7953,13 +8268,19 @@ function logsCredentialMissing(headers, env) {
|
|
|
7953
8268
|
const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
7954
8269
|
for (const value of Object.values(headers)) {
|
|
7955
8270
|
for (const match of value.matchAll(varPattern)) {
|
|
7956
|
-
|
|
7957
|
-
|
|
8271
|
+
const name = match[1];
|
|
8272
|
+
if (env[name])
|
|
8273
|
+
continue;
|
|
8274
|
+
return true;
|
|
7958
8275
|
}
|
|
7959
8276
|
}
|
|
7960
8277
|
return false;
|
|
7961
8278
|
}
|
|
7962
8279
|
function resolveLogDestinationFrom(input) {
|
|
8280
|
+
const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
|
|
8281
|
+
if (spoolDir !== undefined && spoolDir.trim() !== "") {
|
|
8282
|
+
return { kind: "folder", folder: spoolDir };
|
|
8283
|
+
}
|
|
7963
8284
|
const local = resolveLogsSetting(input.localConfig);
|
|
7964
8285
|
let effective = null;
|
|
7965
8286
|
let fallbackReason;
|
|
@@ -7999,23 +8320,72 @@ function resolveLogDestinationFrom(input) {
|
|
|
7999
8320
|
const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
|
|
8000
8321
|
return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
|
|
8001
8322
|
}
|
|
8002
|
-
var
|
|
8003
|
-
function processTrustAnchor() {
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8323
|
+
var processTrustAnchorByRepo = new Map;
|
|
8324
|
+
function processTrustAnchor(repoRoot) {
|
|
8325
|
+
const cached = processTrustAnchorByRepo.get(repoRoot);
|
|
8326
|
+
if (cached !== undefined)
|
|
8327
|
+
return cached;
|
|
8328
|
+
const reading = safeLoadTrustAnchorConfig();
|
|
8329
|
+
processTrustAnchorByRepo.set(repoRoot, reading);
|
|
8330
|
+
return reading;
|
|
8007
8331
|
}
|
|
8008
8332
|
async function defaultResolveLogDestination(repo, env) {
|
|
8009
8333
|
const localConfig = loadConfig();
|
|
8010
8334
|
const unattended = isUnattendedProcess(process.env);
|
|
8335
|
+
const repoRoot = repoRootSync();
|
|
8011
8336
|
return resolveLogDestinationFrom({
|
|
8012
8337
|
localConfig,
|
|
8013
|
-
trustAnchorConfig: unattended ? await processTrustAnchor() : null,
|
|
8338
|
+
trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
|
|
8014
8339
|
unattended,
|
|
8015
8340
|
env,
|
|
8016
8341
|
defaultFolder: join6(await runtimeDirForRepoAsync(repo), "logs"),
|
|
8017
|
-
repoRoot
|
|
8342
|
+
repoRoot
|
|
8343
|
+
});
|
|
8344
|
+
}
|
|
8345
|
+
function unresolvedLogDestination(env) {
|
|
8346
|
+
if (hostFromEnv(env) === "ci") {
|
|
8347
|
+
return {
|
|
8348
|
+
kind: "none",
|
|
8349
|
+
reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
|
|
8350
|
+
};
|
|
8351
|
+
}
|
|
8352
|
+
const loaded = loadConfig();
|
|
8353
|
+
const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
|
|
8354
|
+
const unattended = isUnattendedProcess(process.env);
|
|
8355
|
+
const repoRoot = repoRootSync();
|
|
8356
|
+
const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
|
|
8357
|
+
const defaultFolder = join6(runtimeDir, "logs");
|
|
8358
|
+
const resolved = resolveLogDestinationFrom({
|
|
8359
|
+
localConfig,
|
|
8360
|
+
trustAnchorConfig: null,
|
|
8361
|
+
unattended,
|
|
8362
|
+
env,
|
|
8363
|
+
defaultFolder,
|
|
8364
|
+
repoRoot
|
|
8018
8365
|
});
|
|
8366
|
+
return resolved.kind === "folder" ? resolved : { kind: "folder", folder: defaultFolder };
|
|
8367
|
+
}
|
|
8368
|
+
function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
|
|
8369
|
+
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
8370
|
+
return join6(stateRoot, "fallback", `${dirName}.json`);
|
|
8371
|
+
}
|
|
8372
|
+
function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
|
|
8373
|
+
const message = describeFolderFallback(reason);
|
|
8374
|
+
if (issue !== null) {
|
|
8375
|
+
appendLoopLogLine(loopLogPathFor(repo, issue, runtimeDir), `[log] ${message}`);
|
|
8376
|
+
}
|
|
8377
|
+
try {
|
|
8378
|
+
const record = {
|
|
8379
|
+
at: now.toISOString(),
|
|
8380
|
+
reason: message,
|
|
8381
|
+
intendedUrl: reason.intendedUrl,
|
|
8382
|
+
kind: reason.kind
|
|
8383
|
+
};
|
|
8384
|
+
const path = folderFallbackStatePath(repo, stateRoot);
|
|
8385
|
+
mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
|
|
8386
|
+
writeFileSync3(path, `${JSON.stringify(record)}
|
|
8387
|
+
`, { mode: 384 });
|
|
8388
|
+
} catch {}
|
|
8019
8389
|
}
|
|
8020
8390
|
function isEnoent2(err) {
|
|
8021
8391
|
return typeof err === "object" && err !== null && err.code === "ENOENT";
|
|
@@ -8129,7 +8499,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
|
|
|
8129
8499
|
}
|
|
8130
8500
|
function readVinayaVersion() {
|
|
8131
8501
|
try {
|
|
8132
|
-
const pkg = JSON.parse(
|
|
8502
|
+
const pkg = JSON.parse(readFileSync5(join6(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
8133
8503
|
return pkg.version ?? "unknown";
|
|
8134
8504
|
} catch {
|
|
8135
8505
|
return "unknown";
|
|
@@ -8167,6 +8537,7 @@ function defaultStderr(message) {
|
|
|
8167
8537
|
}
|
|
8168
8538
|
var branchIssueFallbackEnabled = true;
|
|
8169
8539
|
var branchIssueByCwd = new Map;
|
|
8540
|
+
var branchIssueSettledByCwd = new Map;
|
|
8170
8541
|
function branchIssueRead(key, read, shared) {
|
|
8171
8542
|
if (!shared)
|
|
8172
8543
|
return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
@@ -8175,8 +8546,30 @@ function branchIssueRead(key, read, shared) {
|
|
|
8175
8546
|
return cached;
|
|
8176
8547
|
const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
8177
8548
|
branchIssueByCwd.set(key, reading);
|
|
8549
|
+
reading.then((value) => branchIssueSettledByCwd.set(key, value));
|
|
8550
|
+
return reading;
|
|
8551
|
+
}
|
|
8552
|
+
var headShaByCwd = new Map;
|
|
8553
|
+
var headShaSettledByCwd = new Map;
|
|
8554
|
+
function headShaRead(key, read, shared) {
|
|
8555
|
+
if (!shared)
|
|
8556
|
+
return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
8557
|
+
const cached = headShaByCwd.get(key);
|
|
8558
|
+
if (cached !== undefined)
|
|
8559
|
+
return cached;
|
|
8560
|
+
const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
8561
|
+
headShaByCwd.set(key, reading);
|
|
8562
|
+
reading.then((value) => headShaSettledByCwd.set(key, value));
|
|
8178
8563
|
return reading;
|
|
8179
8564
|
}
|
|
8565
|
+
async function resolveHeadSha(cwd) {
|
|
8566
|
+
try {
|
|
8567
|
+
const out = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8" })).stdout.trim();
|
|
8568
|
+
return /^[0-9a-f]{40}$/.test(out) ? out : null;
|
|
8569
|
+
} catch {
|
|
8570
|
+
return null;
|
|
8571
|
+
}
|
|
8572
|
+
}
|
|
8180
8573
|
function defaultDeps() {
|
|
8181
8574
|
return {
|
|
8182
8575
|
outboxRoot: () => join6(GLOBAL_VINAYA_HOME, "outbox"),
|
|
@@ -8191,29 +8584,30 @@ function defaultDeps() {
|
|
|
8191
8584
|
inputVersions: () => {
|
|
8192
8585
|
return;
|
|
8193
8586
|
},
|
|
8194
|
-
resolveLogDestination: defaultResolveLogDestination
|
|
8587
|
+
resolveLogDestination: defaultResolveLogDestination,
|
|
8588
|
+
unresolvedLogDestination
|
|
8195
8589
|
};
|
|
8196
8590
|
}
|
|
8197
|
-
var APPEND_OPEN_FLAGS =
|
|
8591
|
+
var APPEND_OPEN_FLAGS = fsConstants4.O_WRONLY | fsConstants4.O_APPEND | fsConstants4.O_CREAT | fsConstants4.O_NOFOLLOW | fsConstants4.O_NONBLOCK;
|
|
8198
8592
|
function guardedAppendOpen(path) {
|
|
8199
8593
|
try {
|
|
8200
|
-
return
|
|
8594
|
+
return openSync4(path, APPEND_OPEN_FLAGS, 384);
|
|
8201
8595
|
} catch {
|
|
8202
8596
|
return;
|
|
8203
8597
|
}
|
|
8204
8598
|
}
|
|
8205
8599
|
function appendHardenedLine(path, line) {
|
|
8206
8600
|
try {
|
|
8207
|
-
|
|
8601
|
+
mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
|
|
8208
8602
|
const fd = guardedAppendOpen(path);
|
|
8209
8603
|
if (fd === undefined)
|
|
8210
8604
|
return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
|
|
8211
8605
|
try {
|
|
8212
|
-
if (!
|
|
8606
|
+
if (!fstatSync3(fd).isFile())
|
|
8213
8607
|
return `target is not a regular file: ${path}`;
|
|
8214
|
-
|
|
8608
|
+
writeSync3(fd, line);
|
|
8215
8609
|
} finally {
|
|
8216
|
-
|
|
8610
|
+
closeSync4(fd);
|
|
8217
8611
|
}
|
|
8218
8612
|
return null;
|
|
8219
8613
|
} catch (err) {
|
|
@@ -8223,7 +8617,7 @@ function appendHardenedLine(path, line) {
|
|
|
8223
8617
|
function reportRotationOverflow(backupPath, warn) {
|
|
8224
8618
|
let raw;
|
|
8225
8619
|
try {
|
|
8226
|
-
raw =
|
|
8620
|
+
raw = readFileSync5(backupPath, "utf8");
|
|
8227
8621
|
} catch {
|
|
8228
8622
|
return;
|
|
8229
8623
|
}
|
|
@@ -8246,7 +8640,7 @@ function reportRotationOverflow(backupPath, warn) {
|
|
|
8246
8640
|
}
|
|
8247
8641
|
function appendLine(path, line, warn) {
|
|
8248
8642
|
try {
|
|
8249
|
-
|
|
8643
|
+
mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
|
|
8250
8644
|
let fd = guardedAppendOpen(path);
|
|
8251
8645
|
if (fd === undefined) {
|
|
8252
8646
|
warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
|
|
@@ -8255,14 +8649,14 @@ function appendLine(path, line, warn) {
|
|
|
8255
8649
|
}
|
|
8256
8650
|
let closed = false;
|
|
8257
8651
|
try {
|
|
8258
|
-
const stat =
|
|
8652
|
+
const stat = fstatSync3(fd);
|
|
8259
8653
|
if (!stat.isFile()) {
|
|
8260
8654
|
warn(`vinaya: log outbox target is not a regular file — refusing to write: ${path}
|
|
8261
8655
|
`);
|
|
8262
8656
|
return;
|
|
8263
8657
|
}
|
|
8264
8658
|
if (stat.size > OUTBOX_MAX_BYTES) {
|
|
8265
|
-
|
|
8659
|
+
closeSync4(fd);
|
|
8266
8660
|
closed = true;
|
|
8267
8661
|
const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
|
|
8268
8662
|
reportRotationOverflow(backupPath, warn);
|
|
@@ -8276,10 +8670,10 @@ function appendLine(path, line, warn) {
|
|
|
8276
8670
|
fd = rotated;
|
|
8277
8671
|
closed = false;
|
|
8278
8672
|
}
|
|
8279
|
-
|
|
8673
|
+
writeSync3(fd, line);
|
|
8280
8674
|
} finally {
|
|
8281
8675
|
if (!closed)
|
|
8282
|
-
|
|
8676
|
+
closeSync4(fd);
|
|
8283
8677
|
}
|
|
8284
8678
|
} catch (err) {
|
|
8285
8679
|
warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
|
|
@@ -8290,12 +8684,14 @@ function createLogSink(overrides = {}) {
|
|
|
8290
8684
|
const deps = {
|
|
8291
8685
|
...defaultDeps(),
|
|
8292
8686
|
resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
|
|
8687
|
+
resolveHeadSha: () => resolveHeadSha(deps.cwd()),
|
|
8293
8688
|
...overrides
|
|
8294
8689
|
};
|
|
8295
8690
|
const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
|
|
8296
8691
|
const processId = randomUUID2();
|
|
8297
8692
|
let seq = 0;
|
|
8298
8693
|
let warned = false;
|
|
8694
|
+
let folderFallbackRecorded = false;
|
|
8299
8695
|
const warnOnce = (message) => {
|
|
8300
8696
|
if (warned)
|
|
8301
8697
|
return;
|
|
@@ -8313,6 +8709,7 @@ function createLogSink(overrides = {}) {
|
|
|
8313
8709
|
};
|
|
8314
8710
|
const readerIsReal = overrides.resolveBranchIssue === undefined;
|
|
8315
8711
|
let ownBranchIssue;
|
|
8712
|
+
let ownBranchIssueSettled = null;
|
|
8316
8713
|
const branchIssueOnce = (repo) => {
|
|
8317
8714
|
if (!branchIssueFallbackEnabled)
|
|
8318
8715
|
return Promise.resolve(null);
|
|
@@ -8320,10 +8717,36 @@ function createLogSink(overrides = {}) {
|
|
|
8320
8717
|
const read = () => deps.resolveBranchIssue(slug);
|
|
8321
8718
|
if (readerIsReal)
|
|
8322
8719
|
return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
|
|
8323
|
-
if (ownBranchIssue === undefined)
|
|
8720
|
+
if (ownBranchIssue === undefined) {
|
|
8324
8721
|
ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
|
|
8722
|
+
ownBranchIssue.then((value) => {
|
|
8723
|
+
ownBranchIssueSettled = value;
|
|
8724
|
+
});
|
|
8725
|
+
}
|
|
8325
8726
|
return ownBranchIssue;
|
|
8326
8727
|
};
|
|
8728
|
+
const branchIssueIfSettled = (repo) => {
|
|
8729
|
+
if (!branchIssueFallbackEnabled)
|
|
8730
|
+
return null;
|
|
8731
|
+
if (!readerIsReal)
|
|
8732
|
+
return ownBranchIssueSettled;
|
|
8733
|
+
return branchIssueSettledByCwd.get(`${deps.cwd()}\x00${safeRepoSlug(repo) ?? ""}`) ?? null;
|
|
8734
|
+
};
|
|
8735
|
+
const headShaReaderIsReal = overrides.resolveHeadSha === undefined;
|
|
8736
|
+
let ownHeadSha;
|
|
8737
|
+
let ownHeadShaSettled = null;
|
|
8738
|
+
const headShaOnce = () => {
|
|
8739
|
+
if (headShaReaderIsReal)
|
|
8740
|
+
return headShaRead(deps.cwd(), deps.resolveHeadSha, true);
|
|
8741
|
+
if (ownHeadSha === undefined) {
|
|
8742
|
+
ownHeadSha = headShaRead(deps.cwd(), deps.resolveHeadSha, false);
|
|
8743
|
+
ownHeadSha.then((value) => {
|
|
8744
|
+
ownHeadShaSettled = value;
|
|
8745
|
+
});
|
|
8746
|
+
}
|
|
8747
|
+
return ownHeadSha;
|
|
8748
|
+
};
|
|
8749
|
+
const headShaIfSettled = () => headShaReaderIsReal ? headShaSettledByCwd.get(deps.cwd()) ?? null : ownHeadShaSettled;
|
|
8327
8750
|
let resolveRepoCache;
|
|
8328
8751
|
const resolveRepoOnce = () => {
|
|
8329
8752
|
if (resolveRepoCache === undefined)
|
|
@@ -8331,6 +8754,7 @@ function createLogSink(overrides = {}) {
|
|
|
8331
8754
|
return resolveRepoCache;
|
|
8332
8755
|
};
|
|
8333
8756
|
let contextCache;
|
|
8757
|
+
let settledContext;
|
|
8334
8758
|
const context = () => {
|
|
8335
8759
|
if (contextCache === undefined) {
|
|
8336
8760
|
const env = deps.env();
|
|
@@ -8339,11 +8763,16 @@ function createLogSink(overrides = {}) {
|
|
|
8339
8763
|
doctrine()
|
|
8340
8764
|
]).then(async ([resolved, doctrineValue]) => {
|
|
8341
8765
|
const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
|
|
8342
|
-
|
|
8766
|
+
settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
|
|
8767
|
+
return settledContext;
|
|
8343
8768
|
});
|
|
8344
8769
|
}
|
|
8345
8770
|
return contextCache;
|
|
8346
8771
|
};
|
|
8772
|
+
const resetContext = () => {
|
|
8773
|
+
contextCache = undefined;
|
|
8774
|
+
settledContext = undefined;
|
|
8775
|
+
};
|
|
8347
8776
|
let drainChain = Promise.resolve();
|
|
8348
8777
|
const pendingWrites = new Set;
|
|
8349
8778
|
let writeChain = Promise.resolve();
|
|
@@ -8355,63 +8784,88 @@ function createLogSink(overrides = {}) {
|
|
|
8355
8784
|
`);
|
|
8356
8785
|
});
|
|
8357
8786
|
};
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8787
|
+
const snapshot = () => {
|
|
8788
|
+
const env = deps.env();
|
|
8789
|
+
return {
|
|
8790
|
+
host: hostFromEnv(env),
|
|
8791
|
+
now: deps.now(),
|
|
8792
|
+
seq: seq++,
|
|
8793
|
+
envFields: {
|
|
8365
8794
|
role: env.VINAYA_ROLE,
|
|
8366
8795
|
task: env.VINAYA_TASK,
|
|
8367
8796
|
round: env.VINAYA_ROUND,
|
|
8797
|
+
pr: env.VINAYA_PR,
|
|
8368
8798
|
run: env.VINAYA_RUN || runId,
|
|
8369
8799
|
attempt: env.VINAYA_ATTEMPT,
|
|
8370
|
-
parent: env.VINAYA_PARENT_EVENT
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8800
|
+
parent: env.VINAYA_PARENT_EVENT,
|
|
8801
|
+
workRef: env.VINAYA_WORK_REF,
|
|
8802
|
+
flow: env.VINAYA_FLOW,
|
|
8803
|
+
flowVersion: env.VINAYA_FLOW_VERSION,
|
|
8804
|
+
runtime: env.VINAYA_RUNTIME,
|
|
8805
|
+
source: env.VINAYA_SOURCE
|
|
8806
|
+
}
|
|
8807
|
+
};
|
|
8808
|
+
};
|
|
8809
|
+
const writeEvent = (e, call, ctx, branchIssue, headSha, deliver) => {
|
|
8810
|
+
const { repo, doctrine: doctrineValue, destination } = ctx;
|
|
8811
|
+
if (destination.kind === "none") {
|
|
8812
|
+
warnOnce(`vinaya: not recording — ${destination.reason}
|
|
8376
8813
|
`);
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8814
|
+
return;
|
|
8815
|
+
}
|
|
8816
|
+
if (destination.kind === "folder" && destination.fallbackReason) {
|
|
8817
|
+
warnOnce(`vinaya: ${describeFolderFallback(destination.fallbackReason)}
|
|
8381
8818
|
`);
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8819
|
+
}
|
|
8820
|
+
const built = buildHeader({
|
|
8821
|
+
now: call.now,
|
|
8822
|
+
runId,
|
|
8823
|
+
seq: call.seq,
|
|
8824
|
+
repo: repo ? `${repo.owner}/${repo.repo}` : null,
|
|
8825
|
+
vinaya: deps.vinayaVersion(),
|
|
8826
|
+
doctrine: doctrineValue,
|
|
8827
|
+
host: call.host,
|
|
8828
|
+
hostname: deps.hostname(),
|
|
8829
|
+
env: call.envFields,
|
|
8830
|
+
branchIssue,
|
|
8831
|
+
eventId: randomUUID2(),
|
|
8832
|
+
processId,
|
|
8833
|
+
inputVersions: deps.inputVersions()
|
|
8834
|
+
});
|
|
8835
|
+
const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
|
|
8836
|
+
if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
|
|
8837
|
+
folderFallbackRecorded = true;
|
|
8838
|
+
recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname6(destination.folder), join6(deps.home(), ".vinaya"));
|
|
8839
|
+
}
|
|
8840
|
+
const full = { ...e, ...header };
|
|
8841
|
+
const parsed = LogEventSchema.safeParse(full);
|
|
8842
|
+
if (!parsed.success) {
|
|
8843
|
+
warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
|
|
8403
8844
|
`);
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8845
|
+
return;
|
|
8846
|
+
}
|
|
8847
|
+
const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
|
|
8407
8848
|
`;
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8849
|
+
if (destination.kind === "server") {
|
|
8850
|
+
appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
|
|
8851
|
+
if (deliver)
|
|
8852
|
+
scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
|
|
8853
|
+
} else {
|
|
8854
|
+
appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
|
|
8855
|
+
}
|
|
8856
|
+
};
|
|
8857
|
+
function log(e) {
|
|
8858
|
+
try {
|
|
8859
|
+
const call = snapshot();
|
|
8860
|
+
const write = async () => {
|
|
8861
|
+
const ctx = await context();
|
|
8862
|
+
if (ctx.destination.kind === "none") {
|
|
8863
|
+
writeEvent(e, call, ctx, null, null, true);
|
|
8864
|
+
return;
|
|
8414
8865
|
}
|
|
8866
|
+
const branchIssue = call.envFields.task ? null : await branchIssueOnce(ctx.repo);
|
|
8867
|
+
const headSha = e.kind === "gate" ? await headShaOnce() : null;
|
|
8868
|
+
writeEvent(e, call, ctx, branchIssue, headSha, true);
|
|
8415
8869
|
};
|
|
8416
8870
|
const written = writeChain.then(write).catch((err) => {
|
|
8417
8871
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
@@ -8422,6 +8876,26 @@ function createLogSink(overrides = {}) {
|
|
|
8422
8876
|
written.finally(() => pendingWrites.delete(written));
|
|
8423
8877
|
} catch (err) {
|
|
8424
8878
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8879
|
+
`);
|
|
8880
|
+
}
|
|
8881
|
+
}
|
|
8882
|
+
function logSync(e, opts = {}) {
|
|
8883
|
+
try {
|
|
8884
|
+
const call = snapshot();
|
|
8885
|
+
let ctx = settledContext;
|
|
8886
|
+
if (ctx === undefined) {
|
|
8887
|
+
const destination = deps.unresolvedLogDestination(deps.env());
|
|
8888
|
+
if (destination.kind === "folder" && !opts.quiet) {
|
|
8889
|
+
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
|
|
8890
|
+
`);
|
|
8891
|
+
}
|
|
8892
|
+
ctx = { repo: null, doctrine: "unknown", destination };
|
|
8893
|
+
}
|
|
8894
|
+
const branchIssue = ctx.destination.kind === "none" || call.envFields.task ? null : branchIssueIfSettled(ctx.repo);
|
|
8895
|
+
const headSha = e.kind === "gate" && ctx.destination.kind !== "none" ? headShaIfSettled() : null;
|
|
8896
|
+
writeEvent(e, call, ctx, branchIssue, headSha, false);
|
|
8897
|
+
} catch (err) {
|
|
8898
|
+
warnOnce(`vinaya: logSync() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8425
8899
|
`);
|
|
8426
8900
|
}
|
|
8427
8901
|
}
|
|
@@ -8442,7 +8916,7 @@ function createLogSink(overrides = {}) {
|
|
|
8442
8916
|
return;
|
|
8443
8917
|
});
|
|
8444
8918
|
};
|
|
8445
|
-
return { log, runId, warmup, drain };
|
|
8919
|
+
return { log, logSync, runId, warmup, drain, resetContext };
|
|
8446
8920
|
}
|
|
8447
8921
|
var defaultSink = createLogSink();
|
|
8448
8922
|
|
|
@@ -8531,16 +9005,9 @@ function summaryLineIndex(maskedRegion) {
|
|
|
8531
9005
|
return index === -1 ? null : index;
|
|
8532
9006
|
}
|
|
8533
9007
|
|
|
8534
|
-
// src/lib/loop-log.ts
|
|
8535
|
-
var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
|
|
8536
|
-
|
|
8537
|
-
// src/lib/diff-evidence.ts
|
|
8538
|
-
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
8539
|
-
import { join as join9, relative, resolve as resolve2 } from "node:path";
|
|
8540
|
-
|
|
8541
9008
|
// src/lib/brief-assembly.ts
|
|
8542
|
-
import { execFileSync as
|
|
8543
|
-
import { existsSync as existsSync7, readFileSync as
|
|
9009
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
9010
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7, readdirSync as readdirSync2 } from "node:fs";
|
|
8544
9011
|
import { join as join8 } from "node:path";
|
|
8545
9012
|
|
|
8546
9013
|
// ../../packages/sources/src/commands.ts
|
|
@@ -8697,7 +9164,7 @@ var COMMANDS = [
|
|
|
8697
9164
|
"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.",
|
|
8698
9165
|
"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.",
|
|
8699
9166
|
"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.",
|
|
8700
|
-
"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
|
|
9167
|
+
"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`)."
|
|
8701
9168
|
],
|
|
8702
9169
|
status: "shipped"
|
|
8703
9170
|
},
|
|
@@ -8782,13 +9249,14 @@ var COMMANDS = [
|
|
|
8782
9249
|
},
|
|
8783
9250
|
{
|
|
8784
9251
|
flag: "--push",
|
|
8785
|
-
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
|
|
9252
|
+
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."
|
|
8786
9253
|
}
|
|
8787
9254
|
],
|
|
8788
9255
|
details: [
|
|
8789
9256
|
"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.",
|
|
8790
9257
|
"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.",
|
|
8791
|
-
"`--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.
|
|
9258
|
+
"`--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.",
|
|
9259
|
+
"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."
|
|
8792
9260
|
],
|
|
8793
9261
|
status: "shipped"
|
|
8794
9262
|
},
|
|
@@ -8813,7 +9281,7 @@ var COMMANDS = [
|
|
|
8813
9281
|
"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.",
|
|
8814
9282
|
"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.",
|
|
8815
9283
|
"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.",
|
|
8816
|
-
"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
|
|
9284
|
+
"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."
|
|
8817
9285
|
],
|
|
8818
9286
|
status: "shipped"
|
|
8819
9287
|
},
|
|
@@ -8984,7 +9452,7 @@ var COMMANDS = [
|
|
|
8984
9452
|
{ flag: "--secrets", description: "security only: the SECRETS line" },
|
|
8985
9453
|
{
|
|
8986
9454
|
flag: "--secrets-evidence-file",
|
|
8987
|
-
description: 'security only: required whenever `--secrets` claims "none found" — the
|
|
9455
|
+
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'
|
|
8988
9456
|
},
|
|
8989
9457
|
{ flag: "--task-id", description: "the closing `Tokens:` line's task id" },
|
|
8990
9458
|
{ flag: "--model", description: "the closing `Tokens:` line's model name" },
|
|
@@ -9092,7 +9560,20 @@ var COMMANDS = [
|
|
|
9092
9560
|
flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
|
|
9093
9561
|
details: [
|
|
9094
9562
|
"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.",
|
|
9095
|
-
"Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes
|
|
9563
|
+
"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.",
|
|
9564
|
+
"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.",
|
|
9565
|
+
"Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
|
|
9566
|
+
"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."
|
|
9567
|
+
],
|
|
9568
|
+
status: "shipped"
|
|
9569
|
+
},
|
|
9570
|
+
{
|
|
9571
|
+
name: "archive tranches",
|
|
9572
|
+
description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
|
|
9573
|
+
flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
|
|
9574
|
+
details: [
|
|
9575
|
+
"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.",
|
|
9576
|
+
"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."
|
|
9096
9577
|
],
|
|
9097
9578
|
status: "shipped"
|
|
9098
9579
|
},
|
|
@@ -9236,6 +9717,29 @@ var COMMANDS = [
|
|
|
9236
9717
|
],
|
|
9237
9718
|
status: "shipped"
|
|
9238
9719
|
},
|
|
9720
|
+
{
|
|
9721
|
+
name: "log selftest",
|
|
9722
|
+
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)",
|
|
9723
|
+
details: [
|
|
9724
|
+
"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.",
|
|
9725
|
+
"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.",
|
|
9726
|
+
"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."
|
|
9727
|
+
],
|
|
9728
|
+
status: "shipped"
|
|
9729
|
+
},
|
|
9730
|
+
{
|
|
9731
|
+
name: "log emit",
|
|
9732
|
+
description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
|
|
9733
|
+
flags: [
|
|
9734
|
+
{ flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
|
|
9735
|
+
],
|
|
9736
|
+
details: [
|
|
9737
|
+
"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.",
|
|
9738
|
+
"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.",
|
|
9739
|
+
"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)."
|
|
9740
|
+
],
|
|
9741
|
+
status: "shipped"
|
|
9742
|
+
},
|
|
9239
9743
|
{
|
|
9240
9744
|
name: "log send",
|
|
9241
9745
|
description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
|
|
@@ -9246,6 +9750,23 @@ var COMMANDS = [
|
|
|
9246
9750
|
"Safe to run more than once: the server stores events by `event_id` and ignores one it already holds, so a re-sent chunk creates no duplicate, and a second run finds the folder emptied and the queue drained."
|
|
9247
9751
|
],
|
|
9248
9752
|
status: "shipped"
|
|
9753
|
+
},
|
|
9754
|
+
{
|
|
9755
|
+
name: "sync",
|
|
9756
|
+
description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
|
|
9757
|
+
flags: [
|
|
9758
|
+
{
|
|
9759
|
+
flag: "--rebuild",
|
|
9760
|
+
description: "Delete the cache file and sync from the beginning of what the destination still retains"
|
|
9761
|
+
},
|
|
9762
|
+
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
9763
|
+
],
|
|
9764
|
+
details: [
|
|
9765
|
+
"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.",
|
|
9766
|
+
"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.",
|
|
9767
|
+
"`--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."
|
|
9768
|
+
],
|
|
9769
|
+
status: "shipped"
|
|
9249
9770
|
}
|
|
9250
9771
|
];
|
|
9251
9772
|
// ../../packages/sources/src/forge-adapter.ts
|
|
@@ -9257,13 +9778,13 @@ function createForgeSource(config) {
|
|
|
9257
9778
|
};
|
|
9258
9779
|
}
|
|
9259
9780
|
// ../../packages/sources/src/select-source.ts
|
|
9260
|
-
import { z as
|
|
9261
|
-
var StateSourceConfigSchema =
|
|
9262
|
-
|
|
9263
|
-
|
|
9781
|
+
import { z as z6 } from "zod";
|
|
9782
|
+
var StateSourceConfigSchema = z6.discriminatedUnion("kind", [
|
|
9783
|
+
z6.object({ kind: z6.literal("forge"), owner: z6.string(), repo: z6.string() }),
|
|
9784
|
+
z6.object({ kind: z6.literal("file"), root: z6.string().optional() })
|
|
9264
9785
|
]);
|
|
9265
9786
|
// src/checks/edge-resolve.ts
|
|
9266
|
-
import { execFileSync as
|
|
9787
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
9267
9788
|
var DIRECT_ISSUE_REF = /#(\d+)/;
|
|
9268
9789
|
var issueCache = new Map;
|
|
9269
9790
|
function fetchIssueState(num, repo) {
|
|
@@ -9272,7 +9793,7 @@ function fetchIssueState(num, repo) {
|
|
|
9272
9793
|
return issueCache.get(key) ?? null;
|
|
9273
9794
|
let out = null;
|
|
9274
9795
|
try {
|
|
9275
|
-
const raw =
|
|
9796
|
+
const raw = execFileSync4("gh", [
|
|
9276
9797
|
"issue",
|
|
9277
9798
|
"view",
|
|
9278
9799
|
String(num),
|
|
@@ -9381,17 +9902,26 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
9381
9902
|
}
|
|
9382
9903
|
|
|
9383
9904
|
// src/commands/doctrine.ts
|
|
9384
|
-
import { execFileSync as
|
|
9385
|
-
import { existsSync as existsSync6, readdirSync, readFileSync as
|
|
9386
|
-
import { dirname as
|
|
9905
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
9906
|
+
import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync6 } from "node:fs";
|
|
9907
|
+
import { dirname as dirname7, join as join7, sep as sep2 } from "node:path";
|
|
9908
|
+
import matter4 from "gray-matter";
|
|
9909
|
+
|
|
9910
|
+
// ../../packages/aeg-core/src/docs/parse-doc.ts
|
|
9387
9911
|
import matter2 from "gray-matter";
|
|
9912
|
+
// ../../packages/aeg-core/src/docs/surfaced-manifest.ts
|
|
9913
|
+
var NO_MODEL_BACKED_PATHS = new Set;
|
|
9914
|
+
// src/roles/contract.ts
|
|
9915
|
+
import matter3 from "gray-matter";
|
|
9916
|
+
|
|
9917
|
+
// src/commands/doctrine.ts
|
|
9388
9918
|
var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
|
|
9389
9919
|
function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
9390
9920
|
return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
|
|
9391
9921
|
}
|
|
9392
9922
|
function gitToplevel(cwd) {
|
|
9393
9923
|
try {
|
|
9394
|
-
return
|
|
9924
|
+
return execFileSync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
9395
9925
|
encoding: "utf8",
|
|
9396
9926
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9397
9927
|
}).trim();
|
|
@@ -9406,8 +9936,8 @@ function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = proce
|
|
|
9406
9936
|
if (existsSync6(join7(treeRoot, "roles")))
|
|
9407
9937
|
return { root: treeRoot, source: "tree" };
|
|
9408
9938
|
}
|
|
9409
|
-
const fromSource = !pkg.split(
|
|
9410
|
-
const bundleRoot = fromSource ? join7(
|
|
9939
|
+
const fromSource = !pkg.split(sep2).includes("node_modules");
|
|
9940
|
+
const bundleRoot = fromSource ? join7(dirname7(dirname7(pkg)), "aeg-root") : join7(pkg, "aeg-root");
|
|
9411
9941
|
return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
|
|
9412
9942
|
}
|
|
9413
9943
|
function hasDoctrineEntry(root) {
|
|
@@ -9420,7 +9950,7 @@ var PACKAGED_TEMPLATE_PATH = join8(PACKAGE_ROOT, "aeg-root", "templates", "brief
|
|
|
9420
9950
|
var TEMPLATE_PATH = existsSync7(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join8(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
9421
9951
|
function git(args) {
|
|
9422
9952
|
try {
|
|
9423
|
-
return
|
|
9953
|
+
return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
9424
9954
|
} catch {
|
|
9425
9955
|
return "";
|
|
9426
9956
|
}
|
|
@@ -9433,155 +9963,13 @@ function expandGlob(glob) {
|
|
|
9433
9963
|
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
9434
9964
|
|
|
9435
9965
|
// src/lib/forge-write.ts
|
|
9966
|
+
var IMPORTABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
9967
|
+
var IMPORT_SEARCH_PATHSPEC = IMPORTABLE_EXTENSIONS.map((e) => `*${e}`);
|
|
9436
9968
|
var INFORMATIONAL_DISPATCH_BLOCKER_CLASSES = new Set([
|
|
9437
9969
|
"depends-on-not-merged",
|
|
9438
9970
|
"conflicts-with"
|
|
9439
9971
|
]);
|
|
9440
9972
|
|
|
9441
|
-
// src/commands/review-post.ts
|
|
9442
|
-
function parseChangedLineRanges(diffOutput) {
|
|
9443
|
-
const result = {};
|
|
9444
|
-
let currentFile = null;
|
|
9445
|
-
for (const line of diffOutput.split(`
|
|
9446
|
-
`)) {
|
|
9447
|
-
if (line.startsWith("+++ ")) {
|
|
9448
|
-
const path = line.slice(4).trim();
|
|
9449
|
-
currentFile = path === "/dev/null" ? null : path.replace(/^b\//, "");
|
|
9450
|
-
continue;
|
|
9451
|
-
}
|
|
9452
|
-
if (line.startsWith("@@") && currentFile) {
|
|
9453
|
-
const m = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/);
|
|
9454
|
-
if (m) {
|
|
9455
|
-
const start = Number(m[1]);
|
|
9456
|
-
const count = m[2] !== undefined ? Number(m[2]) : 1;
|
|
9457
|
-
if (count > 0) {
|
|
9458
|
-
if (!result[currentFile])
|
|
9459
|
-
result[currentFile] = [];
|
|
9460
|
-
result[currentFile].push([start, start + count - 1]);
|
|
9461
|
-
}
|
|
9462
|
-
}
|
|
9463
|
-
}
|
|
9464
|
-
}
|
|
9465
|
-
return result;
|
|
9466
|
-
}
|
|
9467
|
-
|
|
9468
|
-
// src/lib/diff-evidence.ts
|
|
9469
|
-
function fileDiffAgainst(ref, path) {
|
|
9470
|
-
let out;
|
|
9471
|
-
try {
|
|
9472
|
-
out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
9473
|
-
encoding: "utf8",
|
|
9474
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
9475
|
-
}).trim();
|
|
9476
|
-
} catch {
|
|
9477
|
-
return null;
|
|
9478
|
-
}
|
|
9479
|
-
return out === "" ? null : out;
|
|
9480
|
-
}
|
|
9481
|
-
function revParse(ref) {
|
|
9482
|
-
try {
|
|
9483
|
-
return execFileSync6("git", ["rev-parse", "--verify", ref], {
|
|
9484
|
-
encoding: "utf8",
|
|
9485
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
9486
|
-
}).trim();
|
|
9487
|
-
} catch {
|
|
9488
|
-
return null;
|
|
9489
|
-
}
|
|
9490
|
-
}
|
|
9491
|
-
function repoRoot() {
|
|
9492
|
-
try {
|
|
9493
|
-
return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
|
|
9494
|
-
encoding: "utf8",
|
|
9495
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
9496
|
-
}).trim();
|
|
9497
|
-
} catch {
|
|
9498
|
-
return null;
|
|
9499
|
-
}
|
|
9500
|
-
}
|
|
9501
|
-
function changedFiles(base) {
|
|
9502
|
-
let out;
|
|
9503
|
-
try {
|
|
9504
|
-
out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
9505
|
-
encoding: "utf8",
|
|
9506
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
9507
|
-
}).trim();
|
|
9508
|
-
} catch {
|
|
9509
|
-
return null;
|
|
9510
|
-
}
|
|
9511
|
-
return out === "" ? [] : out.split(`
|
|
9512
|
-
`).map((s) => s.trim()).filter(Boolean);
|
|
9513
|
-
}
|
|
9514
|
-
function resolveChangedFiles(base = process.env.BASE_SHA || "origin/main") {
|
|
9515
|
-
return resolveDiff(base)?.files ?? null;
|
|
9516
|
-
}
|
|
9517
|
-
function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
|
|
9518
|
-
const root = repoRoot();
|
|
9519
|
-
if (root === null)
|
|
9520
|
-
return null;
|
|
9521
|
-
const head = revParse("HEAD");
|
|
9522
|
-
for (const ref of [base, "main"]) {
|
|
9523
|
-
const resolved = revParse(ref);
|
|
9524
|
-
if (resolved === null || resolved === head)
|
|
9525
|
-
continue;
|
|
9526
|
-
const relPaths = changedFiles(ref);
|
|
9527
|
-
if (relPaths === null)
|
|
9528
|
-
continue;
|
|
9529
|
-
return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
|
|
9530
|
-
}
|
|
9531
|
-
return null;
|
|
9532
|
-
}
|
|
9533
|
-
function changedLineRanges(ref, path) {
|
|
9534
|
-
const diff = fileDiffAgainst(ref, path);
|
|
9535
|
-
if (diff === null)
|
|
9536
|
-
return null;
|
|
9537
|
-
return parseChangedLineRanges(diff)[path] ?? null;
|
|
9538
|
-
}
|
|
9539
|
-
function lineIsInRanges(line, ranges) {
|
|
9540
|
-
return ranges.some(([start, end]) => line >= start && line <= end);
|
|
9541
|
-
}
|
|
9542
|
-
function findingsInThisDiff(findings) {
|
|
9543
|
-
const diff = resolveDiff();
|
|
9544
|
-
if (diff === null)
|
|
9545
|
-
return [...findings];
|
|
9546
|
-
const changed = new Set(diff.files);
|
|
9547
|
-
const ranges = new Map;
|
|
9548
|
-
return findings.filter((f) => {
|
|
9549
|
-
const abs = resolve2(diff.root, f.file);
|
|
9550
|
-
if (!changed.has(abs))
|
|
9551
|
-
return false;
|
|
9552
|
-
const relPath = relative(diff.root, abs);
|
|
9553
|
-
if (!ranges.has(relPath))
|
|
9554
|
-
ranges.set(relPath, changedLineRanges(diff.base, relPath));
|
|
9555
|
-
const fileRanges = ranges.get(relPath) ?? null;
|
|
9556
|
-
return fileRanges === null ? true : lineIsInRanges(f.line, fileRanges);
|
|
9557
|
-
});
|
|
9558
|
-
}
|
|
9559
|
-
|
|
9560
|
-
// src/lib/dispatch.ts
|
|
9561
|
-
var MAX_TEE_BYTES = 8 * 1024 * 1024;
|
|
9562
|
-
var CLAUDE_MODEL_ALIASES = new Set(["fable", "opus", "sonnet", "haiku"]);
|
|
9563
|
-
var NO_SUBSCRIPTION_LOGIN_REASON = "this agent has no subscription login in Vinaya yet, and no agent authenticates with an API key — " + "dispatch a vendor whose subscription login Vinaya can stage (claude, codex)";
|
|
9564
|
-
|
|
9565
|
-
// src/commands/tokens.ts
|
|
9566
|
-
var USAGE = [
|
|
9567
|
-
'Usage: vinaya tokens --phase "<task-id>: develop" --role Developer',
|
|
9568
|
-
" [--model <id>] [--transcript <path>] [--in <tokens-in> --out <tokens-out>]",
|
|
9569
|
-
"",
|
|
9570
|
-
" --transcript Read this transcript directly. Supported primary route — use it whenever you know",
|
|
9571
|
-
" which transcript is yours, and always in a repo with no track-transcript.sh hook.",
|
|
9572
|
-
" (omitted) Resolve via the Stop-hook pointer file, if this repo installs that hook.",
|
|
9573
|
-
" --in/--out Manual entry: the exact token figures, for a host whose usage arrives by some other",
|
|
9574
|
-
" means than a Claude Code transcript. Both required together; skips transcript",
|
|
9575
|
-
" resolution entirely.",
|
|
9576
|
-
"",
|
|
9577
|
-
"Usage: vinaya tokens --trust-collect",
|
|
9578
|
-
" Approves this repo's declared tokens.collect command, pinned to the script's exact current",
|
|
9579
|
-
" content, on this machine. Run this once before tokens.collect will ever execute — a changed",
|
|
9580
|
-
" interpreter, script path, or script CONTENT needs its own fresh approval. Does not take",
|
|
9581
|
-
" --phase/--role and never emits a Tokens: line."
|
|
9582
|
-
].join(`
|
|
9583
|
-
`);
|
|
9584
|
-
|
|
9585
9973
|
// src/lib/pr-report-engine.ts
|
|
9586
9974
|
var execFileAsync6 = promisify6(execFile6);
|
|
9587
9975
|
var BODY_READING_CHECK_NAMES = new Set(coreCheckRegistry().filter((spec) => {
|
|
@@ -9608,24 +9996,6 @@ function agentCommandText(line) {
|
|
|
9608
9996
|
return (idx === -1 ? line : line.slice(0, idx)).trim();
|
|
9609
9997
|
}
|
|
9610
9998
|
var AGENT_COMMAND_MAX_BUFFER_BYTES = 32 * 1024 * 1024;
|
|
9611
|
-
var TOKEN_ROW_REMEDY = [
|
|
9612
|
-
"Nothing here established that this host cannot meter — only that this session resolved no",
|
|
9613
|
-
"transcript of its own. Report real figures by naming your own transcript:",
|
|
9614
|
-
"",
|
|
9615
|
-
" vinaya pr report --write <body-file> --transcript <path>",
|
|
9616
|
-
"",
|
|
9617
|
-
"or, on a host whose usage arrives by some other means, format figures you already hold with:",
|
|
9618
|
-
"",
|
|
9619
|
-
' vinaya tokens --phase "<task-id>: develop" --role Developer --in <tokens-in> --out <tokens-out>',
|
|
9620
|
-
"",
|
|
9621
|
-
"and transcribe them into the `## Token report` table. That command prints a `Tokens:` line, not",
|
|
9622
|
-
"a table row — the table takes | Phase | Role | Agent/Model | Tokens in | Tokens out | Cost | Date |,",
|
|
9623
|
-
"and a line inside the block that does not start with `|` truncates the table for every row after it."
|
|
9624
|
-
].join(`
|
|
9625
|
-
`);
|
|
9626
|
-
// src/commands/pr-report.ts
|
|
9627
|
-
var USAGE2 = "Usage: vinaya pr report [--write <body-file> | --push <pr> [--body-file <path>]] [--phase <phase>] " + "[--role <role>] [--model <id>] [--transcript <path>]";
|
|
9628
|
-
|
|
9629
9999
|
// src/lib/patch-id.ts
|
|
9630
10000
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
9631
10001
|
function patchIdAt(base, sha) {
|