@warpgogol/forge 7.0.0 → 8.0.4
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/CHANGELOG.md +33 -0
- package/bin/cli.js +6 -12
- package/bin/cli.ts +3 -2
- package/bin/resolve-entry.js +24 -0
- package/dist/bin/cli.js +3 -2
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/authority/authority.module.d.ts +3 -0
- package/dist/os/authority/authority.module.d.ts.map +1 -0
- package/dist/os/authority/authority.module.js +169 -0
- package/dist/os/authority/authority.module.js.map +1 -0
- package/dist/os/authority/handlers/delegate-revoke.d.ts +15 -0
- package/dist/os/authority/handlers/delegate-revoke.d.ts.map +1 -0
- package/dist/os/authority/handlers/delegate-revoke.js +91 -0
- package/dist/os/authority/handlers/delegate-revoke.js.map +1 -0
- package/dist/os/authority/handlers/delegate.d.ts +14 -0
- package/dist/os/authority/handlers/delegate.d.ts.map +1 -0
- package/dist/os/authority/handlers/delegate.js +134 -0
- package/dist/os/authority/handlers/delegate.js.map +1 -0
- package/dist/os/authority/handlers/delegation-list.d.ts +12 -0
- package/dist/os/authority/handlers/delegation-list.d.ts.map +1 -0
- package/dist/os/authority/handlers/delegation-list.js +54 -0
- package/dist/os/authority/handlers/delegation-list.js.map +1 -0
- package/dist/os/authority/handlers/delegation-validate.d.ts +11 -0
- package/dist/os/authority/handlers/delegation-validate.d.ts.map +1 -0
- package/dist/os/authority/handlers/delegation-validate.js +132 -0
- package/dist/os/authority/handlers/delegation-validate.js.map +1 -0
- package/dist/os/authority/helpers.d.ts +36 -0
- package/dist/os/authority/helpers.d.ts.map +1 -0
- package/dist/os/authority/helpers.js +83 -0
- package/dist/os/authority/helpers.js.map +1 -0
- package/dist/os/authority/index.d.ts +2 -0
- package/dist/os/authority/index.d.ts.map +1 -0
- package/dist/os/authority/index.js +14 -0
- package/dist/os/authority/index.js.map +1 -0
- package/dist/os/compass/comment-safety.d.ts +83 -0
- package/dist/os/compass/comment-safety.d.ts.map +1 -0
- package/dist/os/compass/comment-safety.js +305 -0
- package/dist/os/compass/comment-safety.js.map +1 -0
- package/dist/os/compass/compass.module.d.ts.map +1 -1
- package/dist/os/compass/compass.module.js +47 -4
- package/dist/os/compass/compass.module.js.map +1 -1
- package/dist/os/compass/handlers/compass-change-summary-handler.d.ts +2 -1
- package/dist/os/compass/handlers/compass-change-summary-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-change-summary-handler.js +34 -10
- package/dist/os/compass/handlers/compass-change-summary-handler.js.map +1 -1
- package/dist/os/compass/handlers/compass-docs-scaffold.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-docs-scaffold.js +54 -17
- package/dist/os/compass/handlers/compass-docs-scaffold.js.map +1 -1
- package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts +14 -0
- package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -0
- package/dist/os/compass/handlers/compass-header-scaffold-handler.js +261 -0
- package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -0
- package/dist/os/compass/handlers/compass-header-scaffold.d.ts +31 -0
- package/dist/os/compass/handlers/compass-header-scaffold.d.ts.map +1 -0
- package/dist/os/compass/handlers/compass-header-scaffold.js +739 -0
- package/dist/os/compass/handlers/compass-header-scaffold.js.map +1 -0
- package/dist/os/compass/handlers/compass-inventory-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-inventory-handler.js +8 -4
- package/dist/os/compass/handlers/compass-inventory-handler.js.map +1 -1
- package/dist/os/compass/handlers/compass-inventory.d.ts +6 -0
- package/dist/os/compass/handlers/compass-inventory.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-inventory.js +28 -13
- package/dist/os/compass/handlers/compass-inventory.js.map +1 -1
- package/dist/os/compass/handlers/compass-migrate-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-migrate-handler.js +12 -26
- package/dist/os/compass/handlers/compass-migrate-handler.js.map +1 -1
- package/dist/os/compass/handlers/compass-migrate.d.ts +15 -2
- package/dist/os/compass/handlers/compass-migrate.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-migrate.js +58 -20
- package/dist/os/compass/handlers/compass-migrate.js.map +1 -1
- package/dist/os/compass/handlers/git-revision.d.ts +10 -0
- package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
- package/dist/os/compass/handlers/git-revision.js +58 -4
- package/dist/os/compass/handlers/git-revision.js.map +1 -1
- package/dist/os/compass/handlers/summary-record.d.ts +20 -5
- package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
- package/dist/os/compass/handlers/summary-record.js +175 -44
- package/dist/os/compass/handlers/summary-record.js.map +1 -1
- package/dist/os/compass/index.d.ts +1 -0
- package/dist/os/compass/index.d.ts.map +1 -1
- package/dist/os/compass/index.js +2 -0
- package/dist/os/compass/index.js.map +1 -1
- package/dist/os/compass/policy.d.ts +9 -0
- package/dist/os/compass/policy.d.ts.map +1 -1
- package/dist/os/compass/policy.js +11 -2
- package/dist/os/compass/policy.js.map +1 -1
- package/dist/os/core/core.module.js +1 -1
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +1 -6
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/os/queue/types.d.ts +2 -0
- package/dist/os/queue/types.d.ts.map +1 -1
- package/dist/os/queue/types.js +3 -1
- package/dist/os/queue/types.js.map +1 -1
- package/dist/os/rfc/acceptance.d.ts.map +1 -1
- package/dist/os/rfc/acceptance.js +51 -1
- package/dist/os/rfc/acceptance.js.map +1 -1
- package/dist/os/rfc/decision-log.d.ts.map +1 -1
- package/dist/os/rfc/decision-log.js +21 -3
- package/dist/os/rfc/decision-log.js.map +1 -1
- package/dist/os/rfc/dna-trace.d.ts +2 -0
- package/dist/os/rfc/dna-trace.d.ts.map +1 -1
- package/dist/os/rfc/dna-trace.js +13 -4
- package/dist/os/rfc/dna-trace.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp-origin.d.ts +37 -0
- package/dist/os/rfc/handlers/implement-stamp-origin.d.ts.map +1 -0
- package/dist/os/rfc/handlers/implement-stamp-origin.js +118 -0
- package/dist/os/rfc/handlers/implement-stamp-origin.js.map +1 -0
- package/dist/os/rfc/handlers/implement-stamp.d.ts +41 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +594 -81
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +42 -0
- package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -0
- package/dist/os/rfc/handlers/rfc-evidence-sync.js +147 -0
- package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -0
- package/dist/os/rfc/handlers/validate-rules.d.ts +9 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +90 -9
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/reachable-symbol.d.ts +17 -0
- package/dist/os/rfc/reachable-symbol.d.ts.map +1 -0
- package/dist/os/rfc/reachable-symbol.js +376 -0
- package/dist/os/rfc/reachable-symbol.js.map +1 -0
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +89 -5
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +89 -12
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +17 -10
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/rfc/verification-evidence.d.ts +10 -1
- package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
- package/dist/os/rfc/verification-evidence.js +175 -10
- package/dist/os/rfc/verification-evidence.js.map +1 -1
- package/dist/os/rfc/verification-origin.d.ts +58 -0
- package/dist/os/rfc/verification-origin.d.ts.map +1 -0
- package/dist/os/rfc/verification-origin.js +346 -0
- package/dist/os/rfc/verification-origin.js.map +1 -0
- package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
- package/dist/os/rfc/verification-refresh.js +11 -1
- package/dist/os/rfc/verification-refresh.js.map +1 -1
- package/dist/os/rfc/verify-workspace.d.ts +23 -0
- package/dist/os/rfc/verify-workspace.d.ts.map +1 -0
- package/dist/os/rfc/verify-workspace.js +278 -0
- package/dist/os/rfc/verify-workspace.js.map +1 -0
- package/dist/os/session/handlers/metrics-rfc.d.ts.map +1 -1
- package/dist/os/session/handlers/metrics-rfc.js +3 -0
- package/dist/os/session/handlers/metrics-rfc.js.map +1 -1
- package/dist/os/session/handlers/save.d.ts.map +1 -1
- package/dist/os/session/handlers/save.js +41 -10
- package/dist/os/session/handlers/save.js.map +1 -1
- package/dist/os/spec/spec-status.d.ts.map +1 -1
- package/dist/os/spec/spec-status.js +5 -23
- package/dist/os/spec/spec-status.js.map +1 -1
- package/dist/os/spec/spec-validate.d.ts.map +1 -1
- package/dist/os/spec/spec-validate.js +30 -9
- package/dist/os/spec/spec-validate.js.map +1 -1
- package/dist/os/workflow/handlers.d.ts +0 -4
- package/dist/os/workflow/handlers.d.ts.map +1 -1
- package/dist/os/workflow/handlers.js +9 -36
- package/dist/os/workflow/handlers.js.map +1 -1
- package/dist/os/workflow/index.d.ts +2 -2
- package/dist/os/workflow/index.d.ts.map +1 -1
- package/dist/os/workflow/index.js +1 -1
- package/dist/os/workflow/index.js.map +1 -1
- package/dist/os/workflow/types.d.ts +0 -19
- package/dist/os/workflow/types.d.ts.map +1 -1
- package/dist/os/workflow/types.js +0 -2
- package/dist/os/workflow/types.js.map +1 -1
- package/dist/os/workflow/workflow.module.d.ts.map +1 -1
- package/dist/os/workflow/workflow.module.js +6 -15
- package/dist/os/workflow/workflow.module.js.map +1 -1
- package/dist/src/authority/delegations.d.ts +108 -0
- package/dist/src/authority/delegations.d.ts.map +1 -0
- package/dist/src/authority/delegations.js +217 -0
- package/dist/src/authority/delegations.js.map +1 -0
- package/dist/src/authority/index.d.ts +3 -0
- package/dist/src/authority/index.d.ts.map +1 -0
- package/dist/src/authority/index.js +17 -0
- package/dist/src/authority/index.js.map +1 -0
- package/dist/src/authority/signing.d.ts +8 -0
- package/dist/src/authority/signing.d.ts.map +1 -0
- package/dist/src/authority/signing.js +72 -0
- package/dist/src/authority/signing.js.map +1 -0
- package/dist/src/config/forge-config.d.ts +5 -0
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +5 -2
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/onboarding/agents-generate.js +1 -1
- package/dist/src/onboarding/doctor.js +3 -3
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/init.js +2 -2
- package/dist/src/onboarding/nested-agents-templates.js +1 -1
- package/dist/src/onboarding/prettierignore.js +1 -1
- package/dist/src/onboarding/upgrade.js +2 -2
- package/dist/src/onboarding/workspace-discovery.js +1 -1
- package/dist/src/profiles/profile-schema.d.ts +2 -0
- package/dist/src/profiles/profile-schema.d.ts.map +1 -1
- package/dist/src/profiles/profile-schema.js +1 -0
- package/dist/src/profiles/profile-schema.js.map +1 -1
- package/dist/src/profiles/stack-profile.d.ts +1 -0
- package/dist/src/profiles/stack-profile.d.ts.map +1 -1
- package/dist/src/types.d.ts +23 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -1
- package/dist/src/types.js.map +1 -1
- package/docs/reference/cli.md +0 -1
- package/docs/reference/programmatic-api.md +1 -1
- package/os/adr/handlers/validate.test.ts +14 -0
- package/os/authority/authority.module.ts +183 -0
- package/os/authority/authority.test.ts +328 -0
- package/os/authority/handlers/delegate-revoke.ts +123 -0
- package/os/authority/handlers/delegate.ts +190 -0
- package/os/authority/handlers/delegation-list.ts +80 -0
- package/os/authority/handlers/delegation-validate.ts +231 -0
- package/os/authority/helpers.ts +111 -0
- package/os/authority/index.ts +14 -0
- package/os/compass/comment-safety.ts +331 -0
- package/os/compass/compass.module.ts +50 -4
- package/os/compass/handlers/compass-change-summary-handler.ts +41 -11
- package/os/compass/handlers/compass-docs-scaffold.ts +59 -17
- package/os/compass/handlers/compass-game-extensions.test.ts +3 -7
- package/os/compass/handlers/compass-header-scaffold-handler.ts +352 -0
- package/os/compass/handlers/compass-header-scaffold.ts +847 -0
- package/os/compass/handlers/compass-inventory-handler.ts +9 -4
- package/os/compass/handlers/compass-inventory.ts +29 -13
- package/os/compass/handlers/compass-migrate-handler.ts +13 -27
- package/os/compass/handlers/compass-migrate.ts +77 -21
- package/os/compass/handlers/git-revision.ts +59 -4
- package/os/compass/handlers/resolve-scan-root-package.test.ts +14 -0
- package/os/compass/handlers/resolve-scan-root-workpiece.test.ts +14 -0
- package/os/compass/handlers/summary-record.ts +194 -41
- package/os/compass/handlers/tests/compass-audit-plan.test.ts +6 -0
- package/os/compass/handlers/tests/compass-audit-record.test.ts +6 -0
- package/os/compass/handlers/tests/compass-audit-validate.test.ts +6 -0
- package/os/compass/handlers/tests/compass-change-summary-handler.test.ts +131 -0
- package/os/compass/handlers/tests/compass-docs-validate.test.ts +6 -0
- package/os/compass/handlers/tests/compass-header-scaffold.test.ts +896 -0
- package/os/compass/handlers/tests/compass-ledger-scope.test.ts +6 -0
- package/os/compass/handlers/tests/compass-migrate.test.ts +87 -9
- package/os/compass/handlers/tests/compass-policy.test.ts +1 -1
- package/os/compass/handlers/tests/compass-text-safety.test.ts +271 -0
- package/os/compass/handlers/tests/compass-v2-contract.test.ts +52 -3
- package/os/compass/handlers/tests/summary-record.test.ts +324 -3
- package/os/compass/index.ts +15 -0
- package/os/compass/policy.ts +27 -2
- package/os/core/core.module.ts +1 -1
- package/os/core/handlers/invariant-engine.test.ts +3 -1
- package/os/core/handlers/note-frontmatter-validate.test.ts +6 -1
- package/os/core/handlers/note-link-validate.test.ts +6 -1
- package/os/core/handlers/note-orphan-detect.test.ts +6 -1
- package/os/core/handlers/package-health.test.ts +6 -0
- package/os/core/handlers/package-health.ts +1 -6
- package/os/mission/handlers/archive.test.ts +14 -0
- package/os/naming/naming-convention.test.ts +14 -0
- package/os/queue/decision-ledger.test.ts +27 -4
- package/os/queue/queue-validate.test.ts +14 -0
- package/os/queue/types.ts +3 -1
- package/os/rfc/acceptance-reachable.test.ts +146 -0
- package/os/rfc/acceptance.test.ts +25 -0
- package/os/rfc/acceptance.ts +51 -1
- package/os/rfc/decision-log.ts +22 -4
- package/os/rfc/dna-trace.ts +17 -5
- package/os/rfc/frontmatter-io.test.ts +14 -0
- package/os/rfc/handlers/implement-stamp-acceptance-verification.test.ts +81 -0
- package/os/rfc/handlers/implement-stamp-binding.test.ts +79 -0
- package/os/rfc/handlers/implement-stamp-origin.test.ts +132 -0
- package/os/rfc/handlers/implement-stamp-origin.ts +154 -0
- package/os/rfc/handlers/implement-stamp-stale.test.ts +20 -2
- package/os/rfc/handlers/implement-stamp.ts +714 -87
- package/os/rfc/handlers/lifecycle.test.ts +14 -0
- package/os/rfc/handlers/rfc-evidence-sync.ts +221 -0
- package/os/rfc/handlers/validate-rules-rfc0997.test.ts +14 -0
- package/os/rfc/handlers/validate-rules-rfc1006.test.ts +14 -0
- package/os/rfc/handlers/validate-rules-rfc1330.test.ts +120 -0
- package/os/rfc/handlers/validate-rules-rfc1334.test.ts +65 -0
- package/os/rfc/handlers/validate-rules.test.ts +14 -0
- package/os/rfc/handlers/validate-rules.ts +122 -13
- package/os/rfc/handlers/validate.test.ts +4 -3
- package/os/rfc/reachable-symbol.ts +441 -0
- package/os/rfc/rfc-0000-template.md +3 -0
- package/os/rfc/rfc-create-concurrent.test.ts +6 -0
- package/os/rfc/rfc-create-hint.test.ts +6 -0
- package/os/rfc/rfc-read-only-no-side-effects.test.ts +6 -0
- package/os/rfc/rfc.module.ts +95 -5
- package/os/rfc/types.ts +116 -12
- package/os/rfc/verification-emit-check.test.ts +14 -0
- package/os/rfc/verification-emit-freshness.test.ts +415 -0
- package/os/rfc/verification-emit.test.ts +14 -0
- package/os/rfc/verification-evidence.ts +230 -10
- package/os/rfc/verification-normalize.test.ts +14 -0
- package/os/rfc/verification-origin.test.ts +236 -0
- package/os/rfc/verification-origin.ts +417 -0
- package/os/rfc/verification-refresh.test.ts +14 -0
- package/os/rfc/verification-refresh.ts +12 -1
- package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +78 -0
- package/os/rfc/verifier/rfc-1333/imp12-gate.acceptance.test.ts +81 -0
- package/os/rfc/verifier/rfc-1333/skills-and-types.acceptance.test.ts +50 -0
- package/os/rfc/verifier/rfc-1333/verify-workspace.acceptance.test.ts +103 -0
- package/os/rfc/verify-workspace.test.ts +122 -0
- package/os/rfc/verify-workspace.ts +342 -0
- package/os/session/handlers/metrics-rfc.ts +3 -0
- package/os/session/handlers/save.ts +43 -9
- package/os/spec/spec-status.test.ts +130 -0
- package/os/spec/spec-status.ts +5 -18
- package/os/spec/spec-validate.test.ts +76 -1
- package/os/spec/spec-validate.ts +26 -7
- package/os/workflow/handlers.ts +8 -42
- package/os/workflow/index.ts +1 -4
- package/os/workflow/types.ts +0 -22
- package/os/workflow/workflow.module.ts +6 -16
- package/package.json +13 -1
- package/skills/_shared/agent-operating-model.md +1 -1
- package/skills/_shared/fo-pipeline-conventions.md +1 -0
- package/skills/fo/fo-add-tests/SKILL.md +14 -0
- package/skills/fo/fo-fix/SKILL.md +2 -1
- package/skills/fo/fo-handoff/SKILL.md +1 -1
- package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +8 -0
- package/skills/fo/fo-idea-i-just-want-to-see-the-result/SKILL.md +4 -2
- package/skills/fo/fo-idea-implement/SKILL.md +68 -53
- package/skills/fo/fo-idea-plan/SKILL.md +3 -1
- package/skills/fo/fo-review/SKILL.md +12 -0
- package/skills/fo/fo-session-save/learned-principles.md +13 -0
- package/skills/fo/fo-step-commit/SKILL.md +1 -1
- package/src/authority/delegations.ts +267 -0
- package/src/authority/index.ts +38 -0
- package/src/authority/signing.ts +73 -0
- package/src/bin-entry.test.ts +37 -0
- package/src/compass/contract-registry.test.ts +14 -0
- package/src/compass/types.test.ts +14 -0
- package/src/config/__tests__/resolve-terminology.test.ts +14 -0
- package/src/config/forge-config.test.ts +14 -0
- package/src/config/forge-config.ts +7 -2
- package/src/forge-module.test.ts +14 -0
- package/src/knowledge/__tests__/promote.test.ts +14 -0
- package/src/knowledge/__tests__/serialize.test.ts +14 -0
- package/src/knowledge/__tests__/sync.test.ts +4 -1
- package/src/knowledge/budgets.test.ts +14 -0
- package/src/knowledge/compact.test.ts +14 -0
- package/src/knowledge/parse.test.ts +14 -0
- package/src/knowledge/schema.test.ts +14 -0
- package/src/migration-adapters/__tests__/ignored-files.test.ts +14 -0
- package/src/migration-adapters/__tests__/registry.test.ts +14 -0
- package/src/migration-adapters/__tests__/types.test.ts +14 -0
- package/src/onboarding/__tests__/workspace-discovery.test.ts +14 -0
- package/src/onboarding/agents-generate.ts +1 -1
- package/src/onboarding/compass-docs/semantic-layer-block.test.ts +6 -0
- package/src/onboarding/create.test.ts +14 -0
- package/src/onboarding/doctor-token-check.test.ts +3 -0
- package/src/onboarding/doctor.test.ts +14 -0
- package/src/onboarding/doctor.ts +3 -3
- package/src/onboarding/init.test.ts +14 -0
- package/src/onboarding/init.ts +2 -2
- package/src/onboarding/nested-agents-templates.ts +1 -1
- package/src/onboarding/prettierignore.ts +1 -1
- package/src/onboarding/scaffold.test.ts +14 -0
- package/src/onboarding/site-workshop-profile.test.ts +3 -0
- package/src/onboarding/upgrade.test.ts +14 -0
- package/src/onboarding/upgrade.ts +2 -2
- package/src/onboarding/workspace-discovery.ts +1 -1
- package/src/pipeline-status.test.ts +14 -0
- package/src/plugin/forge-plugin-manifest.test.ts +14 -0
- package/src/profiles/__tests__/profile-schema.test.ts +14 -0
- package/src/profiles/__tests__/stack-profile.test.ts +14 -0
- package/src/profiles/__tests__/terminology-utils.test.ts +14 -0
- package/src/profiles/profile-schema.ts +1 -0
- package/src/tests/acceptance-criteria.test.ts +14 -0
- package/src/tests/acceptance-probe-kinds.test.ts +14 -0
- package/src/tests/adr-implement-stamp.test.ts +14 -0
- package/src/tests/agents-generate-domain.test.ts +3 -0
- package/src/tests/agents-generate.test.ts +3 -0
- package/src/tests/bindings-schema.test.ts +2 -0
- package/src/tests/budgets.test.ts +14 -0
- package/src/tests/compact.test.ts +14 -0
- package/src/tests/compass-docs-flag.test.ts +6 -0
- package/src/tests/compass-docs-scaffold.test.ts +6 -0
- package/src/tests/compass-docs-validate-scope.test.ts +6 -0
- package/src/tests/contract-registry.test.ts +14 -0
- package/src/tests/create.test.ts +3 -0
- package/src/tests/discover-pack-skills.test.ts +14 -0
- package/src/tests/doctor-autonomy.test.ts +3 -0
- package/src/tests/doctor-bindings.test.ts +6 -1
- package/src/tests/doctor-dist-freshness.test.ts +26 -2
- package/src/tests/doctor-domain.test.ts +6 -1
- package/src/tests/doctor-fix.test.ts +3 -0
- package/src/tests/doctor-nested-agents.test.ts +3 -0
- package/src/tests/doctor-profile-id-known.test.ts +3 -0
- package/src/tests/doctor-skills-unmanaged.test.ts +3 -0
- package/src/tests/doctor-version-sync.test.ts +4 -1
- package/src/tests/editable-generated-region.test.ts +6 -3
- package/src/tests/exploration-handlers.test.ts +14 -0
- package/src/tests/file-size-lint.test.ts +6 -1
- package/src/tests/forge-autonomy-validate.test.ts +3 -1
- package/src/tests/forge-config.test.ts +6 -1
- package/src/tests/forge-validate-compass-docs.test.ts +6 -0
- package/src/tests/fs-atomic.test.ts +14 -0
- package/src/tests/fs.test.ts +14 -0
- package/src/tests/generated-marker.test.ts +14 -0
- package/src/tests/hash.test.ts +14 -0
- package/src/tests/implement-stamp.test.ts +476 -10
- package/src/tests/init-bindings.test.ts +6 -1
- package/src/tests/knowledge-parse.test.ts +14 -0
- package/src/tests/knowledge-pbt.test.ts +14 -0
- package/src/tests/markdown-table.test.ts +6 -3
- package/src/tests/memory-compact.test.ts +3 -0
- package/src/tests/memory-scaffold.test.ts +6 -1
- package/src/tests/metrics-rfc-1053.test.ts +14 -0
- package/src/tests/migration-adapters.test.ts +3 -0
- package/src/tests/package-files.test.ts +4 -1
- package/src/tests/package-health-lint-surface.test.ts +3 -0
- package/src/tests/pinned-check.test.ts +14 -0
- package/src/tests/pinned-init.test.ts +14 -0
- package/src/tests/pinned-validate.test.ts +14 -0
- package/src/tests/plugin-manifest.test.ts +14 -0
- package/src/tests/prettierignore-manage.test.ts +3 -0
- package/src/tests/profile-schema.test.ts +6 -1
- package/src/tests/profile-validate.test.ts +6 -1
- package/src/tests/program-lease.test.ts +3 -0
- package/src/tests/program-paths-extended.test.ts +3 -0
- package/src/tests/program-paths.test.ts +3 -0
- package/src/tests/program-property.test.ts +3 -0
- package/src/tests/program-schemas.test.ts +3 -0
- package/src/tests/program-spec-node.test.ts +3 -0
- package/src/tests/promote.test.ts +14 -0
- package/src/tests/public-surface.test.ts +6 -1
- package/src/tests/registry.test.ts +14 -0
- package/src/tests/rfc-evidence-sync.test.ts +347 -0
- package/src/tests/rfc-implement-stamp-governance.test.ts +403 -0
- package/src/tests/rfc-validate-delegation.test.ts +178 -0
- package/src/tests/scaffold-project.test.ts +3 -0
- package/src/tests/session-handlers.test.ts +79 -0
- package/src/tests/session-pbt.test.ts +14 -0
- package/src/tests/skill-agents-sync.test.ts +3 -4
- package/src/tests/skill-schema.test.ts +14 -0
- package/src/tests/skill-sync-marker.test.ts +3 -0
- package/src/tests/skill-validate-knowledge.test.ts +14 -0
- package/src/tests/skill-validate.test.ts +14 -0
- package/src/tests/stack-profile.test.ts +6 -1
- package/src/tests/string-utils.test.ts +14 -0
- package/src/tests/upgrade.test.ts +6 -1
- package/src/tests/werkstatt-lock.test.ts +14 -0
- package/src/tests/workspace-discovery-domain.test.ts +6 -1
- package/src/tests/workspace-discovery.test.ts +6 -1
- package/src/types.test.ts +14 -0
- package/src/types.ts +30 -1
- package/src/utils/__tests__/fs-idempotent.test.ts +17 -0
- package/src/utils/__tests__/fs-trash.test.ts +17 -0
- package/src/utils/fs-atomic.test.ts +17 -0
- package/src/utils/fs-trash-sync.test.ts +17 -0
- package/src/utils/fs.test.ts +17 -0
- package/src/utils/generated-marker.test.ts +17 -0
- package/src/utils/hash.test.ts +17 -0
- package/src/utils/string-utils.test.ts +17 -0
- package/src/validators/__tests__/note-orphan-detect.test.ts +14 -0
|
@@ -12,21 +12,17 @@ verification evidence, and atomically mutates RFC frontmatter.
|
|
|
12
12
|
</non-goals>
|
|
13
13
|
</MODULE_CONTRACT>
|
|
14
14
|
<CHANGE_SUMMARY>
|
|
15
|
-
<item>RFC-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<item>RFC-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<item>Session-retro 2026-10-08: auto-detect picks the sole implement/feat-prefixed candidate among multi-commit references (RFC-IMP-03 no longer blocks full pipelines); ambiguous sets keep blocking with annotated candidate list + earliest-candidate suggestion.</item>
|
|
22
|
-
<item>RFC-1249: wire werkstatt.commands.validate into packages.check + retire CMD-OUTPUT debt</item>
|
|
23
|
-
<item>RFC-1271: review wave — deep probe normalization, malformed-envelope fail-closed, post-stamp re-emit, honest repair hints</item>
|
|
24
|
-
<history>RFC-0268, RFC-0476, RFC-0756, RFC-0795, RFC-0997, RFC-1053, RFC-IMP-07</history>
|
|
15
|
+
<item>RFC-1322: fo-review fix pass — io-injected resolver hardening (empty/dir/escape paths fail closed, line-range strip, probes-less envelope guard), shared IMP-06/09 evaluator, dry-run JSON fields, helpers exported per plan</item>
|
|
16
|
+
<item>RFC-1322: evidence annotation extraction takes the last occurrence — prose mentions no longer shadow the annotation</item>
|
|
17
|
+
<item>RFC-1330: origin gates wired into the shared evidence evaluator; non-blocking warnings surfaced in results.</item>
|
|
18
|
+
<item>RFC-1333: steps 1-3 — report contract, rfc.verify.workspace export, RFC-IMP-12 gate, RFC-IMP-11 blocking</item>
|
|
19
|
+
<item>RFC-1333: CX-1/CX-2 fixes — docs/** binding, waiver covers a missing report, IMP-12 for probe-less RFCs; merge-aware fail-closed binding.</item>
|
|
20
|
+
<history>RFC-0268, RFC-0476, RFC-0756, RFC-0795, RFC-0997, RFC-1053, RFC-1097, RFC-1249, RFC-1271, RFC-1306, RFC-1310, RFC-1321, RFC-1322, RFC-IMP-07</history>
|
|
25
21
|
</CHANGE_SUMMARY>
|
|
26
22
|
*/
|
|
27
23
|
import { execFile, writeFileSync } from "../../../src/utils/sync-fs.js";
|
|
28
24
|
import { ambientIo, resolveIo } from "../../../src/utils/io.js";
|
|
29
|
-
import { join, dirname } from "node:path";
|
|
25
|
+
import { join, dirname, relative, resolve, sep } from "node:path";
|
|
30
26
|
import { writeFileAtomic } from "../../../src/utils/fs-atomic.js";
|
|
31
27
|
import { parse as yamlParse } from "yaml";
|
|
32
28
|
import { generateRfcMetrics } from "../../session/handlers/metrics-rfc.js";
|
|
@@ -34,7 +30,9 @@ import { listRfcFiles, readAndParseRfc, rfcFileMatchesId, loadRfcStatusMap, } fr
|
|
|
34
30
|
import { evaluateAcceptanceCriteria } from "./validate-rules.js";
|
|
35
31
|
import { toIsoDate } from "./shared.js";
|
|
36
32
|
import { byteHashHex, normalizeProbes, runRfcVerificationEmit } from "../verification-evidence.js";
|
|
37
|
-
import { RFC_DIR, RFC_METADATA_CUTOFF, RFC_PROBE_BINDING_CUTOFF } from "../types.js";
|
|
33
|
+
import { RFC_DIR, RFC_METADATA_CUTOFF, RFC_ORIGIN_CUTOFF, RFC_PROBE_BINDING_CUTOFF, } from "../types.js";
|
|
34
|
+
import { createOriginGit, deriveProbeOrigins, gitEnvForCwd, hasVerifierTrailers, } from "../verification-origin.js";
|
|
35
|
+
import { ACCEPTANCE_REPORTS_DIR, evaluateAcceptanceVerificationGate, evaluateOriginGates, } from "./implement-stamp-origin.js";
|
|
38
36
|
// Ambient default for helper fns without a context param — handlers override
|
|
39
37
|
// with `const io = resolveIo(context.io)` inside their own scope.
|
|
40
38
|
const io = ambientIo;
|
|
@@ -46,7 +44,7 @@ const VERIFICATION_DIR = join(RFC_DIR, "verification");
|
|
|
46
44
|
const IMPLEMENTATION_SUBJECT_RE = /^(implement|feat)(\([^)]*\))?!?:/i;
|
|
47
45
|
function execGit(workspaceRoot, args) {
|
|
48
46
|
return new Promise((resolve) => {
|
|
49
|
-
execFile("git", args, { cwd: workspaceRoot, timeout:
|
|
47
|
+
execFile("git", args, { cwd: workspaceRoot, timeout: 30000, env: gitEnvForCwd() }, (err, stdout) => {
|
|
50
48
|
if (err) {
|
|
51
49
|
resolve("");
|
|
52
50
|
return;
|
|
@@ -65,7 +63,7 @@ async function commitReachableFromHead(workspaceRoot, commitSha) {
|
|
|
65
63
|
// execGit returns "" on error (non-zero exit), trimmed stdout on success
|
|
66
64
|
// So we need a different approach: check exit code directly
|
|
67
65
|
return new Promise((resolve) => {
|
|
68
|
-
execFile("git", ["merge-base", "--is-ancestor", commitSha, "HEAD"], { cwd: workspaceRoot, timeout:
|
|
66
|
+
execFile("git", ["merge-base", "--is-ancestor", commitSha, "HEAD"], { cwd: workspaceRoot, timeout: 30000, env: gitEnvForCwd() }, (err) => {
|
|
69
67
|
resolve(!err);
|
|
70
68
|
});
|
|
71
69
|
});
|
|
@@ -74,6 +72,7 @@ async function autoDetectImplementationCommit(workspaceRoot, rfcId) {
|
|
|
74
72
|
const hashes = await execGit(workspaceRoot, [
|
|
75
73
|
"log",
|
|
76
74
|
"--fixed-strings",
|
|
75
|
+
"--regexp-ignore-case",
|
|
77
76
|
"--no-merges",
|
|
78
77
|
`--grep=${rfcId}`,
|
|
79
78
|
"--format=%H",
|
|
@@ -86,6 +85,7 @@ async function autoDetectImplementationCommit(workspaceRoot, rfcId) {
|
|
|
86
85
|
const details = await execGit(workspaceRoot, [
|
|
87
86
|
"log",
|
|
88
87
|
"--fixed-strings",
|
|
88
|
+
"--regexp-ignore-case",
|
|
89
89
|
"--no-merges",
|
|
90
90
|
`--grep=${rfcId}`,
|
|
91
91
|
"--format=%h %s",
|
|
@@ -101,10 +101,37 @@ async function autoDetectImplementationCommit(workspaceRoot, rfcId) {
|
|
|
101
101
|
});
|
|
102
102
|
return { multiple: candidates };
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* RFC-1310 STAMP-GOV-01: provenance, not mere reference — the commit carries
|
|
106
|
+
* an `X-RFC:`/`X-ADR:` trailer naming the id (ecosystem.commit --rfc/--adr)
|
|
107
|
+
* or its diff adds a CHANGE_SUMMARY `<item>` naming the id (the injection
|
|
108
|
+
* itself, e.g. commits made before the trailer existed).
|
|
109
|
+
*/
|
|
110
|
+
async function commitCarriesGovernanceProvenance(workspaceRoot, commitSha, rfcId) {
|
|
111
|
+
const idUpper = rfcId.toUpperCase();
|
|
112
|
+
// RFC-1321 review-r2: same (?!\d) boundary as commitReferencesRfc —
|
|
113
|
+
// X-RFC: RFC-00011 must not satisfy provenance for RFC-0001.
|
|
114
|
+
const idRe = new RegExp(`${idUpper.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?!\\d)`);
|
|
115
|
+
const commitMsg = await execGit(workspaceRoot, ["log", "-1", "--format=%B", commitSha]);
|
|
116
|
+
if (commitMsg.split("\n").some((l) => /^X-(?:RFC|ADR):\s*\S/i.test(l) && idRe.test(l.toUpperCase()))) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
const diff = await execGit(workspaceRoot, ["show", "-U0", "--format=", commitSha]);
|
|
120
|
+
return diff
|
|
121
|
+
.split("\n")
|
|
122
|
+
.some((l) => l.startsWith("+") &&
|
|
123
|
+
!l.startsWith("+++") &&
|
|
124
|
+
l.includes("<item>") &&
|
|
125
|
+
idRe.test(l.toUpperCase()));
|
|
126
|
+
}
|
|
104
127
|
async function commitReferencesRfc(workspaceRoot, commitSha, rfcId) {
|
|
105
128
|
// Check the commit message and the diff for the RFC ID
|
|
106
129
|
const commitMsg = await execGit(workspaceRoot, ["log", "-1", "--format=%B", commitSha]);
|
|
107
|
-
|
|
130
|
+
// RFC-1321: governance ids compare case-insensitively — `--id rfc-1310` must
|
|
131
|
+
// satisfy an `RFC-1310` subject (the RFC-IMP-03 false-fail). The (?!\d)
|
|
132
|
+
// boundary keeps RFC-0001 from matching RFC-00011.
|
|
133
|
+
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
134
|
+
if (new RegExp(`${esc(rfcId.toUpperCase())}(?!\\d)`).test(commitMsg.toUpperCase()))
|
|
108
135
|
return true;
|
|
109
136
|
// Also check if the commit touched a file whose name contains the RFC id
|
|
110
137
|
const changedFiles = await execGit(workspaceRoot, [
|
|
@@ -114,7 +141,7 @@ async function commitReferencesRfc(workspaceRoot, commitSha, rfcId) {
|
|
|
114
141
|
commitSha,
|
|
115
142
|
]);
|
|
116
143
|
const slug = rfcId.toLowerCase();
|
|
117
|
-
if (changedFiles.toLowerCase()
|
|
144
|
+
if (new RegExp(`${esc(slug)}(?!\\d)`).test(changedFiles.toLowerCase()))
|
|
118
145
|
return true;
|
|
119
146
|
return false;
|
|
120
147
|
}
|
|
@@ -192,12 +219,319 @@ function mutateFrontmatter(source, status, implementedAt, updatedAt) {
|
|
|
192
219
|
content = content.replace(/^updatedAt: .*$/m, `updatedAt: ${updatedAt}`);
|
|
193
220
|
return content;
|
|
194
221
|
}
|
|
222
|
+
// ─── RFC-1322: --check-criteria ──────────────────────────────────────────────
|
|
223
|
+
/** Extract the inline `(evidence: ...)` annotation text from a criterion line. */
|
|
224
|
+
function extractEvidenceAnnotation(line) {
|
|
225
|
+
// The authoritative annotation is the LAST occurrence — criterion prose may
|
|
226
|
+
// reference the literal `(evidence: ...)` syntax mid-sentence (RFC-1322's own
|
|
227
|
+
// AC-1/AC-2 do), and taking the first match would certify `...` as evidence.
|
|
228
|
+
const matches = [...line.matchAll(/\(evidence:\s*(.+?)\)/g)];
|
|
229
|
+
return matches.at(-1)?.[1]?.trim();
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The AC-N identifier of a checklist line, or a truncated line excerpt when it
|
|
233
|
+
* carries no id — STAMP-CHECK-01 diagnostics and criteriaAutoChecked key on it.
|
|
234
|
+
*/
|
|
235
|
+
function criterionLabelOf(line) {
|
|
236
|
+
const id = line.match(/- \[[ x]\]\s*(AC-\d+):/)?.[1];
|
|
237
|
+
if (id)
|
|
238
|
+
return id;
|
|
239
|
+
const trimmed = line.trim();
|
|
240
|
+
return trimmed.length > 72 ? `${trimmed.slice(0, 69)}…` : trimmed;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Resolvable-annotation contract (RFC-1322 — deliberately stricter than V-37,
|
|
244
|
+
* which validates the `probe:` binding only and lets `file:` annotations fall
|
|
245
|
+
* through unvalidated): `test:<path>`, `file:<path>`, and `<path>:<line>`
|
|
246
|
+
* resolve when the path exists on disk as a FILE; `probe:AC-N` resolves when
|
|
247
|
+
* the evidence envelope carries a probe record bound to AC-N with ok === true.
|
|
248
|
+
* Every other form is unresolvable — the stamp certifies, so it resolves
|
|
249
|
+
* evidence, not just references. An empty or directory target never resolves
|
|
250
|
+
* (an empty `test:`/`file:` joins onto workspaceRoot, whose directory always
|
|
251
|
+
* exists — that would blank-check the criterion the gate exists to protect),
|
|
252
|
+
* and `..` segments that escape the workspace root are refused.
|
|
253
|
+
*/
|
|
254
|
+
export async function resolveCriterionEvidence(annotation, envelope, workspaceRoot, io) {
|
|
255
|
+
const statFile = async (filePath) => {
|
|
256
|
+
if (filePath === "")
|
|
257
|
+
return false;
|
|
258
|
+
const resolved = resolve(workspaceRoot, filePath);
|
|
259
|
+
if (resolved !== workspaceRoot && !resolved.startsWith(workspaceRoot + sep)) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
return (await io.stat(resolved)).isFile;
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
if (annotation.startsWith("probe:")) {
|
|
270
|
+
const refId = annotation.slice("probe:".length).trim();
|
|
271
|
+
return (envelope?.probes ?? []).some((r) => r.probe?.criterion === refId && r.ok === true);
|
|
272
|
+
}
|
|
273
|
+
if (annotation.startsWith("test:") || annotation.startsWith("file:")) {
|
|
274
|
+
// A trailing :line / :line-range rides the annotation, not the path.
|
|
275
|
+
const filePath = annotation
|
|
276
|
+
.slice(annotation.indexOf(":") + 1)
|
|
277
|
+
.trim()
|
|
278
|
+
.replace(/:\d+(?:-\d+)?$/, "");
|
|
279
|
+
return statFile(filePath);
|
|
280
|
+
}
|
|
281
|
+
if (/^[^:]+:\d+(?:-\d+)?$/.test(annotation)) {
|
|
282
|
+
const filePath = annotation.slice(0, annotation.lastIndexOf(":")).trim();
|
|
283
|
+
return statFile(filePath);
|
|
284
|
+
}
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The committed envelope needs an in-process refresh when it is absent,
|
|
289
|
+
* malformed, lacks the hash fields IMP-09 binds, or its hashes diverge from
|
|
290
|
+
* the committed RFC bytes / acceptance list — the same comparisons IMP-09
|
|
291
|
+
* performs, evaluated pre-write so the auto-check pass sees probe: evidence.
|
|
292
|
+
*/
|
|
293
|
+
export function envelopeNeedsRefresh(evidenceCheck, rfcMarkdown, acceptance) {
|
|
294
|
+
if (!evidenceCheck.exists || evidenceCheck.malformed || !evidenceCheck.envelope) {
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
const env = evidenceCheck.envelope;
|
|
298
|
+
if (!env.rfcFileHash || !env.acceptanceHash)
|
|
299
|
+
return true;
|
|
300
|
+
const currentFileHash = byteHashHex(rfcMarkdown);
|
|
301
|
+
const currentAcceptanceHash = byteHashHex(normalizeProbes(Array.isArray(acceptance) ? acceptance : []));
|
|
302
|
+
return env.rfcFileHash !== currentFileHash || env.acceptanceHash !== currentAcceptanceHash;
|
|
303
|
+
}
|
|
304
|
+
/** RFC-1333: committed acceptance reports for an RFC (frontmatter only). */
|
|
305
|
+
export async function readAcceptanceReports(workspaceRoot, rfcId) {
|
|
306
|
+
const dir = join(ACCEPTANCE_REPORTS_DIR, rfcId.toLowerCase());
|
|
307
|
+
const listed = await execGit(workspaceRoot, ["ls-files", "--", dir]);
|
|
308
|
+
const out = [];
|
|
309
|
+
for (const path of listed.split("\n").filter((p) => p.endsWith(".md"))) {
|
|
310
|
+
const text = await execGit(workspaceRoot, ["show", `HEAD:${path}`]);
|
|
311
|
+
// CRLF checkouts and BOMs must not turn a real report into "no evidence".
|
|
312
|
+
const m = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
313
|
+
if (!m)
|
|
314
|
+
continue;
|
|
315
|
+
try {
|
|
316
|
+
const fm = yamlParse(m[1]);
|
|
317
|
+
if (fm && typeof fm === "object")
|
|
318
|
+
out.push({ path, frontmatter: fm });
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
// Unparseable report frontmatter is not evidence.
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return out;
|
|
325
|
+
}
|
|
326
|
+
/** RFC-1333: candidate..HEAD may contain only verifier-trailer or docs-only commits. */
|
|
327
|
+
export async function candidateBoundToHead(workspaceRoot, sha) {
|
|
328
|
+
const isAnc = await new Promise((done) => execFile("git", ["merge-base", "--is-ancestor", sha, "HEAD"], { cwd: workspaceRoot, env: gitEnvForCwd() }, (err) => done(!err)));
|
|
329
|
+
if (!isAnc)
|
|
330
|
+
return false;
|
|
331
|
+
// --first-parent -m: a merge reports its full first-parent diff, so code
|
|
332
|
+
// brought in by a merge cannot pass as an empty "docs-only" commit.
|
|
333
|
+
const log = await execGit(workspaceRoot, [
|
|
334
|
+
"log",
|
|
335
|
+
"--first-parent",
|
|
336
|
+
"-m",
|
|
337
|
+
"--format=%x1e%B%x1f",
|
|
338
|
+
"--name-only",
|
|
339
|
+
`${sha}..HEAD`,
|
|
340
|
+
]);
|
|
341
|
+
const count = Number((await execGit(workspaceRoot, ["rev-list", "--count", `${sha}..HEAD`])) || "0");
|
|
342
|
+
const chunks = log.split("\x1e").filter((c) => c.includes("\x1f"));
|
|
343
|
+
// Fail closed: commits exist but their log could not be read.
|
|
344
|
+
if (count > 0 && chunks.length === 0)
|
|
345
|
+
return false;
|
|
346
|
+
for (const chunk of chunks) {
|
|
347
|
+
const [body = "", files = ""] = chunk.split("\x1f");
|
|
348
|
+
const touched = files
|
|
349
|
+
.split("\n")
|
|
350
|
+
.map((l) => l.trim())
|
|
351
|
+
.filter(Boolean);
|
|
352
|
+
const docsOnly = touched.every((f) => f.startsWith("docs/"));
|
|
353
|
+
if (!docsOnly && !hasVerifierTrailers(body))
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* RFC-IMP-06 (probe-bearing RFCs need a passing envelope) + RFC-IMP-09
|
|
360
|
+
* (committed envelope must hash-match the committed bytes — RFC-1271) as one
|
|
361
|
+
* evaluator. The default path runs it pre-lock; --check-criteria runs it
|
|
362
|
+
* in-lock against the envelope its emit-if-needed pass may have just
|
|
363
|
+
* refreshed. One ruleset, two invocation orders — the paths cannot diverge.
|
|
364
|
+
*/
|
|
365
|
+
async function evaluateStampEvidenceGates(opts) {
|
|
366
|
+
const { evidenceCheck, requiresEvidence, hasProbes, targetId, rfcFilePath, acceptance } = opts;
|
|
367
|
+
const violations = [];
|
|
368
|
+
const warnings = [];
|
|
369
|
+
let evidenceRelPath;
|
|
370
|
+
// ── RFC-IMP-10 / RFC-IMP-11: git-derived origin gates (RFC-1330) ─────────
|
|
371
|
+
// Derived fresh at stamp time (head = HEAD) — the committed envelope's
|
|
372
|
+
// origin records are volatile context and may predate later commits.
|
|
373
|
+
if (hasProbes && String(opts.frontmatter["createdAt"] ?? "") >= RFC_ORIGIN_CUTOFF) {
|
|
374
|
+
const probes = acceptance;
|
|
375
|
+
const origins = await deriveProbeOrigins({
|
|
376
|
+
git: createOriginGit(opts.workspaceRoot),
|
|
377
|
+
rfcRelPath: relative(opts.workspaceRoot, rfcFilePath),
|
|
378
|
+
frontmatter: opts.frontmatter,
|
|
379
|
+
probes,
|
|
380
|
+
});
|
|
381
|
+
const gate = evaluateOriginGates({
|
|
382
|
+
targetId,
|
|
383
|
+
frontmatter: opts.frontmatter,
|
|
384
|
+
body: await opts.io.readFile(rfcFilePath),
|
|
385
|
+
probes,
|
|
386
|
+
origins,
|
|
387
|
+
});
|
|
388
|
+
violations.push(...gate.errors);
|
|
389
|
+
warnings.push(...gate.warnings);
|
|
390
|
+
}
|
|
391
|
+
// RFC-IMP-12 applies to every post-cutoff HIGH-tier RFC, probe-bearing or not.
|
|
392
|
+
// ── RFC-IMP-12: acceptance-verification report (RFC-1333) ─────────────
|
|
393
|
+
const acc = await evaluateAcceptanceVerificationGate({
|
|
394
|
+
targetId,
|
|
395
|
+
frontmatter: opts.frontmatter,
|
|
396
|
+
reports: await readAcceptanceReports(opts.workspaceRoot, targetId),
|
|
397
|
+
isCandidateBound: (sha) => candidateBoundToHead(opts.workspaceRoot, sha),
|
|
398
|
+
waiverReason: opts.waiverReason,
|
|
399
|
+
});
|
|
400
|
+
violations.push(...acc.errors);
|
|
401
|
+
warnings.push(...acc.warnings);
|
|
402
|
+
// ── RFC-IMP-06: probe-bearing post-cutoff RFCs need a passing envelope ────
|
|
403
|
+
if (requiresEvidence) {
|
|
404
|
+
if (!evidenceCheck.exists || evidenceCheck.overall !== "pass") {
|
|
405
|
+
violations.push({
|
|
406
|
+
rule: "RFC-IMP-06",
|
|
407
|
+
message: `RFC ${targetId} declares acceptance probes but evidence file is missing or overall is not "pass" (got "${evidenceCheck.overall}"). Run: site-kernel run rfc.verification.emit --id ${targetId}`,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
evidenceRelPath = join(VERIFICATION_DIR, `${targetId.toLowerCase()}.generated.yaml`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
// ── RFC-IMP-09: stale evidence gate (RFC-1271) ────────────────────────────
|
|
415
|
+
// Hashes are recomputed from the working tree; combined with RFC-IMP-04
|
|
416
|
+
// (the RFC file must be committed-clean to stamp) the compared bytes are
|
|
417
|
+
// effectively the committed bytes — deliberate, keeps the gate honest
|
|
418
|
+
// without a second git read.
|
|
419
|
+
if (evidenceCheck.exists) {
|
|
420
|
+
if (evidenceCheck.malformed || !evidenceCheck.envelope) {
|
|
421
|
+
violations.push({
|
|
422
|
+
rule: "RFC-IMP-09",
|
|
423
|
+
message: `RFC ${targetId} evidence envelope is malformed (unreadable YAML or non-object content). Re-run: site-kernel run rfc.verification.emit --id ${targetId}, then commit the envelope — or delete the stale envelope file.`,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
else if (!hasProbes) {
|
|
427
|
+
violations.push({
|
|
428
|
+
rule: "RFC-IMP-09",
|
|
429
|
+
message: `RFC ${targetId} has a committed evidence envelope but no acceptance: list — probes were deleted after emission, which is a criteria change. Either restore the probes and re-run: site-kernel run rfc.verification.emit --id ${targetId}, then commit the envelope — or delete the stale envelope file (rfc.verification.emit skips probe-less RFCs, so re-emit alone cannot clear this).`,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
const rfcMarkdown = await opts.io.readFile(rfcFilePath);
|
|
434
|
+
const currentFileHash = byteHashHex(rfcMarkdown);
|
|
435
|
+
const currentAcceptanceHash = byteHashHex(normalizeProbes(acceptance));
|
|
436
|
+
const env = evidenceCheck.envelope;
|
|
437
|
+
if (!env.rfcFileHash || !env.acceptanceHash) {
|
|
438
|
+
violations.push({
|
|
439
|
+
rule: "RFC-IMP-09",
|
|
440
|
+
message: `RFC ${targetId} evidence envelope lacks hash fields (pre-RFC-0330 format). Re-run: site-kernel run rfc.verification.emit --id ${targetId}, then commit the envelope.`,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
else if (env.rfcFileHash !== currentFileHash ||
|
|
444
|
+
env.acceptanceHash !== currentAcceptanceHash) {
|
|
445
|
+
const staleFields = [
|
|
446
|
+
env.rfcFileHash !== currentFileHash ? "rfcFileHash" : "",
|
|
447
|
+
env.acceptanceHash !== currentAcceptanceHash ? "acceptanceHash" : "",
|
|
448
|
+
]
|
|
449
|
+
.filter(Boolean)
|
|
450
|
+
.join(" + ");
|
|
451
|
+
violations.push({
|
|
452
|
+
rule: "RFC-IMP-09",
|
|
453
|
+
message: `RFC ${targetId} evidence is stale: ${staleFields} mismatch — the RFC file or its acceptance list changed after emission. Re-run: site-kernel run rfc.verification.emit --id ${targetId}, then commit the envelope.`,
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return { violations, warnings, evidenceRelPath };
|
|
459
|
+
}
|
|
460
|
+
/** In-memory auto-check pass over the unchecked criteria of the committed body. */
|
|
461
|
+
async function autoCheckCriteria(opts) {
|
|
462
|
+
const outcome = {
|
|
463
|
+
flippable: [],
|
|
464
|
+
flippedIds: [],
|
|
465
|
+
failures: [],
|
|
466
|
+
pendingRefresh: [],
|
|
467
|
+
};
|
|
468
|
+
for (const line of opts.uncheckedLines) {
|
|
469
|
+
const label = criterionLabelOf(line);
|
|
470
|
+
const annotation = extractEvidenceAnnotation(line);
|
|
471
|
+
if (!annotation) {
|
|
472
|
+
outcome.failures.push({
|
|
473
|
+
criterion: label,
|
|
474
|
+
annotation: "<no (evidence: ...) annotation>",
|
|
475
|
+
});
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
if (!opts.probesUsable && annotation.startsWith("probe:")) {
|
|
479
|
+
// Store the trimmed line so the post-flip gate can exclude pending
|
|
480
|
+
// criteria from the residual-unchecked check (they flip post-emit in
|
|
481
|
+
// the real run); labels derive via criterionLabelOf when reported.
|
|
482
|
+
outcome.pendingRefresh.push(line);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (await resolveCriterionEvidence(annotation, opts.envelope, opts.workspaceRoot, opts.io)) {
|
|
486
|
+
outcome.flippable.push(line);
|
|
487
|
+
outcome.flippedIds.push(label);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
outcome.failures.push({ criterion: label, annotation });
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return outcome;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Flip `- [ ]` → `- [x]` for the given unchecked criterion lines inside the
|
|
497
|
+
* source's `## Acceptance criteria` section only — fenced code blocks are
|
|
498
|
+
* skipped so a section example inside ``` fences never becomes a flip target
|
|
499
|
+
* (the same guard the section extractors apply), and `## Document readiness`
|
|
500
|
+
* DR-N items are out of scope by construction.
|
|
501
|
+
*/
|
|
502
|
+
export function flipCriteriaInSource(source, uncheckedTargets) {
|
|
503
|
+
const lines = source.split("\n");
|
|
504
|
+
let inFence = false;
|
|
505
|
+
let inSection = false;
|
|
506
|
+
for (let i = 0; i < lines.length; i++) {
|
|
507
|
+
const line = lines[i];
|
|
508
|
+
if (/^```/.test(line)) {
|
|
509
|
+
inFence = !inFence;
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
if (inFence)
|
|
513
|
+
continue;
|
|
514
|
+
if (/^## /.test(line)) {
|
|
515
|
+
inSection = /^## Acceptance criteria\s*$/.test(line);
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
if (inSection && /^\s*- \[ \]/.test(line) && uncheckedTargets.has(line.trim())) {
|
|
519
|
+
lines[i] = line.replace(/- \[ \]/, "- [x]");
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return lines.join("\n");
|
|
523
|
+
}
|
|
195
524
|
// ─── Main handler ────────────────────────────────────────────────────────────
|
|
196
525
|
export async function runRfcImplementStamp(input, context) {
|
|
197
526
|
const io = resolveIo(context.io);
|
|
198
527
|
const { workspaceRoot, logger, outputFormat, dryRun } = context;
|
|
199
528
|
const rfcDirPath = join(workspaceRoot, RFC_DIR);
|
|
200
|
-
|
|
529
|
+
// RFC-1321: canonicalize the governance id at parse — every stored surface
|
|
530
|
+
// (result rfcId, post-stamp re-emit flags, metrics ids) carries the
|
|
531
|
+
// canonical uppercase spelling regardless of flag casing. A non-string flag
|
|
532
|
+
// (repeated --id forms an array) degrades to absent rather than crashing.
|
|
533
|
+
const rawId = input.flags["id"];
|
|
534
|
+
const targetId = typeof rawId === "string" ? rawId.toUpperCase() : undefined;
|
|
201
535
|
let implementationCommit = input.flags["implementation-commit"];
|
|
202
536
|
// ── Flag validation ───────────────────────────────────────────────────────
|
|
203
537
|
if (!targetId) {
|
|
@@ -205,6 +539,10 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
205
539
|
}
|
|
206
540
|
const violations = [];
|
|
207
541
|
const isDryRun = dryRun || input.flags["dry-run"] === true;
|
|
542
|
+
// RFC-1322: the stamp performs the checkbox flips itself — but only for
|
|
543
|
+
// criteria whose (evidence: ...) annotation resolves — and refreshes a
|
|
544
|
+
// missing/stale envelope in-process before the gates evaluate it.
|
|
545
|
+
const checkCriteria = input.flags["check-criteria"] === true;
|
|
208
546
|
// ── Find the target RFC ───────────────────────────────────────────────────
|
|
209
547
|
const files = await listRfcFiles(rfcDirPath);
|
|
210
548
|
const targetFile = files.find((f) => rfcFileMatchesId(f, targetId));
|
|
@@ -241,15 +579,51 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
241
579
|
});
|
|
242
580
|
return stampFailResult(violations, isDryRun, outputFormat, logger);
|
|
243
581
|
}
|
|
582
|
+
// ── RFC-1306: --sync runs the evidence-resync chain before stamping ────────
|
|
583
|
+
// Positioned after the target RFC resolves (so --id is real) and before any
|
|
584
|
+
// criteria/commit/evidence read, so the IMP-06/09 gates see fresh artifacts.
|
|
585
|
+
// The chain is delegated by name through the kernel host's invoke port — the
|
|
586
|
+
// standalone forge CLI has no host and fails closed like rfc.evidence.sync.
|
|
587
|
+
if (input.flags["sync"] === true) {
|
|
588
|
+
if (!context.invoke) {
|
|
589
|
+
violations.push({
|
|
590
|
+
rule: "EVIDENCE-SYNC-01",
|
|
591
|
+
message: "--sync requires the werkstatt kernel host (context.invoke is absent). Run via `pnpm exec werkstatt run rfc.implement.stamp --id <id> --sync`, or resync manually.",
|
|
592
|
+
});
|
|
593
|
+
return stampFailResult(violations, isDryRun, outputFormat, logger);
|
|
594
|
+
}
|
|
595
|
+
let syncReport;
|
|
596
|
+
try {
|
|
597
|
+
syncReport = await context.invoke("rfc.evidence.sync", { id: targetId });
|
|
598
|
+
}
|
|
599
|
+
catch (err) {
|
|
600
|
+
violations.push({
|
|
601
|
+
rule: "EVIDENCE-SYNC-02",
|
|
602
|
+
message: `rfc.evidence.sync threw before stamping: ${err instanceof Error ? err.message : String(err)}. Resolve the failing step and re-run the stamp.`,
|
|
603
|
+
});
|
|
604
|
+
return stampFailResult(violations, isDryRun, outputFormat, logger);
|
|
605
|
+
}
|
|
606
|
+
if (syncReport.exitCode !== 0) {
|
|
607
|
+
violations.push({
|
|
608
|
+
rule: "EVIDENCE-SYNC-02",
|
|
609
|
+
message: `rfc.evidence.sync failed before stamping${syncReport.summary ? `: ${syncReport.summary}` : ""}. Resolve the failing step and re-run the stamp.`,
|
|
610
|
+
});
|
|
611
|
+
return stampFailResult(violations, isDryRun, outputFormat, logger);
|
|
612
|
+
}
|
|
613
|
+
logger.info(`[rfc.implement.stamp] --sync: ${syncReport.summary ?? "resync chain completed"}`);
|
|
614
|
+
}
|
|
244
615
|
// ── RFC-IMP-02: criterion checks (V-26/V-27 semantics) ────────────────────
|
|
616
|
+
// Under --check-criteria both branches defer: unchecked lines become flip
|
|
617
|
+
// candidates for the auto-check pass, and checkedWithoutEvidence re-runs on
|
|
618
|
+
// the post-flip body — a flipped line always keeps its annotation.
|
|
245
619
|
const criteriaEval = evaluateAcceptanceCriteria(body);
|
|
246
|
-
if (criteriaEval.totalUnchecked > 0) {
|
|
620
|
+
if (!checkCriteria && criteriaEval.totalUnchecked > 0) {
|
|
247
621
|
violations.push({
|
|
248
622
|
rule: "RFC-IMP-02",
|
|
249
623
|
message: `${criteriaEval.totalUnchecked} acceptance criteria are unchecked. All criteria must be checked before stamping: ${criteriaEval.uncheckedLines.join("; ")}`,
|
|
250
624
|
});
|
|
251
625
|
}
|
|
252
|
-
if (criteriaEval.checkedWithoutEvidence.length > 0) {
|
|
626
|
+
if (!checkCriteria && criteriaEval.checkedWithoutEvidence.length > 0) {
|
|
253
627
|
violations.push({
|
|
254
628
|
rule: "RFC-IMP-02",
|
|
255
629
|
message: `${criteriaEval.checkedWithoutEvidence.length} checked criteria lack inline (evidence: ...) annotation: ${criteriaEval.checkedWithoutEvidence.join("; ")}`,
|
|
@@ -279,10 +653,14 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
279
653
|
}
|
|
280
654
|
}
|
|
281
655
|
// ── RFC-0756: auto-detect implementation commit when --implementation-commit is omitted ──
|
|
656
|
+
// RFC-1310 STAMP-GOV-01: auto-detect candidates join the provenance scan
|
|
657
|
+
// set — a trailer on any implementation-shaped commit counts.
|
|
658
|
+
const provenanceCandidateShas = [];
|
|
282
659
|
if (!implementationCommit) {
|
|
283
660
|
const detected = await autoDetectImplementationCommit(workspaceRoot, targetId);
|
|
284
661
|
if ("sha" in detected) {
|
|
285
662
|
implementationCommit = detected.sha;
|
|
663
|
+
provenanceCandidateShas.push(detected.sha);
|
|
286
664
|
}
|
|
287
665
|
else if ("none" in detected) {
|
|
288
666
|
violations.push({
|
|
@@ -294,6 +672,7 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
294
672
|
// Auto-resolve when exactly one candidate looks like an implementation
|
|
295
673
|
// commit — a multi-commit RFC pipeline (audit → plan → implement → docs →
|
|
296
674
|
// review) references the id at every step, but only one step implements.
|
|
675
|
+
provenanceCandidateShas.push(...detected.multiple.map((c) => c.sha));
|
|
297
676
|
const implCandidates = detected.multiple.filter((c) => IMPLEMENTATION_SUBJECT_RE.test(c.message));
|
|
298
677
|
if (implCandidates.length === 1) {
|
|
299
678
|
implementationCommit = implCandidates[0].sha;
|
|
@@ -345,6 +724,28 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
345
724
|
message: `Implementation commit ${implementationCommit} does not reference ${targetId} in its message or changed files.`,
|
|
346
725
|
});
|
|
347
726
|
}
|
|
727
|
+
else {
|
|
728
|
+
// ── RFC-1310 STAMP-GOV-01: commit-time governance provenance ──────
|
|
729
|
+
// A subject mention is not provenance — the implementation commit
|
|
730
|
+
// (or an auto-detected sibling candidate) must carry the X-RFC
|
|
731
|
+
// trailer or an injected CHANGE_SUMMARY item, else the stamp would
|
|
732
|
+
// certify a provenance-broken implementation (DNA-59).
|
|
733
|
+
const scanShas = [...new Set([implementationCommit, ...provenanceCandidateShas])];
|
|
734
|
+
logger.info(`[rfc.implement.stamp] STAMP-GOV-01 scanning ${scanShas.length} commit(s): ${scanShas.join(", ")}`);
|
|
735
|
+
let provenance = false;
|
|
736
|
+
for (const sha of scanShas) {
|
|
737
|
+
if (await commitCarriesGovernanceProvenance(workspaceRoot, sha, targetId)) {
|
|
738
|
+
provenance = true;
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if (!provenance) {
|
|
743
|
+
violations.push({
|
|
744
|
+
rule: "STAMP-GOV-01",
|
|
745
|
+
message: `Implementation commit(s) for ${targetId} carry no governance provenance (no X-RFC: ${targetId} trailer, no injected CHANGE_SUMMARY item) — scanned: ${scanShas.join(", ")}. Retro-fix: hand-edit CHANGE_SUMMARY <item>${targetId}: …</item> entries into the touched files' headers in the worktree, then land a follow-up ecosystem.commit --rfc ${targetId} --message "docs(${targetId.toLowerCase()}): retrofit governance provenance" and re-stamp.`,
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}
|
|
348
749
|
}
|
|
349
750
|
}
|
|
350
751
|
// ── RFC-IMP-06: probe-bearing RFCs require passing evidence ───────────────
|
|
@@ -354,66 +755,38 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
354
755
|
const requiresEvidence = createdAtStr >= RFC_METADATA_CUTOFF && hasProbes;
|
|
355
756
|
const rfcFilePath = join(rfcDirPath, targetFile);
|
|
356
757
|
let evidenceRelPath;
|
|
758
|
+
// RFC-1330/1333: non-blocking stamp findings (waived RFC-IMP-12: missing report or isolation).
|
|
759
|
+
const stampWarnings = [];
|
|
760
|
+
const waiverFlag = input.flags["waive-independent-verification"];
|
|
761
|
+
const waiverReason = typeof waiverFlag === "string" && waiverFlag.trim() ? waiverFlag.trim() : undefined;
|
|
357
762
|
// RFC-1271: the envelope is fetched unconditionally — a committed envelope
|
|
358
763
|
// must also be evaluated when hasProbes is now false, because probe
|
|
359
764
|
// deletion IS a criteria change and would otherwise slip past
|
|
360
765
|
// requiresEvidence entirely (RFC-IMP-08 exempts policy/deprecation kinds).
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
else if (!hasProbes) {
|
|
387
|
-
violations.push({
|
|
388
|
-
rule: "RFC-IMP-09",
|
|
389
|
-
message: `RFC ${targetId} has a committed evidence envelope but no acceptance: list — probes were deleted after emission, which is a criteria change. Either restore the probes and re-run: site-kernel run rfc.verification.emit --id ${targetId}, then commit the envelope — or delete the stale envelope file (rfc.verification.emit skips probe-less RFCs, so re-emit alone cannot clear this).`,
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
const rfcMarkdown = await io.readFile(rfcFilePath);
|
|
394
|
-
const currentFileHash = byteHashHex(rfcMarkdown);
|
|
395
|
-
const currentAcceptanceHash = byteHashHex(normalizeProbes(acceptance));
|
|
396
|
-
const env = evidenceCheck.envelope;
|
|
397
|
-
if (!env.rfcFileHash || !env.acceptanceHash) {
|
|
398
|
-
violations.push({
|
|
399
|
-
rule: "RFC-IMP-09",
|
|
400
|
-
message: `RFC ${targetId} evidence envelope lacks hash fields (pre-RFC-0330 format). Re-run: site-kernel run rfc.verification.emit --id ${targetId}, then commit the envelope.`,
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
else if (env.rfcFileHash !== currentFileHash ||
|
|
404
|
-
env.acceptanceHash !== currentAcceptanceHash) {
|
|
405
|
-
const staleFields = [
|
|
406
|
-
env.rfcFileHash !== currentFileHash ? "rfcFileHash" : "",
|
|
407
|
-
env.acceptanceHash !== currentAcceptanceHash ? "acceptanceHash" : "",
|
|
408
|
-
]
|
|
409
|
-
.filter(Boolean)
|
|
410
|
-
.join(" + ");
|
|
411
|
-
violations.push({
|
|
412
|
-
rule: "RFC-IMP-09",
|
|
413
|
-
message: `RFC ${targetId} evidence is stale: ${staleFields} mismatch — the RFC file or its acceptance list changed after emission. Re-run: site-kernel run rfc.verification.emit --id ${targetId}, then commit the envelope.`,
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}
|
|
766
|
+
// let — --check-criteria re-reads the envelope after the emit-if-needed pass.
|
|
767
|
+
let evidenceCheck = await checkExistingEvidence(workspaceRoot, targetId);
|
|
768
|
+
// Default path: IMP-06 + IMP-09 fire pre-lock via the shared evaluator —
|
|
769
|
+
// under --check-criteria the same ruleset runs inside the lock, after the
|
|
770
|
+
// emit-if-needed pass may have refreshed the envelope.
|
|
771
|
+
if (!checkCriteria) {
|
|
772
|
+
const gates = await evaluateStampEvidenceGates({
|
|
773
|
+
evidenceCheck,
|
|
774
|
+
requiresEvidence,
|
|
775
|
+
hasProbes,
|
|
776
|
+
targetId,
|
|
777
|
+
rfcFilePath,
|
|
778
|
+
acceptance,
|
|
779
|
+
io,
|
|
780
|
+
frontmatter: fm,
|
|
781
|
+
workspaceRoot,
|
|
782
|
+
waiverReason,
|
|
783
|
+
});
|
|
784
|
+
violations.push(...gates.violations);
|
|
785
|
+
stampWarnings.push(...gates.warnings);
|
|
786
|
+
for (const w of gates.warnings)
|
|
787
|
+
logger.warn(`${w.rule}: ${w.message}`);
|
|
788
|
+
if (gates.evidenceRelPath)
|
|
789
|
+
evidenceRelPath = gates.evidenceRelPath;
|
|
417
790
|
}
|
|
418
791
|
// ── RFC-IMP-08: minimum-one-probe gate (RFC-0997) ─────────────────────────
|
|
419
792
|
// Post-cutoff architecture/contract/command RFCs must declare at least one
|
|
@@ -431,6 +804,9 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
431
804
|
return stampFailResult(violations, isDryRun, outputFormat, logger);
|
|
432
805
|
}
|
|
433
806
|
// ── RFC-IMP-05: acquire RFC-specific exclusive lock ───────────────────────
|
|
807
|
+
// Under --check-criteria the lock must precede the FIRST write — which is
|
|
808
|
+
// the emit-if-needed envelope refresh, not the stamp mutation — so all
|
|
809
|
+
// envelope-independent gates above abort before this point.
|
|
434
810
|
const { acquired, lockPath } = await acquireRfcLock(workspaceRoot, targetId);
|
|
435
811
|
if (!acquired) {
|
|
436
812
|
violations.push({
|
|
@@ -442,14 +818,137 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
442
818
|
try {
|
|
443
819
|
// ── Atomic mutation ──────────────────────────────────────────────────────
|
|
444
820
|
const rfcSource = await io.readFile(rfcFilePath);
|
|
821
|
+
// RFC-1322: the mutation-bound source — under --check-criteria it carries
|
|
822
|
+
// the auto-check flips; without the flag it is the committed file text.
|
|
823
|
+
let stampSource = rfcSource;
|
|
824
|
+
let criteriaAutoChecked;
|
|
825
|
+
let criteriaPendingRefresh = [];
|
|
826
|
+
let evidenceWouldRefresh = false;
|
|
827
|
+
let effectiveCriteriaChecked = criteriaEval.totalChecked;
|
|
828
|
+
if (checkCriteria) {
|
|
829
|
+
// Emit-if-needed (RFC-1322 order step 4): a missing, malformed, or
|
|
830
|
+
// hash-stale envelope is refreshed in-process through the same direct
|
|
831
|
+
// runRfcVerificationEmit call the post-stamp re-emit uses — on the
|
|
832
|
+
// committed bytes, so IMP-09 keeps evaluating a real file state. The
|
|
833
|
+
// freshness precheck (RFC-1320) gates this emit exactly as a manual one.
|
|
834
|
+
const needsEmit = hasProbes && envelopeNeedsRefresh(evidenceCheck, rfcSource, acceptance);
|
|
835
|
+
evidenceWouldRefresh = needsEmit;
|
|
836
|
+
if (needsEmit && !isDryRun) {
|
|
837
|
+
let emitOk = false;
|
|
838
|
+
let emitSummary = "";
|
|
839
|
+
try {
|
|
840
|
+
const emitResult = await runRfcVerificationEmit({ argv: [], flags: { id: targetId } }, context);
|
|
841
|
+
emitOk = emitResult.exitCode === 0;
|
|
842
|
+
emitSummary = emitResult.summary ?? "";
|
|
843
|
+
}
|
|
844
|
+
catch (emitErr) {
|
|
845
|
+
violations.push({
|
|
846
|
+
rule: "EVIDENCE-SYNC-02",
|
|
847
|
+
message: `pre-stamp evidence emit for ${targetId} threw: ${emitErr instanceof Error ? emitErr.message : String(emitErr)}. Resolve the failing step and re-run the stamp.`,
|
|
848
|
+
});
|
|
849
|
+
return stampFailResult(violations, isDryRun, outputFormat, logger);
|
|
850
|
+
}
|
|
851
|
+
if (!emitOk) {
|
|
852
|
+
violations.push({
|
|
853
|
+
rule: "EVIDENCE-SYNC-02",
|
|
854
|
+
message: `pre-stamp evidence emit for ${targetId} failed${emitSummary ? `: ${emitSummary}` : ""}. Resolve the failing step and re-run the stamp.`,
|
|
855
|
+
});
|
|
856
|
+
return stampFailResult(violations, isDryRun, outputFormat, logger);
|
|
857
|
+
}
|
|
858
|
+
logger.info(`[rfc.implement.stamp] --check-criteria: refreshed stale/missing envelope`);
|
|
859
|
+
evidenceCheck = await checkExistingEvidence(workspaceRoot, targetId);
|
|
860
|
+
}
|
|
861
|
+
// Auto-check pass (RFC-1322 order step 5, in-memory): each unchecked
|
|
862
|
+
// criterion resolves its (evidence: ...) annotation; unresolvable ones
|
|
863
|
+
// abort before any RFC mutation. In dry-run with a pending refresh the
|
|
864
|
+
// probe: annotations are not yet resolvable — pending, not failures.
|
|
865
|
+
const auto = await autoCheckCriteria({
|
|
866
|
+
uncheckedLines: criteriaEval.uncheckedLines,
|
|
867
|
+
envelope: evidenceCheck.envelope,
|
|
868
|
+
probesUsable: !(isDryRun && needsEmit),
|
|
869
|
+
workspaceRoot,
|
|
870
|
+
io,
|
|
871
|
+
});
|
|
872
|
+
criteriaAutoChecked = auto.flippedIds;
|
|
873
|
+
criteriaPendingRefresh = auto.pendingRefresh.map(criterionLabelOf);
|
|
874
|
+
if (auto.failures.length > 0) {
|
|
875
|
+
violations.push({
|
|
876
|
+
rule: "STAMP-CHECK-01",
|
|
877
|
+
message: `${auto.failures.length} unchecked acceptance criteria lack resolvable (evidence: ...) annotations — ` +
|
|
878
|
+
`supply a resolvable reference (test:<path>, file:<path>, <path>:<line>, or probe:AC-N bound to a passing envelope probe): ` +
|
|
879
|
+
auto.failures.map((f) => `${f.criterion} [${f.annotation}]`).join("; "),
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
if (auto.flippable.length > 0) {
|
|
883
|
+
stampSource = flipCriteriaInSource(rfcSource, new Set(auto.flippable));
|
|
884
|
+
}
|
|
885
|
+
// Post-flip criteria gates on the mutation-bound bytes (step 6): a
|
|
886
|
+
// still-unchecked line means the flip failed to land — fail closed
|
|
887
|
+
// rather than write a partially checked document; checked lines must
|
|
888
|
+
// keep their annotation (a flipped line always does). Dry-run pending
|
|
889
|
+
// criteria (probe: awaiting the skipped emit) are excluded — the real
|
|
890
|
+
// run resolves them against the refreshed envelope.
|
|
891
|
+
const pendingSet = new Set(auto.pendingRefresh);
|
|
892
|
+
const postFlipEval = evaluateAcceptanceCriteria(stampSource);
|
|
893
|
+
const residualUnchecked = postFlipEval.uncheckedLines.filter((l) => !pendingSet.has(l));
|
|
894
|
+
if (residualUnchecked.length > 0) {
|
|
895
|
+
violations.push({
|
|
896
|
+
rule: "RFC-IMP-02",
|
|
897
|
+
message: `${residualUnchecked.length} acceptance criteria remain unchecked after the --check-criteria pass: ${residualUnchecked.join("; ")}`,
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
if (postFlipEval.checkedWithoutEvidence.length > 0) {
|
|
901
|
+
violations.push({
|
|
902
|
+
rule: "RFC-IMP-02",
|
|
903
|
+
message: `${postFlipEval.checkedWithoutEvidence.length} checked criteria lack inline (evidence: ...) annotation: ${postFlipEval.checkedWithoutEvidence.join("; ")}`,
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
effectiveCriteriaChecked = postFlipEval.totalChecked;
|
|
907
|
+
// IMP-06 + IMP-09 against the (possibly just-refreshed) envelope via
|
|
908
|
+
// the shared evaluator — skipped in dry-run when a refresh would run,
|
|
909
|
+
// since committed-bytes verdicts are not predictive of the post-emit
|
|
910
|
+
// state the real stamp evaluates.
|
|
911
|
+
if (!(isDryRun && needsEmit)) {
|
|
912
|
+
const gates = await evaluateStampEvidenceGates({
|
|
913
|
+
evidenceCheck,
|
|
914
|
+
requiresEvidence,
|
|
915
|
+
hasProbes,
|
|
916
|
+
targetId,
|
|
917
|
+
rfcFilePath,
|
|
918
|
+
acceptance,
|
|
919
|
+
io,
|
|
920
|
+
frontmatter: fm,
|
|
921
|
+
workspaceRoot,
|
|
922
|
+
waiverReason,
|
|
923
|
+
});
|
|
924
|
+
violations.push(...gates.violations);
|
|
925
|
+
stampWarnings.push(...gates.warnings);
|
|
926
|
+
for (const w of gates.warnings)
|
|
927
|
+
logger.warn(`${w.rule}: ${w.message}`);
|
|
928
|
+
if (gates.evidenceRelPath)
|
|
929
|
+
evidenceRelPath = gates.evidenceRelPath;
|
|
930
|
+
}
|
|
931
|
+
if (violations.length > 0) {
|
|
932
|
+
return stampFailResult(violations, isDryRun, outputFormat, logger);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
445
935
|
const today = toIsoDate(new Date());
|
|
446
936
|
const stampedAt = new Date().toISOString();
|
|
447
|
-
const mutatedSource = mutateFrontmatter(
|
|
937
|
+
const mutatedSource = mutateFrontmatter(stampSource, "implemented", today, today);
|
|
448
938
|
if (isDryRun) {
|
|
449
939
|
if (outputFormat === "pretty") {
|
|
450
940
|
logger.success(`[dry-run] ${targetId} would be stamped as implemented`);
|
|
451
941
|
logger.info(` implementation commit: ${implementationCommit}`);
|
|
452
|
-
logger.info(` criteria checked: ${
|
|
942
|
+
logger.info(` criteria checked: ${effectiveCriteriaChecked}`);
|
|
943
|
+
if (criteriaAutoChecked && criteriaAutoChecked.length > 0) {
|
|
944
|
+
logger.info(` criteria auto-checked: ${criteriaAutoChecked.join(", ")}`);
|
|
945
|
+
}
|
|
946
|
+
if (criteriaPendingRefresh.length > 0) {
|
|
947
|
+
logger.info(` criteria pending envelope refresh: ${criteriaPendingRefresh.join(", ")}`);
|
|
948
|
+
}
|
|
949
|
+
if (evidenceWouldRefresh) {
|
|
950
|
+
logger.info(` evidence envelope would be refreshed (missing or stale)`);
|
|
951
|
+
}
|
|
453
952
|
if (evidenceRelPath) {
|
|
454
953
|
logger.info(` evidence: ${evidenceRelPath}`);
|
|
455
954
|
}
|
|
@@ -458,11 +957,19 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
458
957
|
data: {
|
|
459
958
|
command: "rfc.implement.stamp",
|
|
460
959
|
status: "pass",
|
|
960
|
+
...(stampWarnings.length > 0 ? { warnings: stampWarnings } : {}),
|
|
461
961
|
data: {
|
|
462
962
|
rfcId: targetId,
|
|
463
963
|
implementationCommit: implementationCommit,
|
|
464
964
|
stampedAt,
|
|
465
|
-
criteriaChecked:
|
|
965
|
+
criteriaChecked: effectiveCriteriaChecked,
|
|
966
|
+
...(checkCriteria
|
|
967
|
+
? {
|
|
968
|
+
criteriaAutoChecked: criteriaAutoChecked ?? [],
|
|
969
|
+
criteriaPendingRefresh,
|
|
970
|
+
evidenceWouldRefresh,
|
|
971
|
+
}
|
|
972
|
+
: {}),
|
|
466
973
|
...(evidenceRelPath ? { evidencePath: evidenceRelPath } : {}),
|
|
467
974
|
},
|
|
468
975
|
violations: [],
|
|
@@ -471,7 +978,8 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
471
978
|
summary: `rfc.implement.stamp: dry-run — ${targetId} would be stamped`,
|
|
472
979
|
};
|
|
473
980
|
}
|
|
474
|
-
// Write the mutated RFC file atomically
|
|
981
|
+
// Write the mutated RFC file atomically — under --check-criteria this
|
|
982
|
+
// single write carries the checkbox flips AND the frontmatter mutation.
|
|
475
983
|
await writeFileAtomic(rfcFilePath, mutatedSource);
|
|
476
984
|
// ── RFC-1053: Generate per-RFC metrics (non-fatal, guarded by !isDryRun) ─
|
|
477
985
|
let metricsPath;
|
|
@@ -509,7 +1017,10 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
509
1017
|
if (outputFormat === "pretty") {
|
|
510
1018
|
logger.success(`${targetId} stamped as implemented`);
|
|
511
1019
|
logger.info(` implementation commit: ${implementationCommit}`);
|
|
512
|
-
logger.info(` criteria checked: ${
|
|
1020
|
+
logger.info(` criteria checked: ${effectiveCriteriaChecked}`);
|
|
1021
|
+
if (criteriaAutoChecked && criteriaAutoChecked.length > 0) {
|
|
1022
|
+
logger.info(` criteria auto-checked: ${criteriaAutoChecked.join(", ")}`);
|
|
1023
|
+
}
|
|
513
1024
|
if (evidenceRelPath) {
|
|
514
1025
|
logger.info(` evidence: ${evidenceRelPath}`);
|
|
515
1026
|
}
|
|
@@ -519,11 +1030,13 @@ export async function runRfcImplementStamp(input, context) {
|
|
|
519
1030
|
data: {
|
|
520
1031
|
command: "rfc.implement.stamp",
|
|
521
1032
|
status: "pass",
|
|
1033
|
+
...(stampWarnings.length > 0 ? { warnings: stampWarnings } : {}),
|
|
522
1034
|
data: {
|
|
523
1035
|
rfcId: targetId,
|
|
524
1036
|
implementationCommit: implementationCommit,
|
|
525
1037
|
stampedAt,
|
|
526
|
-
criteriaChecked:
|
|
1038
|
+
criteriaChecked: effectiveCriteriaChecked,
|
|
1039
|
+
...(checkCriteria ? { criteriaAutoChecked: criteriaAutoChecked ?? [] } : {}),
|
|
527
1040
|
...(evidenceRelPath ? { evidencePath: evidenceRelPath } : {}),
|
|
528
1041
|
...(hasProbes ? { evidenceReEmitted } : {}),
|
|
529
1042
|
...(metricsPath ? { metricsPath } : {}),
|