@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
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1336: authority.delegate — operator-only grant path. Writes one
|
|
4
|
+
entry into the workspace-root authority.delegations.yaml registry and, when
|
|
5
|
+
running under a kernel host, fans out an authority-delegation Bordbuch event
|
|
6
|
+
to every covered site. Rejects non-delegable scopes, malformed actors,
|
|
7
|
+
unknown sites, and past expirations before any write.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>Do not decide who may run this command — the human-only rule is workspace policy (AGENTS.md), not a process check.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<KEY_DECISIONS>
|
|
13
|
+
<item>Registry write is the durable act; the Bordbuch event is audit evidence fanned out per site and never authoritative.</item>
|
|
14
|
+
<item>--site absent means a workspace grant; --site values must resolve to systems-cache siblings — a site that does not exist makes the grant meaningless.</item>
|
|
15
|
+
</KEY_DECISIONS>
|
|
16
|
+
<CHANGE_SUMMARY>
|
|
17
|
+
<item>RFC-1336: initial handler — grant append, site probe, optional --sign, per-site Bordbuch fan-out.</item>
|
|
18
|
+
<item>RFC-1336: step 1: forge authority module — delegation registry schema + resolver, four authority.* commands, optional Ed25519 signing</item>
|
|
19
|
+
</CHANGE_SUMMARY>
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
AGENT_OR_WILDCARD_PATTERN,
|
|
24
|
+
DELEGABLE_SCOPES,
|
|
25
|
+
HUMAN_ID_PATTERN,
|
|
26
|
+
NON_DELEGABLE_SCOPES,
|
|
27
|
+
BORDBUCH_SCOPE_PREFIX,
|
|
28
|
+
isDelegableScope,
|
|
29
|
+
loadDelegations,
|
|
30
|
+
serializeDelegations,
|
|
31
|
+
delegationsPath,
|
|
32
|
+
canonicalDelegationPayload,
|
|
33
|
+
type DelegationEntry,
|
|
34
|
+
} from "../../../src/authority/delegations.ts";
|
|
35
|
+
import { signDelegationPayload } from "../../../src/authority/signing.ts";
|
|
36
|
+
import type {
|
|
37
|
+
ForgeCommandInput,
|
|
38
|
+
ForgeCommandResult,
|
|
39
|
+
ForgeRuntimeContext,
|
|
40
|
+
} from "../../../src/types.ts";
|
|
41
|
+
import {
|
|
42
|
+
appendAuthorityEvent,
|
|
43
|
+
coveredSites,
|
|
44
|
+
flagString,
|
|
45
|
+
flagStringList,
|
|
46
|
+
systemsCacheSiteExists,
|
|
47
|
+
} from "../helpers.ts";
|
|
48
|
+
|
|
49
|
+
export interface AuthorityDelegateResult {
|
|
50
|
+
command: "authority.delegate";
|
|
51
|
+
status: "pass" | "fail";
|
|
52
|
+
delegation?: DelegationEntry;
|
|
53
|
+
bordbuch?: { appended: string[]; skipped: boolean };
|
|
54
|
+
diagnostics: string[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function nextDelegationId(entries: DelegationEntry[]): string {
|
|
58
|
+
const max = entries.reduce((acc, e) => {
|
|
59
|
+
const m = e.id.match(/^del-(\d{4,})$/);
|
|
60
|
+
return m ? Math.max(acc, parseInt(m[1], 10)) : acc;
|
|
61
|
+
}, 0);
|
|
62
|
+
return `del-${String(max + 1).padStart(4, "0")}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function runAuthorityDelegate(
|
|
66
|
+
input: ForgeCommandInput,
|
|
67
|
+
context: ForgeRuntimeContext,
|
|
68
|
+
): Promise<ForgeCommandResult<AuthorityDelegateResult>> {
|
|
69
|
+
const { workspaceRoot, logger } = context;
|
|
70
|
+
const scope = flagString(input, "scope");
|
|
71
|
+
const to = flagString(input, "to");
|
|
72
|
+
const by = flagString(input, "by");
|
|
73
|
+
const sites = flagStringList(input, "site");
|
|
74
|
+
const expires = flagString(input, "expires");
|
|
75
|
+
const note = flagString(input, "note");
|
|
76
|
+
const sign = input.flags["sign"] === true || input.flags["sign"] === "true";
|
|
77
|
+
|
|
78
|
+
if (!scope) throw new Error("authority.delegate requires --scope <scope-id>");
|
|
79
|
+
if (!to) throw new Error("authority.delegate requires --to agent:<id>");
|
|
80
|
+
if (!by) throw new Error("authority.delegate requires --by human:<handle>");
|
|
81
|
+
if (!AGENT_OR_WILDCARD_PATTERN.test(to)) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`--to must name an agent identity (agent:<id>) or the agent:* wildcard — got "${to}". Agents may only act as themselves; human:<handle> grantees are not allowed.`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (!HUMAN_ID_PATTERN.test(by)) {
|
|
87
|
+
throw new Error(`--by must name the granting human (human:<handle>) — got "${by}"`);
|
|
88
|
+
}
|
|
89
|
+
if ((NON_DELEGABLE_SCOPES as readonly string[]).includes(scope)) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`scope "${scope}" is non-delegable (RFC-1336) — security-sensitive or irreversible flows stay human-only`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (!isDelegableScope(scope)) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`unknown scope "${scope}" — delegable scopes: ${[...DELEGABLE_SCOPES, `${BORDBUCH_SCOPE_PREFIX}<kind>`].join(", ")}`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (to === "agent:*") {
|
|
100
|
+
logger.warn(
|
|
101
|
+
" [authority] granting to the agent:* wildcard — any agent may claim this delegation; prefer an explicit agent:<id>",
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (expires !== undefined && Number.isNaN(Date.parse(expires))) {
|
|
105
|
+
throw new Error(`--expires must be an ISO-8601 datetime — got "${expires}"`);
|
|
106
|
+
}
|
|
107
|
+
if (expires !== undefined && new Date(expires).getTime() <= Date.now()) {
|
|
108
|
+
throw new Error(`--expires "${expires}" is already in the past — grant would be born dead`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
for (const siteId of sites) {
|
|
112
|
+
if (!(await systemsCacheSiteExists(workspaceRoot, siteId, context.io))) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
`--site "${siteId}" does not resolve — no systems-cache/${siteId} sibling exists; site-scoped grants must name a real site`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const registry = await loadDelegations(workspaceRoot, context.io);
|
|
120
|
+
const grantedAt = new Date().toISOString();
|
|
121
|
+
const entry: DelegationEntry = {
|
|
122
|
+
id: nextDelegationId(registry.delegations),
|
|
123
|
+
scope,
|
|
124
|
+
grantedTo: to,
|
|
125
|
+
grantedBy: by,
|
|
126
|
+
sites: sites.length === 0 ? "workspace" : sites,
|
|
127
|
+
grantedAt,
|
|
128
|
+
expiresAt: expires ?? null,
|
|
129
|
+
revokedAt: null,
|
|
130
|
+
...(note !== undefined ? { note } : {}),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
if (sign) {
|
|
134
|
+
const seed = process.env["SIGNING_PRIVATE_KEY"];
|
|
135
|
+
if (!seed || !/^[0-9a-fA-F]{64}$/.test(seed)) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
"--sign requires SIGNING_PRIVATE_KEY (hex-encoded 32-byte Ed25519 seed) in the environment",
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
entry.signature = `ed25519:${signDelegationPayload(seed, canonicalDelegationPayload(entry))}`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (context.dryRun) {
|
|
144
|
+
return {
|
|
145
|
+
data: {
|
|
146
|
+
command: "authority.delegate",
|
|
147
|
+
status: "pass",
|
|
148
|
+
delegation: entry,
|
|
149
|
+
diagnostics: ["dry-run — registry unchanged"],
|
|
150
|
+
},
|
|
151
|
+
summary: `[authority.delegate] would grant ${entry.id} (${scope} → ${to})`,
|
|
152
|
+
exitCode: 0,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
registry.delegations.push(entry);
|
|
157
|
+
const { resolveIo } = await import("../../../src/utils/io.ts");
|
|
158
|
+
await resolveIo(context.io).writeFile(
|
|
159
|
+
delegationsPath(workspaceRoot),
|
|
160
|
+
serializeDelegations(registry),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const covered = await coveredSites(workspaceRoot, entry, context.io);
|
|
164
|
+
const bordbuch = await appendAuthorityEvent(context, {
|
|
165
|
+
kind: "authority-delegation",
|
|
166
|
+
sites: covered,
|
|
167
|
+
summary: `Delegation ${entry.id}: ${scope} granted to ${to} by ${by}`,
|
|
168
|
+
actor: by,
|
|
169
|
+
metadata: {
|
|
170
|
+
delegationId: entry.id,
|
|
171
|
+
scope,
|
|
172
|
+
grantedTo: to,
|
|
173
|
+
expiresAt: entry.expiresAt ?? null,
|
|
174
|
+
...(note !== undefined ? { note } : {}),
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
logger.success(`[authority.delegate] granted ${entry.id}: ${scope} → ${to}`);
|
|
179
|
+
return {
|
|
180
|
+
data: {
|
|
181
|
+
command: "authority.delegate",
|
|
182
|
+
status: "pass",
|
|
183
|
+
delegation: entry,
|
|
184
|
+
bordbuch,
|
|
185
|
+
diagnostics: [],
|
|
186
|
+
},
|
|
187
|
+
summary: `[authority.delegate] ${entry.id}: ${scope} → ${to} (by ${by}${expires ? `, expires ${expires}` : ""})`,
|
|
188
|
+
exitCode: 0,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1336: authority.delegation.list — read-only registry listing.
|
|
4
|
+
Defaults to active grants; --history includes revoked and expired entries.
|
|
5
|
+
--site filters to grants covering one site.</purpose>
|
|
6
|
+
<non-goals>
|
|
7
|
+
<item>Do not evaluate whether a grant authorizes a specific act — resolveDelegation does that; this reports registry content.</item>
|
|
8
|
+
</non-goals>
|
|
9
|
+
</MODULE_CONTRACT>
|
|
10
|
+
<CHANGE_SUMMARY>
|
|
11
|
+
<item>RFC-1336: initial handler — active-only default, --history flag, --site filter.</item>
|
|
12
|
+
<item>RFC-1336: step 1: forge authority module — delegation registry schema + resolver, four authority.* commands, optional Ed25519 signing</item>
|
|
13
|
+
</CHANGE_SUMMARY>
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { loadDelegations, type DelegationEntry } from "../../../src/authority/delegations.ts";
|
|
17
|
+
import type {
|
|
18
|
+
ForgeCommandInput,
|
|
19
|
+
ForgeCommandResult,
|
|
20
|
+
ForgeRuntimeContext,
|
|
21
|
+
} from "../../../src/types.ts";
|
|
22
|
+
import { flagString } from "../helpers.ts";
|
|
23
|
+
|
|
24
|
+
export interface AuthorityDelegationListResult {
|
|
25
|
+
command: "authority.delegation.list";
|
|
26
|
+
status: "pass" | "fail";
|
|
27
|
+
total: number;
|
|
28
|
+
shown: number;
|
|
29
|
+
delegations: DelegationEntry[];
|
|
30
|
+
diagnostics: string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function runAuthorityDelegationList(
|
|
34
|
+
input: ForgeCommandInput,
|
|
35
|
+
context: ForgeRuntimeContext,
|
|
36
|
+
): Promise<ForgeCommandResult<AuthorityDelegationListResult>> {
|
|
37
|
+
const { workspaceRoot, logger, outputFormat } = context;
|
|
38
|
+
const site = flagString(input, "site");
|
|
39
|
+
const history = input.flags["history"] === true || input.flags["history"] === "true";
|
|
40
|
+
|
|
41
|
+
const registry = await loadDelegations(workspaceRoot, context.io);
|
|
42
|
+
const now = new Date();
|
|
43
|
+
const isActive = (d: DelegationEntry) =>
|
|
44
|
+
!d.revokedAt && (!d.expiresAt || new Date(d.expiresAt).getTime() > now.getTime());
|
|
45
|
+
const coversSite = (d: DelegationEntry) =>
|
|
46
|
+
site === undefined || d.sites === "workspace" || d.sites.includes(site);
|
|
47
|
+
|
|
48
|
+
const shown = registry.delegations.filter((d) => (history || isActive(d)) && coversSite(d));
|
|
49
|
+
|
|
50
|
+
if (outputFormat === "pretty") {
|
|
51
|
+
logger.section("Authority delegations");
|
|
52
|
+
if (shown.length === 0) {
|
|
53
|
+
logger.info(" (none)");
|
|
54
|
+
}
|
|
55
|
+
for (const d of shown) {
|
|
56
|
+
const state = d.revokedAt
|
|
57
|
+
? `revoked ${d.revokedAt}`
|
|
58
|
+
: d.expiresAt && new Date(d.expiresAt).getTime() <= now.getTime()
|
|
59
|
+
? `expired ${d.expiresAt}`
|
|
60
|
+
: "active";
|
|
61
|
+
const sites = d.sites === "workspace" ? "workspace" : d.sites.join(",");
|
|
62
|
+
logger.info(
|
|
63
|
+
` ${d.id} ${d.scope} → ${d.grantedTo} by ${d.grantedBy} [${sites}] ${state}`,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
data: {
|
|
70
|
+
command: "authority.delegation.list",
|
|
71
|
+
status: "pass",
|
|
72
|
+
total: registry.delegations.length,
|
|
73
|
+
shown: shown.length,
|
|
74
|
+
delegations: shown,
|
|
75
|
+
diagnostics: [],
|
|
76
|
+
},
|
|
77
|
+
summary: `${shown.length}/${registry.delegations.length} delegation(s)${history ? "" : " active"}`,
|
|
78
|
+
exitCode: 0,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1336: authority.delegation.validate — the registry's validator
|
|
4
|
+
(DNA-91 contract authority, rules DELEG-01..08). Absent registry is a clean
|
|
5
|
+
pass; schema violations and non-delegable scopes block; agent:* wildcards,
|
|
6
|
+
unknown sites, unknown scopes, and bad signatures warn.</purpose>
|
|
7
|
+
<non-goals>
|
|
8
|
+
<item>Do not mutate the registry — read-only validator.</item>
|
|
9
|
+
</non-goals>
|
|
10
|
+
</MODULE_CONTRACT>
|
|
11
|
+
<CHANGE_SUMMARY>
|
|
12
|
+
<item>RFC-1336: initial handler — DELEG-01..08.</item>
|
|
13
|
+
<item>RFC-1336: step 1: forge authority module — delegation registry schema + resolver, four authority.* commands, optional Ed25519 signing</item>
|
|
14
|
+
</CHANGE_SUMMARY>
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import YAML from "yaml";
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
DELEGATIONS_FILENAME,
|
|
21
|
+
NON_DELEGABLE_SCOPES,
|
|
22
|
+
authorityDelegationsSchema,
|
|
23
|
+
canonicalDelegationPayload,
|
|
24
|
+
delegationsPath,
|
|
25
|
+
isDelegableScope,
|
|
26
|
+
} from "../../../src/authority/delegations.ts";
|
|
27
|
+
import { verifyDelegationSignature } from "../../../src/authority/signing.ts";
|
|
28
|
+
import type {
|
|
29
|
+
Diagnostic,
|
|
30
|
+
ForgeCommandInput,
|
|
31
|
+
ForgeCommandResult,
|
|
32
|
+
ForgeRuntimeContext,
|
|
33
|
+
} from "../../../src/types.ts";
|
|
34
|
+
import { resolveIo } from "../../../src/utils/io.ts";
|
|
35
|
+
import { flagString, systemsCacheSiteExists } from "../helpers.ts";
|
|
36
|
+
|
|
37
|
+
export interface AuthorityDelegationValidateResult {
|
|
38
|
+
command: "authority.delegation.validate";
|
|
39
|
+
status: "pass" | "fail";
|
|
40
|
+
file: string;
|
|
41
|
+
delegations: number;
|
|
42
|
+
errors: Diagnostic[];
|
|
43
|
+
warnings: Diagnostic[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function diag(
|
|
47
|
+
ruleId: string,
|
|
48
|
+
severity: "error" | "warning",
|
|
49
|
+
message: string,
|
|
50
|
+
file?: string,
|
|
51
|
+
): Diagnostic {
|
|
52
|
+
return { ruleId, severity, message, file };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function runAuthorityDelegationValidate(
|
|
56
|
+
input: ForgeCommandInput,
|
|
57
|
+
context: ForgeRuntimeContext,
|
|
58
|
+
): Promise<ForgeCommandResult<AuthorityDelegationValidateResult>> {
|
|
59
|
+
const { workspaceRoot, logger, outputFormat } = context;
|
|
60
|
+
const siteFilter = flagString(input, "site");
|
|
61
|
+
const errors: Diagnostic[] = [];
|
|
62
|
+
const warnings: Diagnostic[] = [];
|
|
63
|
+
const io = resolveIo(context.io);
|
|
64
|
+
const filePath = delegationsPath(workspaceRoot);
|
|
65
|
+
|
|
66
|
+
// DELEG-01: absent registry is legal (zero delegations); unreadable or
|
|
67
|
+
// unparseable registry is a blocking load failure — never fail open.
|
|
68
|
+
let raw: unknown;
|
|
69
|
+
try {
|
|
70
|
+
raw = YAML.parse(await io.readFile(filePath));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
if ((e as NodeJS.ErrnoException).code === "ENOENT") {
|
|
73
|
+
return {
|
|
74
|
+
data: {
|
|
75
|
+
command: "authority.delegation.validate",
|
|
76
|
+
status: "pass",
|
|
77
|
+
file: DELEGATIONS_FILENAME,
|
|
78
|
+
delegations: 0,
|
|
79
|
+
errors,
|
|
80
|
+
warnings,
|
|
81
|
+
},
|
|
82
|
+
summary: "no delegation registry — zero delegations",
|
|
83
|
+
exitCode: 0,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
errors.push(
|
|
87
|
+
diag(
|
|
88
|
+
"DELEG-01",
|
|
89
|
+
"error",
|
|
90
|
+
`cannot read/parse ${DELEGATIONS_FILENAME}: ${e instanceof Error ? e.message : String(e)}`,
|
|
91
|
+
DELEGATIONS_FILENAME,
|
|
92
|
+
),
|
|
93
|
+
);
|
|
94
|
+
return { data: resultData(errors, warnings, 0), summary: "registry unreadable", exitCode: 1 };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// DELEG-02: schema violations.
|
|
98
|
+
const parsed = authorityDelegationsSchema.safeParse(raw);
|
|
99
|
+
const entries = parsed.success
|
|
100
|
+
? parsed.data.delegations
|
|
101
|
+
: Array.isArray((raw as { delegations?: unknown[] })?.delegations)
|
|
102
|
+
? ((raw as { delegations: unknown[] }).delegations.filter(
|
|
103
|
+
(d): d is Record<string, unknown> => typeof d === "object" && d !== null,
|
|
104
|
+
) as never[])
|
|
105
|
+
: [];
|
|
106
|
+
if (!parsed.success) {
|
|
107
|
+
for (const issue of parsed.error.issues) {
|
|
108
|
+
errors.push(
|
|
109
|
+
diag(
|
|
110
|
+
"DELEG-02",
|
|
111
|
+
"error",
|
|
112
|
+
`schema violation at ${issue.path.join(".") || "<root>"}: ${issue.message}`,
|
|
113
|
+
DELEGATIONS_FILENAME,
|
|
114
|
+
),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Semantic checks run over whatever parsed — per-entry diagnostics.
|
|
120
|
+
const seen = new Set<string>();
|
|
121
|
+
const now = Date.now();
|
|
122
|
+
for (const d of entries) {
|
|
123
|
+
const id = typeof d.id === "string" ? d.id : "<unknown>";
|
|
124
|
+
if (seen.has(id)) {
|
|
125
|
+
errors.push(
|
|
126
|
+
diag("DELEG-03", "error", `duplicate delegation id "${id}"`, DELEGATIONS_FILENAME),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
seen.add(id);
|
|
130
|
+
|
|
131
|
+
const scope = typeof d.scope === "string" ? d.scope : "";
|
|
132
|
+
if ((NON_DELEGABLE_SCOPES as readonly string[]).includes(scope)) {
|
|
133
|
+
errors.push(
|
|
134
|
+
diag(
|
|
135
|
+
"DELEG-04",
|
|
136
|
+
"error",
|
|
137
|
+
`"${id}" delegates non-delegable scope "${scope}" (RFC-1336: human-only)`,
|
|
138
|
+
DELEGATIONS_FILENAME,
|
|
139
|
+
),
|
|
140
|
+
);
|
|
141
|
+
} else if (scope && !isDelegableScope(scope)) {
|
|
142
|
+
warnings.push(
|
|
143
|
+
diag(
|
|
144
|
+
"DELEG-05",
|
|
145
|
+
"warning",
|
|
146
|
+
`"${id}" uses unknown scope "${scope}" — not in the RFC-1336 catalogue`,
|
|
147
|
+
DELEGATIONS_FILENAME,
|
|
148
|
+
),
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (d.grantedTo === "agent:*") {
|
|
153
|
+
warnings.push(
|
|
154
|
+
diag(
|
|
155
|
+
"DELEG-06",
|
|
156
|
+
"warning",
|
|
157
|
+
`"${id}" grants the agent:* wildcard — prefer an explicit agent:<id>`,
|
|
158
|
+
DELEGATIONS_FILENAME,
|
|
159
|
+
),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (Array.isArray(d.sites)) {
|
|
164
|
+
for (const siteId of d.sites as string[]) {
|
|
165
|
+
if (siteFilter && siteId !== siteFilter && siteFilter !== undefined) continue;
|
|
166
|
+
if (!(await systemsCacheSiteExists(workspaceRoot, siteId, context.io))) {
|
|
167
|
+
warnings.push(
|
|
168
|
+
diag(
|
|
169
|
+
"DELEG-07",
|
|
170
|
+
"warning",
|
|
171
|
+
`"${id}" references site "${siteId}" — no systems-cache/${siteId} sibling exists`,
|
|
172
|
+
DELEGATIONS_FILENAME,
|
|
173
|
+
),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (typeof d.signature === "string" && parsed.success) {
|
|
180
|
+
const entry = parsed.data.delegations.find((e) => e.id === id);
|
|
181
|
+
if (
|
|
182
|
+
entry &&
|
|
183
|
+
!verifyDelegationSignature(entry.signature!, canonicalDelegationPayload(entry))
|
|
184
|
+
) {
|
|
185
|
+
warnings.push(
|
|
186
|
+
diag(
|
|
187
|
+
"DELEG-08",
|
|
188
|
+
"warning",
|
|
189
|
+
`"${id}" signature does not verify against its canonical payload`,
|
|
190
|
+
DELEGATIONS_FILENAME,
|
|
191
|
+
),
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Informational: expired-but-unrevoked entries are legal history, no signal.
|
|
197
|
+
void now;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const status = errors.length === 0 ? "pass" : "fail";
|
|
201
|
+
if (outputFormat === "pretty") {
|
|
202
|
+
logger.section(`Authority delegations: ${DELEGATIONS_FILENAME}`);
|
|
203
|
+
logger.info(` ${entries.length} delegation(s)`);
|
|
204
|
+
for (const w of warnings) logger.warn(` ${w.ruleId}: ${w.message}`);
|
|
205
|
+
for (const e of errors) logger.error(` ${e.ruleId}: ${e.message}`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
data: resultData(errors, warnings, entries.length),
|
|
210
|
+
summary:
|
|
211
|
+
status === "pass"
|
|
212
|
+
? `delegation registry valid: ${entries.length} delegation(s), ${warnings.length} warning(s)`
|
|
213
|
+
: `delegation registry invalid: ${errors.length} error(s)`,
|
|
214
|
+
exitCode: status === "pass" ? 0 : 1,
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
function resultData(
|
|
218
|
+
errs: Diagnostic[],
|
|
219
|
+
warns: Diagnostic[],
|
|
220
|
+
count: number,
|
|
221
|
+
): AuthorityDelegationValidateResult {
|
|
222
|
+
return {
|
|
223
|
+
command: "authority.delegation.validate",
|
|
224
|
+
status: errs.length === 0 ? "pass" : "fail",
|
|
225
|
+
file: DELEGATIONS_FILENAME,
|
|
226
|
+
delegations: count,
|
|
227
|
+
errors: errs,
|
|
228
|
+
warnings: warns,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1336: shared authority-module helpers — werkstatt-layout site
|
|
4
|
+
probes (systems-cache sibling convention) and Bordbuch audit-event emission
|
|
5
|
+
through the kernel's sibling-invocation port (ForgeRuntimeContext.invoke,
|
|
6
|
+
RFC-1306). All engine touchpoints degrade cleanly under the standalone
|
|
7
|
+
forge CLI where no kernel host exists.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>Do not import @warpgogol/* runtime packages — FORGE-AUTONOMY-01; the invoke port is the only engine surface.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<CHANGE_SUMMARY>
|
|
13
|
+
<item>RFC-1336: initial module — systemsCacheSiteExists, coveredSites, appendAuthorityEvent.</item>
|
|
14
|
+
<item>RFC-1336: step 1: forge authority module — delegation registry schema + resolver, four authority.* commands, optional Ed25519 signing</item>
|
|
15
|
+
</CHANGE_SUMMARY>
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
|
|
20
|
+
import type { DelegationEntry } from "../../src/authority/delegations.ts";
|
|
21
|
+
import type { ForgeRuntimeContext, WorkspaceIO } from "../../src/types.ts";
|
|
22
|
+
import { resolveIo } from "../../src/utils/io.ts";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Werkstatt layout: systems-cache/<id> is a sibling of the workshop root
|
|
26
|
+
* (mirrors[0], RFC-0790). A declared site-scoped grant must name a site that
|
|
27
|
+
* actually exists — a typo'd site would silently bind to nothing.
|
|
28
|
+
*/
|
|
29
|
+
export async function systemsCacheSiteExists(
|
|
30
|
+
workspaceRoot: string,
|
|
31
|
+
siteId: string,
|
|
32
|
+
io?: WorkspaceIO,
|
|
33
|
+
): Promise<boolean> {
|
|
34
|
+
const effectiveIo = resolveIo(io);
|
|
35
|
+
const siteDir = path.resolve(workspaceRoot, "..", "systems-cache", siteId);
|
|
36
|
+
return effectiveIo.exists(siteDir);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Enumerate the sites a grant covers for audit-event fan-out: explicit ids,
|
|
41
|
+
* or every systems-cache sibling dir for "workspace" grants.
|
|
42
|
+
*/
|
|
43
|
+
export async function coveredSites(
|
|
44
|
+
workspaceRoot: string,
|
|
45
|
+
grant: Pick<DelegationEntry, "sites">,
|
|
46
|
+
io?: WorkspaceIO,
|
|
47
|
+
): Promise<string[]> {
|
|
48
|
+
if (grant.sites !== "workspace") return grant.sites;
|
|
49
|
+
const effectiveIo = resolveIo(io);
|
|
50
|
+
const cacheDir = path.resolve(workspaceRoot, "..", "systems-cache");
|
|
51
|
+
if (!(await effectiveIo.exists(cacheDir))) return [];
|
|
52
|
+
const entries = await effectiveIo.readdir(cacheDir);
|
|
53
|
+
return entries.filter((e) => e.isDirectory).map((e) => e.name);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Append one audit event per covered site via bordbuch.append — the
|
|
58
|
+
* sibling-invocation port exists only under a kernel host; under the
|
|
59
|
+
* standalone forge CLI the registry write has already landed (it is the
|
|
60
|
+
* source of truth) and the event degrades to a warning.
|
|
61
|
+
*/
|
|
62
|
+
export async function appendAuthorityEvent(
|
|
63
|
+
context: ForgeRuntimeContext,
|
|
64
|
+
opts: {
|
|
65
|
+
kind: "authority-delegation" | "authority-delegation-revoked";
|
|
66
|
+
sites: string[];
|
|
67
|
+
summary: string;
|
|
68
|
+
actor: string;
|
|
69
|
+
metadata: Record<string, unknown>;
|
|
70
|
+
},
|
|
71
|
+
): Promise<{ appended: string[]; skipped: boolean }> {
|
|
72
|
+
if (!context.invoke) {
|
|
73
|
+
context.logger.warn(
|
|
74
|
+
` [authority] bordbuch event '${opts.kind}' not recorded — no kernel host (registry is the source of truth)`,
|
|
75
|
+
);
|
|
76
|
+
return { appended: [], skipped: true };
|
|
77
|
+
}
|
|
78
|
+
const appended: string[] = [];
|
|
79
|
+
for (const siteId of opts.sites) {
|
|
80
|
+
const result = await context.invoke("bordbuch.append", {
|
|
81
|
+
system: siteId,
|
|
82
|
+
kind: opts.kind,
|
|
83
|
+
summary: opts.summary,
|
|
84
|
+
actor: opts.actor,
|
|
85
|
+
"writer-role": "operator",
|
|
86
|
+
metadata: JSON.stringify(opts.metadata),
|
|
87
|
+
});
|
|
88
|
+
if (result.ok || result.exitCode === 0) {
|
|
89
|
+
appended.push(siteId);
|
|
90
|
+
} else {
|
|
91
|
+
context.logger.warn(
|
|
92
|
+
` [authority] bordbuch event for '${siteId}' failed: ${result.summary ?? "unknown"}`,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return { appended, skipped: false };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function flagString(
|
|
100
|
+
input: { flags: Record<string, unknown> },
|
|
101
|
+
key: string,
|
|
102
|
+
): string | undefined {
|
|
103
|
+
const v = input.flags[key];
|
|
104
|
+
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function flagStringList(input: { flags: Record<string, unknown> }, key: string): string[] {
|
|
108
|
+
const v = input.flags[key];
|
|
109
|
+
if (Array.isArray(v)) return v.filter((x): x is string => typeof x === "string");
|
|
110
|
+
return typeof v === "string" && v.length > 0 ? [v] : [];
|
|
111
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1336: authority module barrel — re-exports the module factory.</purpose>
|
|
4
|
+
<non-goals>
|
|
5
|
+
<item>Do not add handler logic — that lives in handlers/.</item>
|
|
6
|
+
</non-goals>
|
|
7
|
+
</MODULE_CONTRACT>
|
|
8
|
+
<CHANGE_SUMMARY>
|
|
9
|
+
<item>RFC-1336: initial barrel.</item>
|
|
10
|
+
<item>RFC-1336: step 1: forge authority module — delegation registry schema + resolver, four authority.* commands, optional Ed25519 signing</item>
|
|
11
|
+
</CHANGE_SUMMARY>
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export { createForgeAuthorityModule } from "./authority.module.ts";
|