@warpgogol/forge 6.3.6 → 8.0.2
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 +47 -0
- package/README.md +2 -1
- package/bin/cli.js +6 -12
- package/bin/resolve-entry.js +24 -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 +66 -2
- 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 +645 -47
- 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 +71 -10
- 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 +99 -10
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +112 -14
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +27 -10
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/rfc/verification-evidence.d.ts +25 -0
- package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
- package/dist/os/rfc/verification-evidence.js +244 -13
- 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/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/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/skill-schema.d.ts +2 -0
- package/dist/src/skill-schema.d.ts.map +1 -1
- package/dist/src/skill-schema.js +9 -1
- package/dist/src/skill-schema.js.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/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 +136 -0
- package/os/rfc/acceptance.ts +71 -2
- 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 +285 -0
- package/os/rfc/handlers/implement-stamp.ts +783 -55
- 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 +56 -0
- package/os/rfc/handlers/validate-rules.ts +101 -10
- package/os/rfc/handlers/validate.test.ts +4 -3
- package/os/rfc/reachable-symbol.ts +441 -0
- package/os/rfc/rfc-0000-template.md +21 -1
- 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 +106 -10
- package/os/rfc/types.ts +151 -14
- package/os/rfc/verification-emit-check.test.ts +215 -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 +301 -13
- package/os/rfc/verification-normalize.test.ts +75 -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/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 +1 -1
- package/skills/_shared/agent-operating-model.md +83 -0
- 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/SKILL.md +6 -3
- 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/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/templates/behavioral-layer-core.md +8 -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/skill-schema.ts +9 -1
- 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/fixtures/agents-generate-business-before.txt +8 -0
- 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/scaffold-project.test.ts +3 -0
- package/src/tests/session-handlers.test.ts +14 -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 +53 -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
|
@@ -6,16 +6,14 @@
|
|
|
6
6
|
</non-goals>
|
|
7
7
|
</MODULE_CONTRACT>
|
|
8
8
|
<CHANGE_SUMMARY>
|
|
9
|
-
<item>RFC-0795: add V-33 dependsOn referential integrity/self-dependency/rejected-dependency and V-34 batch slug format rules.</item>
|
|
10
|
-
<item>RFC-0997: add V-35 probe→criterion referential integrity, V-36 criterion identifier discipline, V-37 evidence mechanism validity, and computeProbeCoverage for non-blocking coverage reports.</item>
|
|
11
|
-
<item>RFC-1006: add V-38 document readiness completeness, V-39 non-atomic criterion, V-40 unbounded quantity, V-41 weasel verb, V-42 criterion versioning annotation format. Add evaluateDocumentReadiness and extend evaluateAcceptanceCriteria with supersession tracking and reject-checklist scans.</item>
|
|
12
|
-
<item>RFC-1097: step 6 — compass.migrate codemod run
|
|
13
|
-
|
|
14
|
-
Mechanical v1 to v2 header migration across the workspace: 942 files rewritten — CHANGE_SUMMARY windows collapsed into history, forbidden v1 blocks stripped, KEY_DECISIONS seeded from @ai-invariant comments (5 files) or TODO placeholders (103 files), blocks reordered to canonical order.</item>
|
|
15
9
|
<item>RFC-1097: sweep — packages/forge + services clean
|
|
16
10
|
|
|
17
11
|
Sweep batch 2: real KEY_DECISIONS on 10 files, expanded purposes (CONTRACT-02/PURPOSE-02), headers on mission/index + gen-upstreams, sanitizeItemText in summary.record (literal Compass tags corrupted history), excludedPaths for wrangler types, test-fixtures testPattern. forge+services now 0 diagnostics under --mode error.</item>
|
|
18
|
-
<
|
|
12
|
+
<item>RFC-1271: V-43 verificationTier enum check; V-23 archive exemption (isArchived paths skip evidence-presence — archive-freeze precedent).</item>
|
|
13
|
+
<item>RFC-1322: fo-review fix pass — V-37 annotation extraction takes the LAST (evidence: ...) occurrence, matching the stamp resolver (prose mentions no longer shadow the real annotation).</item>
|
|
14
|
+
<item>RFC-1330: V-44 presence-only behavioral criteria; shared listBehavioralCriteria.</item>
|
|
15
|
+
<item>RFC-1334: step 4 — reachable acceptance probe (symbol and command modes) and V-45</item>
|
|
16
|
+
<history>RFC-0303, RFC-0722, RFC-0755, RFC-0795, RFC-0997, RFC-1006, RFC-1097</history>
|
|
19
17
|
</CHANGE_SUMMARY>
|
|
20
18
|
*/
|
|
21
19
|
|
|
@@ -28,20 +26,24 @@ import { parse as yamlParse } from "yaml";
|
|
|
28
26
|
import { validateAcceptanceShape } from "../acceptance.ts";
|
|
29
27
|
import type { ParsedRfc } from "../frontmatter-io.ts";
|
|
30
28
|
import type { ReadAndParseRfcResult } from "../frontmatter-io.ts";
|
|
31
|
-
import type { RfcStatus, RfcKind, RfcScope, Marker } from "../types.ts";
|
|
29
|
+
import type { RfcStatus, RfcKind, RfcScope, RfcVerificationTier, Marker } from "../types.ts";
|
|
32
30
|
import {
|
|
33
31
|
RFC_DIR,
|
|
34
32
|
RFC_ID_PATTERN,
|
|
35
33
|
RFC_STATUSES,
|
|
36
34
|
RFC_KINDS,
|
|
37
35
|
RFC_SCOPES,
|
|
36
|
+
RFC_VERIFICATION_TIERS,
|
|
38
37
|
RFC_FULL_REQUIRED_SECTIONS,
|
|
39
38
|
RFC_METADATA_CUTOFF,
|
|
40
39
|
RFC_VERSION_BUMP_CUTOFF,
|
|
41
40
|
RFC_PROBE_BINDING_CUTOFF,
|
|
42
41
|
RFC_CRITERIA_CONTENT_CUTOFF,
|
|
42
|
+
RFC_ORIGIN_CUTOFF,
|
|
43
|
+
RFC_REACHABLE_CUTOFF,
|
|
43
44
|
} from "../types.ts";
|
|
44
45
|
import type { ProbeCoverageReport, AcceptanceProbe } from "../types.ts";
|
|
46
|
+
import { isPresenceProbe } from "../verification-origin.ts";
|
|
45
47
|
import { DNA_DOCS, AP_DOCS } from "./shared.ts";
|
|
46
48
|
|
|
47
49
|
// Ambient default for helper fns without a context param — handlers override
|
|
@@ -95,6 +97,35 @@ export interface DocumentReadinessEvaluation {
|
|
|
95
97
|
linesWithoutId: string[];
|
|
96
98
|
}
|
|
97
99
|
|
|
100
|
+
// ─── RFC-1330: V-44 presence-only behavioral criteria ───────────────────────
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Behavioral criteria (EARS event-driven `WHEN …` or failure-path `IF …`
|
|
104
|
+
* forms) whose bound probes are all presence probes. A criterion with no
|
|
105
|
+
* bound probe is not reported here — probe coverage is V-35's concern.
|
|
106
|
+
* Pure function — no I/O, no side effects.
|
|
107
|
+
*/
|
|
108
|
+
export function listBehavioralCriteria(body: string): string[] {
|
|
109
|
+
const section = extractAcceptanceCriteriaSection(stripFencedCodeBlocks(body));
|
|
110
|
+
if (!section) return [];
|
|
111
|
+
const ids: string[] = [];
|
|
112
|
+
for (const line of section.split("\n")) {
|
|
113
|
+
const match = /^\s*- \[[ xX]\]\s*(AC-\d+):\s*(.*)$/.exec(line);
|
|
114
|
+
if (match && /^(WHEN|IF)\b/.test((match[2] ?? "").trim())) ids.push(match[1]!);
|
|
115
|
+
}
|
|
116
|
+
return ids;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function findPresenceOnlyBehavioralCriteria(
|
|
120
|
+
body: string,
|
|
121
|
+
probes: AcceptanceProbe[],
|
|
122
|
+
): string[] {
|
|
123
|
+
return listBehavioralCriteria(body).filter((id) => {
|
|
124
|
+
const bound = probes.filter((p) => p.criterion === id);
|
|
125
|
+
return bound.length > 0 && bound.every(isPresenceProbe);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
98
129
|
// ─── RFC-1006: reject checklist constants ──────────────────────────────────
|
|
99
130
|
|
|
100
131
|
const UNBOUNDED_QUANTITY_TRIGGERS = [
|
|
@@ -811,7 +842,10 @@ export async function validateSingleRfc(
|
|
|
811
842
|
.split("\n")
|
|
812
843
|
.filter((line: string) => /^- \[x\]/.test(line));
|
|
813
844
|
for (const line of checkedLines) {
|
|
814
|
-
|
|
845
|
+
// The LAST `(evidence: ...)` occurrence is the annotation — criterion
|
|
846
|
+
// prose may mention the literal syntax mid-sentence (RFC-1322 AC-1/2).
|
|
847
|
+
const evidenceMatches = [...line.matchAll(/\(evidence:\s*(.+?)\)/g)];
|
|
848
|
+
const evidenceMatch = evidenceMatches.at(-1);
|
|
815
849
|
if (!evidenceMatch) continue;
|
|
816
850
|
const evidence = evidenceMatch[1]!.trim();
|
|
817
851
|
|
|
@@ -926,6 +960,60 @@ export async function validateSingleRfc(
|
|
|
926
960
|
}
|
|
927
961
|
}
|
|
928
962
|
|
|
963
|
+
// V-43: valid verificationTier (RFC-1271 — optional; absent is valid)
|
|
964
|
+
const verificationTier = fm["verificationTier"];
|
|
965
|
+
if (
|
|
966
|
+
verificationTier !== undefined &&
|
|
967
|
+
!RFC_VERIFICATION_TIERS.includes(verificationTier as RfcVerificationTier)
|
|
968
|
+
) {
|
|
969
|
+
addViolation(
|
|
970
|
+
rfcId,
|
|
971
|
+
relFile,
|
|
972
|
+
"V-43",
|
|
973
|
+
`Invalid verificationTier "${String(verificationTier)}". Must be one of: ${RFC_VERIFICATION_TIERS.join(", ")}`,
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// V-44: WHEN/IF criteria need an execution probe (RFC-1330, post-cutoff only)
|
|
978
|
+
if (createdAt >= RFC_ORIGIN_CUTOFF && !isArchived) {
|
|
979
|
+
const acceptance = fm["acceptance"];
|
|
980
|
+
const probes = Array.isArray(acceptance) ? (acceptance as AcceptanceProbe[]) : [];
|
|
981
|
+
for (const id of findPresenceOnlyBehavioralCriteria(body, probes)) {
|
|
982
|
+
addViolation(
|
|
983
|
+
rfcId,
|
|
984
|
+
relFile,
|
|
985
|
+
"V-44",
|
|
986
|
+
`${id} is a WHEN/IF behavioral criterion evidenced only by presence probes (file-exists, command-registered, or file-contains/json-schema over non-doc paths). Bind an execution probe (test, run, or page) to ${id}.`,
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// V-45: proposed/added commands need a command-mode reachable probe (RFC-1334, warning)
|
|
992
|
+
if (createdAt >= RFC_REACHABLE_CUTOFF && !isArchived) {
|
|
993
|
+
const acceptance = fm["acceptance"];
|
|
994
|
+
const probes = Array.isArray(acceptance) ? (acceptance as AcceptanceProbe[]) : [];
|
|
995
|
+
const covered = new Set(
|
|
996
|
+
probes
|
|
997
|
+
.filter((p) => p.probe === "reachable" && "command" in p)
|
|
998
|
+
.map((p) => (p as { command: string }).command),
|
|
999
|
+
);
|
|
1000
|
+
const block = (fm["commands"] ?? {}) as Record<string, unknown>;
|
|
1001
|
+
const declared = [
|
|
1002
|
+
...(Array.isArray(block["proposed"]) ? block["proposed"] : []),
|
|
1003
|
+
...(Array.isArray(block["added"]) ? block["added"] : []),
|
|
1004
|
+
].map(String);
|
|
1005
|
+
const missing = declared.filter((c) => !covered.has(c));
|
|
1006
|
+
if (missing.length > 0) {
|
|
1007
|
+
addViolation(
|
|
1008
|
+
rfcId,
|
|
1009
|
+
relFile,
|
|
1010
|
+
"V-45",
|
|
1011
|
+
`commands without a command-mode reachable probe: ${missing.join(", ")} — add \`probe: reachable\` with \`command: <name>\` per command.`,
|
|
1012
|
+
"warning",
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
929
1017
|
// V-15: title consistency
|
|
930
1018
|
const titleStr = String(fm["title"] ?? "");
|
|
931
1019
|
const headingMatch = body.match(/^#\s+(?:RFC-\d{4}:\s*)?(.+)$/m);
|
|
@@ -1106,9 +1194,12 @@ export async function validateSingleRfc(
|
|
|
1106
1194
|
}
|
|
1107
1195
|
|
|
1108
1196
|
// V-23: verification evidence for post-cutoff, probe-bearing, implemented RFCs
|
|
1197
|
+
// Skip for archived RFCs — archival freezes the document; its envelope records
|
|
1198
|
+
// the state at stamp time and probe decay over moved/renamed paths is expected
|
|
1199
|
+
// historical drift, not actionable debt (precedent: V-13/V-15 archive skips).
|
|
1109
1200
|
const createdAtStr = String(fm["createdAt"] ?? "");
|
|
1110
1201
|
const hasProbes = Array.isArray(fm["acceptance"]) && (fm["acceptance"] as unknown[]).length > 0;
|
|
1111
|
-
if (createdAtStr >= RFC_METADATA_CUTOFF && hasProbes && status === "implemented") {
|
|
1202
|
+
if (!isArchived && createdAtStr >= RFC_METADATA_CUTOFF && hasProbes && status === "implemented") {
|
|
1112
1203
|
const slug = rfcId.toLowerCase();
|
|
1113
1204
|
const evidenceRelPath = path.join(RFC_DIR, "verification", `${slug}.generated.yaml`);
|
|
1114
1205
|
const evidenceAbsPath = path.join(workspaceRoot, evidenceRelPath);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
<MODULE_CONTRACT>
|
|
3
|
-
<purpose>
|
|
4
|
-
|
|
3
|
+
<purpose>
|
|
4
|
+
Unit tests for validate covering runRfcValidate --id flag guard. It also guards the documented public contract and regression-sensitive edge cases.
|
|
5
|
+
</purpose>
|
|
5
6
|
<non-goals>
|
|
6
7
|
<item>Do not duplicate validate-rules coverage — V-rule behavior lives in validate-rules*.test.ts.</item>
|
|
7
8
|
</non-goals>
|
|
8
9
|
</MODULE_CONTRACT>
|
|
9
10
|
<CHANGE_SUMMARY>
|
|
10
|
-
<item>Initial test — non-string --id (boolean/array from unvalidated flag input) throws a clear flag error instead of TypeError in rfcFileMatchesId.</item>
|
|
11
|
+
<item>RFC-1311: carried legacy entry — Initial test — non-string --id (boolean/array from unvalidated flag input) throws a clear flag error instead of TypeError in rfcFileMatchesId.</item>
|
|
11
12
|
</CHANGE_SUMMARY>
|
|
12
13
|
*/
|
|
13
14
|
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
RFC-1334: lexical reachability for the `reachable` acceptance probe — symbol mode
|
|
5
|
+
proves an exported symbol is value-imported by a non-test module (optionally
|
|
6
|
+
inside the import graph of a root file); command mode reads the generated command
|
|
7
|
+
manifest's `reachableVia` edges.
|
|
8
|
+
</purpose>
|
|
9
|
+
<non-goals>
|
|
10
|
+
<item>No TypeScript semantic resolution — import declarations are scanned lexically.</item>
|
|
11
|
+
<item>No @warpgogol/* imports — command reachability comes from the generated manifest.</item>
|
|
12
|
+
</non-goals>
|
|
13
|
+
</MODULE_CONTRACT>
|
|
14
|
+
<KEY_DECISIONS>
|
|
15
|
+
<item>Unsupported import forms (require, default-export probing) report as not reachable; use root or command mode.</item>
|
|
16
|
+
<item>The scan set is the workspace's tracked files (git ls-files) — no hardcoded directory layout.</item>
|
|
17
|
+
<item>Type-only imports and re-exports alone never count as usage.</item>
|
|
18
|
+
<item>Barrel re-exports are followed to depth 5; bare specifiers resolve through workspace package.json exports.</item>
|
|
19
|
+
<item>The tracked-file scan is memoized per workspace so several probes in one run share it.</item>
|
|
20
|
+
</KEY_DECISIONS>
|
|
21
|
+
<CHANGE_SUMMARY>
|
|
22
|
+
<item>RFC-1334: initial implementation.</item>
|
|
23
|
+
<item>RFC-1334: step 4 — reachable acceptance probe (symbol and command modes) and V-45</item>
|
|
24
|
+
</CHANGE_SUMMARY>
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
28
|
+
import { dirname, join, normalize, sep } from "node:path";
|
|
29
|
+
import { parse as yamlParse } from "yaml";
|
|
30
|
+
|
|
31
|
+
import { execFile } from "../../src/utils/sync-fs.ts";
|
|
32
|
+
import { gitEnvForCwd } from "./verification-origin.ts";
|
|
33
|
+
|
|
34
|
+
const SOURCE_EXT_RE = /\.(ts|tsx|mts|astro)$/;
|
|
35
|
+
const EXCLUDED_RE =
|
|
36
|
+
/(?:\.(?:test|spec)\.|\.pbt\.test\.|(?:^|\/)(?:tests|__tests__|fixtures|test-fixtures|dist|node_modules|\.stryker-tmp|\.coverage)\/|\.d\.ts$)/;
|
|
37
|
+
const MAX_REEXPORT_DEPTH = 5;
|
|
38
|
+
|
|
39
|
+
const toPosix = (p: string): string => p.split(sep).join("/");
|
|
40
|
+
|
|
41
|
+
interface ImportRecord {
|
|
42
|
+
/** Resolved repo-relative target, or null when unresolved. */
|
|
43
|
+
target: string | null;
|
|
44
|
+
/** Value-imported names (local alias irrelevant); "*" marks a namespace import. */
|
|
45
|
+
names: Set<string>;
|
|
46
|
+
/** Namespace alias, when `import * as ns`. */
|
|
47
|
+
namespace?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface FileInfo {
|
|
51
|
+
imports: ImportRecord[];
|
|
52
|
+
/** `export { a } from "x"` → a; `export * from "x"` → "*". */
|
|
53
|
+
reexports: Array<{ target: string | null; names: Set<string> }>;
|
|
54
|
+
/** Dynamic import targets (module loaders) — graph edges for root reachability. */
|
|
55
|
+
loaders: string[];
|
|
56
|
+
text: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface ScanIndex {
|
|
60
|
+
files: Map<string, FileInfo>;
|
|
61
|
+
packages: Map<string, { dir: string; exports: unknown }>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const indexCache = new Map<string, Promise<ScanIndex>>();
|
|
65
|
+
|
|
66
|
+
function gitLsFiles(workspaceRoot: string): Promise<string[]> {
|
|
67
|
+
return new Promise((done) => {
|
|
68
|
+
execFile(
|
|
69
|
+
"git",
|
|
70
|
+
["ls-files", "-z"],
|
|
71
|
+
{ cwd: workspaceRoot, maxBuffer: 256 * 1024 * 1024, env: gitEnvForCwd() },
|
|
72
|
+
(err, stdout) => done(err ? [] : String(stdout).split("\0").filter(Boolean)),
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Strip comments with a string-aware state machine (globs like "a/*" stay intact). */
|
|
78
|
+
function stripComments(src: string): string {
|
|
79
|
+
let out = "";
|
|
80
|
+
let state: "code" | "line" | "block" | "string" = "code";
|
|
81
|
+
let quote = "";
|
|
82
|
+
for (let i = 0; i < src.length; i++) {
|
|
83
|
+
const ch = src[i]!;
|
|
84
|
+
const next = src[i + 1];
|
|
85
|
+
if (state === "code") {
|
|
86
|
+
if (ch === "/" && next === "/") {
|
|
87
|
+
state = "line";
|
|
88
|
+
i++;
|
|
89
|
+
} else if (ch === "/" && next === "*") {
|
|
90
|
+
state = "block";
|
|
91
|
+
i++;
|
|
92
|
+
} else {
|
|
93
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
94
|
+
state = "string";
|
|
95
|
+
quote = ch;
|
|
96
|
+
}
|
|
97
|
+
out += ch;
|
|
98
|
+
}
|
|
99
|
+
} else if (state === "line") {
|
|
100
|
+
if (ch === "\n") {
|
|
101
|
+
state = "code";
|
|
102
|
+
out += ch;
|
|
103
|
+
}
|
|
104
|
+
} else if (state === "block") {
|
|
105
|
+
if (ch === "*" && next === "/") {
|
|
106
|
+
state = "code";
|
|
107
|
+
i++;
|
|
108
|
+
} else if (ch === "\n") out += ch;
|
|
109
|
+
} else {
|
|
110
|
+
out += ch;
|
|
111
|
+
if (ch === "\\") {
|
|
112
|
+
out += next ?? "";
|
|
113
|
+
i++;
|
|
114
|
+
} else if (ch === quote || (ch === "\n" && quote !== "`")) state = "code";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function astroFrontmatter(src: string): string {
|
|
121
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(src);
|
|
122
|
+
return m ? m[1]! : "";
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function resolveExportsEntry(entry: unknown): string | null {
|
|
126
|
+
if (typeof entry === "string") return entry;
|
|
127
|
+
if (entry && typeof entry === "object") {
|
|
128
|
+
const rec = entry as Record<string, unknown>;
|
|
129
|
+
for (const key of ["import", "default", "node"]) {
|
|
130
|
+
const v = resolveExportsEntry(rec[key]);
|
|
131
|
+
if (v) return v;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function resolveFile(rel: string, tracked: Set<string>): string | null {
|
|
138
|
+
const base = toPosix(normalize(rel));
|
|
139
|
+
const candidates = [
|
|
140
|
+
base,
|
|
141
|
+
base.replace(/\.js$/, ".ts"),
|
|
142
|
+
base.replace(/\.mjs$/, ".mts"),
|
|
143
|
+
`${base}.ts`,
|
|
144
|
+
`${base}.tsx`,
|
|
145
|
+
`${base}/index.ts`,
|
|
146
|
+
];
|
|
147
|
+
return candidates.find((c) => tracked.has(c)) ?? null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function resolveSpecifier(
|
|
151
|
+
importer: string,
|
|
152
|
+
spec: string,
|
|
153
|
+
tracked: Set<string>,
|
|
154
|
+
packages: ScanIndex["packages"],
|
|
155
|
+
): string | null {
|
|
156
|
+
if (spec.startsWith(".")) return resolveFile(join(dirname(importer), spec), tracked);
|
|
157
|
+
const parts = spec.split("/");
|
|
158
|
+
const nameParts = spec.startsWith("@") ? 2 : 1;
|
|
159
|
+
const pkgName = parts.slice(0, nameParts).join("/");
|
|
160
|
+
const sub = parts.slice(nameParts).join("/");
|
|
161
|
+
const pkg = packages.get(pkgName);
|
|
162
|
+
if (!pkg) return null;
|
|
163
|
+
const key = sub ? `./${sub}` : ".";
|
|
164
|
+
const exportsMap = pkg.exports;
|
|
165
|
+
let target: string | null = null;
|
|
166
|
+
if (typeof exportsMap === "string" && key === ".") target = exportsMap;
|
|
167
|
+
else if (exportsMap && typeof exportsMap === "object") {
|
|
168
|
+
const map = exportsMap as Record<string, unknown>;
|
|
169
|
+
target = resolveExportsEntry(map[key]);
|
|
170
|
+
if (!target) {
|
|
171
|
+
// Subpath patterns: "./*": "./src/*.ts"
|
|
172
|
+
for (const [pattern, value] of Object.entries(map)) {
|
|
173
|
+
const star = pattern.indexOf("*");
|
|
174
|
+
if (star < 0) continue;
|
|
175
|
+
const pre = pattern.slice(0, star);
|
|
176
|
+
const post = pattern.slice(star + 1);
|
|
177
|
+
if (key.startsWith(pre) && key.endsWith(post) && key.length >= pre.length + post.length) {
|
|
178
|
+
const hit = resolveExportsEntry(value);
|
|
179
|
+
if (hit) {
|
|
180
|
+
target = hit.replace("*", key.slice(pre.length, key.length - post.length));
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (!target) return sub ? resolveFile(join(pkg.dir, sub), tracked) : null;
|
|
188
|
+
return resolveFile(join(pkg.dir, target), tracked);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const IMPORT_RE = /\bimport\s+(type\s+)?([\s\S]*?)\s+from\s+["']([^"']+)["']/g;
|
|
192
|
+
const DYNAMIC_RE = /\{([^}]*)\}\s*=\s*await\s+import\(\s*["']([^"']+)["']\s*\)/g;
|
|
193
|
+
/** `const m = await import("x")` / `import("x").then((m) => …)` — bound as a namespace. */
|
|
194
|
+
const DYNAMIC_NS_RE =
|
|
195
|
+
/(?:\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*await\s+import\(\s*["']([^"']+)["']\s*\))|(?:\bimport\(\s*["']([^"']+)["']\s*\)\s*\.then\(\s*\(?\s*([A-Za-z_$][\w$]*))/g;
|
|
196
|
+
/** Any dynamic import specifier — a loader edge for root reachability. */
|
|
197
|
+
const DYNAMIC_ANY_RE = /\bimport\(\s*["']([^"']+)["']\s*\)/g;
|
|
198
|
+
const REEXPORT_RE = /\bexport\s+(type\s+)?(\*|\{[^}]*\})\s+from\s+["']([^"']+)["']/g;
|
|
199
|
+
|
|
200
|
+
function namedList(braced: string): Set<string> {
|
|
201
|
+
const names = new Set<string>();
|
|
202
|
+
for (const raw of braced.replace(/[{}]/g, "").split(",")) {
|
|
203
|
+
const part = raw.trim();
|
|
204
|
+
if (!part || part.startsWith("type ")) continue;
|
|
205
|
+
names.add(part.split(/\s+as\s+/)[0]!.trim());
|
|
206
|
+
}
|
|
207
|
+
return names;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function buildIndex(workspaceRoot: string): Promise<ScanIndex> {
|
|
211
|
+
const all = await gitLsFiles(workspaceRoot);
|
|
212
|
+
const tracked = new Set(all);
|
|
213
|
+
const packages: ScanIndex["packages"] = new Map();
|
|
214
|
+
for (const f of all.filter((f) => f.endsWith("package.json") && !f.includes("node_modules/"))) {
|
|
215
|
+
try {
|
|
216
|
+
const pj = JSON.parse(readFileSync(join(workspaceRoot, f), "utf8")) as {
|
|
217
|
+
name?: string;
|
|
218
|
+
exports?: unknown;
|
|
219
|
+
};
|
|
220
|
+
if (pj.name) packages.set(pj.name, { dir: dirname(f), exports: pj.exports ?? null });
|
|
221
|
+
} catch {
|
|
222
|
+
// Unparseable package.json — its specifiers stay unresolved.
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const files = new Map<string, FileInfo>();
|
|
226
|
+
for (const rel of all) {
|
|
227
|
+
if (!SOURCE_EXT_RE.test(rel) || rel.endsWith(".d.ts") || rel.includes("node_modules/"))
|
|
228
|
+
continue;
|
|
229
|
+
let text: string;
|
|
230
|
+
try {
|
|
231
|
+
text = readFileSync(join(workspaceRoot, rel), "utf8");
|
|
232
|
+
} catch {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (rel.endsWith(".astro")) text = astroFrontmatter(text);
|
|
236
|
+
const clean = stripComments(text);
|
|
237
|
+
const imports: ImportRecord[] = [];
|
|
238
|
+
for (const m of clean.matchAll(IMPORT_RE)) {
|
|
239
|
+
if (m[1]) continue; // import type
|
|
240
|
+
const clause = m[2]!.trim();
|
|
241
|
+
const target = resolveSpecifier(rel, m[3]!, tracked, packages);
|
|
242
|
+
const ns = /\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(clause);
|
|
243
|
+
const braced = /\{[^}]*\}/.exec(clause);
|
|
244
|
+
const rec: ImportRecord = { target, names: braced ? namedList(braced[0]) : new Set() };
|
|
245
|
+
if (ns) {
|
|
246
|
+
rec.namespace = ns[1]!;
|
|
247
|
+
rec.names.add("*");
|
|
248
|
+
}
|
|
249
|
+
imports.push(rec);
|
|
250
|
+
}
|
|
251
|
+
for (const m of clean.matchAll(DYNAMIC_RE)) {
|
|
252
|
+
imports.push({
|
|
253
|
+
target: resolveSpecifier(rel, m[2]!, tracked, packages),
|
|
254
|
+
names: namedList(m[1]!),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
for (const m of clean.matchAll(DYNAMIC_NS_RE)) {
|
|
258
|
+
const alias = m[1] ?? m[4];
|
|
259
|
+
const spec = m[2] ?? m[3];
|
|
260
|
+
if (alias && spec) {
|
|
261
|
+
imports.push({
|
|
262
|
+
target: resolveSpecifier(rel, spec, tracked, packages),
|
|
263
|
+
names: new Set(["*"]),
|
|
264
|
+
namespace: alias,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const loaders: string[] = [];
|
|
269
|
+
for (const m of clean.matchAll(DYNAMIC_ANY_RE)) {
|
|
270
|
+
const t = resolveSpecifier(rel, m[1]!, tracked, packages);
|
|
271
|
+
if (t) loaders.push(t);
|
|
272
|
+
}
|
|
273
|
+
const reexports: FileInfo["reexports"] = [];
|
|
274
|
+
for (const m of clean.matchAll(REEXPORT_RE)) {
|
|
275
|
+
if (m[1]) continue;
|
|
276
|
+
reexports.push({
|
|
277
|
+
target: resolveSpecifier(rel, m[3]!, tracked, packages),
|
|
278
|
+
names: m[2] === "*" ? new Set(["*"]) : namedList(m[2]!),
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
files.set(rel, { imports, reexports, loaders, text: clean });
|
|
282
|
+
}
|
|
283
|
+
return { files, packages };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function gitStateKey(workspaceRoot: string): Promise<string> {
|
|
287
|
+
return new Promise((done) => {
|
|
288
|
+
execFile(
|
|
289
|
+
"git",
|
|
290
|
+
["status", "--porcelain=v1", "-z", "--untracked-files=no"],
|
|
291
|
+
{ cwd: workspaceRoot, maxBuffer: 64 * 1024 * 1024, env: gitEnvForCwd() },
|
|
292
|
+
(_e, status) =>
|
|
293
|
+
execFile(
|
|
294
|
+
"git",
|
|
295
|
+
["rev-parse", "HEAD"],
|
|
296
|
+
{ cwd: workspaceRoot, env: gitEnvForCwd() },
|
|
297
|
+
(_e2, head) => done(`${String(head).trim()}:${String(status)}`),
|
|
298
|
+
),
|
|
299
|
+
);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Memoized per workspace and git state — edits or commits invalidate the scan. */
|
|
304
|
+
async function scanIndex(workspaceRoot: string): Promise<ScanIndex> {
|
|
305
|
+
const key = `${workspaceRoot}\u0000${await gitStateKey(workspaceRoot)}`;
|
|
306
|
+
let p = indexCache.get(key);
|
|
307
|
+
if (!p) {
|
|
308
|
+
indexCache.clear();
|
|
309
|
+
p = buildIndex(workspaceRoot);
|
|
310
|
+
indexCache.set(key, p);
|
|
311
|
+
}
|
|
312
|
+
return p;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Test seam: forget memoized scans (fixtures mutate their repositories). */
|
|
316
|
+
export function resetReachableScanCache(): void {
|
|
317
|
+
indexCache.clear();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export interface ReachableSymbolResult {
|
|
321
|
+
ok: boolean;
|
|
322
|
+
detail: string;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export async function probeReachableSymbol(opts: {
|
|
326
|
+
workspaceRoot: string;
|
|
327
|
+
symbol: string;
|
|
328
|
+
module: string;
|
|
329
|
+
root?: string;
|
|
330
|
+
}): Promise<ReachableSymbolResult> {
|
|
331
|
+
const { workspaceRoot } = opts;
|
|
332
|
+
const symbol = opts.symbol.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
333
|
+
const moduleRel = toPosix(normalize(opts.module));
|
|
334
|
+
if (!existsSync(join(workspaceRoot, moduleRel))) return { ok: false, detail: "module not found" };
|
|
335
|
+
const exportRe = new RegExp(
|
|
336
|
+
`\\bexport\\s+(?:declare\\s+)?(?:async\\s+)?(?:const|let|var|function\\*?|class|enum)\\s+${symbol}\\b|\\bexport\\s*\\{[^}]*\\b${symbol}\\b[^}]*\\}`,
|
|
337
|
+
);
|
|
338
|
+
const moduleText = stripComments(readFileSync(join(workspaceRoot, moduleRel), "utf8"));
|
|
339
|
+
if (!exportRe.test(moduleText)) return { ok: false, detail: "symbol not exported" };
|
|
340
|
+
|
|
341
|
+
const index = await scanIndex(workspaceRoot);
|
|
342
|
+
if (index.files.size === 0)
|
|
343
|
+
return { ok: false, detail: "scan failed: git ls-files returned no tracked sources" };
|
|
344
|
+
// Files that provide the symbol: the module plus barrels re-exporting it.
|
|
345
|
+
const providers = new Set([moduleRel]);
|
|
346
|
+
for (let depth = 0; depth < MAX_REEXPORT_DEPTH; depth++) {
|
|
347
|
+
let grew = false;
|
|
348
|
+
for (const [rel, info] of index.files) {
|
|
349
|
+
if (providers.has(rel)) continue;
|
|
350
|
+
if (
|
|
351
|
+
info.reexports.some(
|
|
352
|
+
(r) =>
|
|
353
|
+
r.target && providers.has(r.target) && (r.names.has(opts.symbol) || r.names.has("*")),
|
|
354
|
+
)
|
|
355
|
+
) {
|
|
356
|
+
providers.add(rel);
|
|
357
|
+
grew = true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (!grew) break;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const importers: string[] = [];
|
|
364
|
+
for (const [rel, info] of index.files) {
|
|
365
|
+
if (EXCLUDED_RE.test(rel)) continue;
|
|
366
|
+
const uses = info.imports.some((imp) => {
|
|
367
|
+
if (!imp.target || !providers.has(imp.target)) return false;
|
|
368
|
+
if (imp.names.has(opts.symbol)) return true;
|
|
369
|
+
return (
|
|
370
|
+
imp.namespace !== undefined &&
|
|
371
|
+
new RegExp(`\\b${imp.namespace}\\.${symbol}\\b`).test(info.text)
|
|
372
|
+
);
|
|
373
|
+
});
|
|
374
|
+
if (uses) importers.push(rel);
|
|
375
|
+
}
|
|
376
|
+
if (importers.length === 0) return { ok: false, detail: "no runtime importer" };
|
|
377
|
+
|
|
378
|
+
if (opts.root) {
|
|
379
|
+
const rootRel = toPosix(normalize(opts.root));
|
|
380
|
+
const seen = new Set<string>([rootRel]);
|
|
381
|
+
const queue = [rootRel];
|
|
382
|
+
while (queue.length > 0) {
|
|
383
|
+
const cur = queue.shift()!;
|
|
384
|
+
const info = index.files.get(cur);
|
|
385
|
+
const next = [
|
|
386
|
+
...(info?.imports ?? []).map((i) => i.target),
|
|
387
|
+
...(info?.reexports ?? []).map((r) => r.target),
|
|
388
|
+
...(info?.loaders ?? []),
|
|
389
|
+
];
|
|
390
|
+
for (const t of next) {
|
|
391
|
+
if (t && !seen.has(t)) {
|
|
392
|
+
seen.add(t);
|
|
393
|
+
queue.push(t);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const reached = importers.filter((i) => seen.has(i));
|
|
398
|
+
if (reached.length === 0) {
|
|
399
|
+
return {
|
|
400
|
+
ok: false,
|
|
401
|
+
detail: `importers not reachable from root ${rootRel}: ${importers.slice(0, 3).join(", ")}`,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
return { ok: true, detail: `reachable from ${rootRel} via ${reached.slice(0, 3).join(", ")}` };
|
|
405
|
+
}
|
|
406
|
+
return { ok: true, detail: `imported by ${importers.slice(0, 3).join(", ")}` };
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export async function probeReachableCommand(opts: {
|
|
410
|
+
workspaceRoot: string;
|
|
411
|
+
command: string;
|
|
412
|
+
}): Promise<ReachableSymbolResult> {
|
|
413
|
+
const manifestPath = join(opts.workspaceRoot, "docs", "command-manifest.generated.yaml");
|
|
414
|
+
if (!existsSync(manifestPath)) return { ok: false, detail: "command manifest not found" };
|
|
415
|
+
const manifest = yamlParse(readFileSync(manifestPath, "utf8")) as {
|
|
416
|
+
commands?: Array<{
|
|
417
|
+
name: string;
|
|
418
|
+
coverageNote?: string | null;
|
|
419
|
+
reachableVia?: Array<{ kind: string; ref: string }>;
|
|
420
|
+
}>;
|
|
421
|
+
};
|
|
422
|
+
const entry = manifest.commands?.find((c) => c.name === opts.command);
|
|
423
|
+
if (!entry) return { ok: false, detail: "command not in manifest" };
|
|
424
|
+
if (!Array.isArray(entry.reachableVia)) {
|
|
425
|
+
return { ok: false, detail: "manifest predates reachableVia — run command.manifest.generate" };
|
|
426
|
+
}
|
|
427
|
+
const edges = entry.reachableVia.filter(
|
|
428
|
+
(e) =>
|
|
429
|
+
e.kind !== "coverage" ||
|
|
430
|
+
e.ref !== "delegated" ||
|
|
431
|
+
(entry.coverageNote ?? "").trim().length > 0,
|
|
432
|
+
);
|
|
433
|
+
if (edges.length === 0) return { ok: false, detail: "no pipeline, invoker, or coverage edge" };
|
|
434
|
+
return {
|
|
435
|
+
ok: true,
|
|
436
|
+
detail: edges
|
|
437
|
+
.slice(0, 3)
|
|
438
|
+
.map((e) => `${e.kind}:${e.ref}`)
|
|
439
|
+
.join(", "),
|
|
440
|
+
};
|
|
441
|
+
}
|
|
@@ -52,21 +52,33 @@ appsImpacted: []
|
|
|
52
52
|
packagesImpacted: []
|
|
53
53
|
successSignals: []
|
|
54
54
|
nonGoals: []
|
|
55
|
+
# RFC-1271: Verification tier declares the expected rigor of the acceptance
|
|
56
|
+
# portfolio — standard (default) | high | formal. Policy-level signal reviewed
|
|
57
|
+
# at acceptance; tier-to-portfolio guidance lives in
|
|
58
|
+
# packages/forge/skills/_shared/agent-operating-model.md.
|
|
59
|
+
# verificationTier: standard
|
|
55
60
|
# OPTIONAL machine-checkable acceptance probes, executed on-demand
|
|
56
61
|
# via `pnpm exec forge rfc.acceptance.run --id <this-rfc-id>` (never
|
|
57
62
|
# automatically inside build pipelines).
|
|
63
|
+
# RFC-1271: a probe MAY declare `expectationSource` — who authored the
|
|
64
|
+
# expected result: self | requirement | independent | external — and
|
|
65
|
+
# `limitations`, a free-text caveat about coverage gaps. Both optional.
|
|
58
66
|
# acceptance:
|
|
59
67
|
# - probe: run
|
|
60
68
|
# criterion: AC-1
|
|
61
|
-
# command: "
|
|
69
|
+
# command: "werkstatt run some.command.validate"
|
|
62
70
|
# expect:
|
|
63
71
|
# exitCode: 0
|
|
72
|
+
# expectationSource: independent
|
|
64
73
|
# - probe: file-exists
|
|
65
74
|
# criterion: AC-2
|
|
66
75
|
# path: "packages/my-package/src/some-new-module.ts"
|
|
67
76
|
# - probe: command-registered
|
|
68
77
|
# criterion: AC-3
|
|
69
78
|
# name: "some.new.command"
|
|
79
|
+
# - probe: reachable
|
|
80
|
+
# criterion: AC-7
|
|
81
|
+
# command: "some.new.command" # or: symbol: someExport + module: "packages/x/src/m.ts" [+ root: <entry file>]
|
|
70
82
|
# - probe: file-contains
|
|
71
83
|
# criterion: AC-4
|
|
72
84
|
# path: "AGENTS.md"
|
|
@@ -234,6 +246,14 @@ interface ExampleResult {
|
|
|
234
246
|
in the same commit.
|
|
235
247
|
- Agents MUST NOT weaken or remove enforcement rules established by this RFC
|
|
236
248
|
without a new RFC that supersedes it.
|
|
249
|
+
- Agents report completion with the RFC-1271 vocabulary: IMPLEMENTED (code
|
|
250
|
+
landed), VERIFIED (independent probes pass), ACCEPTED (human/contract
|
|
251
|
+
acceptance), RELEASED (shipped to consumers). Do not claim a later state
|
|
252
|
+
than the evidence supports.
|
|
253
|
+
- Verification follows the portfolio model in
|
|
254
|
+
packages/forge/skills/_shared/agent-operating-model.md — TDD is one tool,
|
|
255
|
+
not a mandate; proportionate evidence (probes, tests, manual checks)
|
|
256
|
+
is required.
|
|
237
257
|
- If implementation reveals an invariant conflict, run
|
|
238
258
|
`pnpm exec forge rfc.supersede.propose --id <this-rfc-id> --reason "..." --invariant "DNA-N"`
|
|
239
259
|
instead of working around it.
|