@mnstry/atelier 0.2.0-alpha.1 → 0.2.0-alpha.11
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 +413 -0
- package/README.md +402 -205
- package/SECURITY.md +6 -1
- package/contracts/atelier-adoption-policy.v1.schema.json +49 -0
- package/contracts/atelier-coauthor.v1.schema.json +163 -0
- package/contracts/atelier-decision-request.v1.schema.json +476 -0
- package/contracts/atelier-decision-result.v1.schema.json +500 -0
- package/contracts/atelier-guide.v1.schema.json +227 -0
- package/contracts/atelier-intake.v1.schema.json +151 -0
- package/contracts/atelier-migration.v2.schema.json +61 -0
- package/contracts/atelier-obsidian-acceptance-receipt.v1.schema.json +211 -0
- package/contracts/atelier-obsidian-apply-policy.v1.schema.json +298 -0
- package/contracts/atelier-obsidian-corpus-profile.v1.schema.json +98 -0
- package/contracts/atelier-obsidian-edit-operation.v1.schema.json +138 -0
- package/contracts/atelier-obsidian-ext-settings.v1.schema.json +287 -0
- package/contracts/atelier-obsidian-generation-manifest.v1.schema.json +353 -0
- package/contracts/atelier-obsidian-proposal-receipt.v1.schema.json +110 -0
- package/contracts/atelier-obsidian-publication-journal.v1.schema.json +167 -0
- package/contracts/atelier-obsidian-scope.v1.schema.json +264 -0
- package/contracts/atelier-obsidian-service-state.v1.schema.json +149 -0
- package/contracts/atelier-obsidian-source-snapshot.v1.schema.json +179 -0
- package/contracts/atelier-pane-presentation.v1.schema.json +76 -0
- package/contracts/atelier-presentation.v1.schema.json +1293 -0
- package/contracts/atelier-repository-observation.v1.schema.json +163 -0
- package/contracts/atelier-review.v1.schema.json +1601 -0
- package/contracts/atelier-skill-steward.v1.schema.json +692 -0
- package/contracts/atelier-upgrade-plan.v2.schema.json +398 -0
- package/contracts/atelier-upgrade-receipt.v1.schema.json +99 -0
- package/contracts/atelier-vault-publication.v1.schema.json +58 -0
- package/contracts/public-api-baseline.json +57 -0
- package/docs/assurance-controls.md +49 -0
- package/docs/atelier-runtime.md +28 -2
- package/docs/atelier-sync.md +172 -0
- package/docs/blocks/audience-visibility.md +9 -0
- package/docs/blocks/claims.md +61 -0
- package/docs/blocks/conformance-admission.md +15 -0
- package/docs/blocks/will-not-do.md +18 -0
- package/docs/coauthor-session.md +57 -0
- package/docs/connected-composition.md +75 -0
- package/docs/continuity.md +3 -4
- package/docs/decisions.md +167 -0
- package/docs/design.md +167 -0
- package/docs/exact-upgrades.md +159 -0
- package/docs/extension-pack-lifecycle.md +33 -0
- package/docs/guided-upgrades.md +99 -0
- package/docs/install.md +99 -16
- package/docs/intake-and-guides.md +65 -0
- package/docs/integration-and-review-plan.md +409 -0
- package/docs/integration-contract-decisions.md +22 -0
- package/docs/knowledge-graph.md +8 -4
- package/docs/local-review.md +84 -0
- package/docs/local-services.md +328 -0
- package/docs/local-state.md +107 -0
- package/docs/obsidian-contract.md +698 -0
- package/docs/obsidian.md +484 -0
- package/docs/portable-presentation.md +328 -0
- package/docs/presentation-consumer-boundaries.md +75 -0
- package/docs/presentation-review-disposition.md +47 -0
- package/docs/project-command-inventory.md +38 -0
- package/docs/project-options.md +53 -0
- package/docs/release-engineering.md +174 -12
- package/docs/repo-boundary-guard.md +12 -2
- package/docs/review-portability.md +55 -0
- package/docs/skill-steward.md +156 -0
- package/docs/upgrade.md +155 -5
- package/docs/vault-service.md +292 -0
- package/fixtures/atelier-coauthor/invalid/authority.v1.json +5 -0
- package/fixtures/atelier-coauthor/valid/config.v1.json +12 -0
- package/fixtures/atelier-guide/invalid/authority.v1.json +11 -0
- package/fixtures/atelier-guide/valid/capability.v1.json +10 -0
- package/fixtures/atelier-guide/valid/consent.v1.json +11 -0
- package/fixtures/atelier-guide/valid/engagement.v1.json +7 -0
- package/fixtures/atelier-guide/valid/offer.v1.json +10 -0
- package/fixtures/atelier-intake/invalid/authority.v1.json +9 -0
- package/fixtures/atelier-intake/valid/attempt.v1.json +8 -0
- package/fixtures/atelier-intake/valid/completion.v1.json +9 -0
- package/fixtures/atelier-intake/valid/source.v1.json +7 -0
- package/fixtures/atelier-repository-observation/invalid/complete-with-blocker.v1.json +18 -0
- package/fixtures/atelier-repository-observation/valid/complete-local.v1.json +48 -0
- package/fixtures/atelier-review/invalid/authenticated-identity.v1.json +22 -0
- package/fixtures/atelier-review/valid/bound.v1.json +229 -0
- package/fixtures/atelier-review/valid/bundle.v1.json +267 -0
- package/fixtures/atelier-review/valid/contribution.v1.json +22 -0
- package/fixtures/atelier-review/valid/lifecycle.v1.json +14 -0
- package/fixtures/atelier-skill-steward/audit/invalid/source-mutation.v1.json +26 -0
- package/fixtures/atelier-skill-steward/audit/valid/clean.v1.json +26 -0
- package/fixtures/atelier-skill-steward/candidates/invalid/workflow-key.v1.json +37 -0
- package/fixtures/atelier-skill-steward/candidates/valid/create.v1.json +37 -0
- package/fixtures/atelier-skill-steward/lock/invalid/bad-digest.v1.json +18 -0
- package/fixtures/atelier-skill-steward/lock/valid/installed.v1.json +23 -0
- package/fixtures/atelier-skill-steward/plan/invalid/delete-action.v1.json +33 -0
- package/fixtures/atelier-skill-steward/plan/valid/add.v1.json +33 -0
- package/fixtures/atelier-upgrade-transaction/adoption-policy/invalid/example.json +12 -0
- package/fixtures/atelier-upgrade-transaction/adoption-policy/valid/example.json +11 -0
- package/fixtures/atelier-upgrade-transaction/migration/invalid/example.json +20 -0
- package/fixtures/atelier-upgrade-transaction/migration/valid/example.json +19 -0
- package/fixtures/atelier-upgrade-transaction/upgrade-plan/invalid/example.json +58 -0
- package/fixtures/atelier-upgrade-transaction/upgrade-plan/valid/example.json +57 -0
- package/fixtures/atelier-upgrade-transaction/upgrade-receipt/invalid/example.json +15 -0
- package/fixtures/atelier-upgrade-transaction/upgrade-receipt/valid/example.json +14 -0
- package/fixtures/atelier-vault-publication/invalid/publication.json +5 -0
- package/fixtures/atelier-vault-publication/valid/publication.json +11 -0
- package/fixtures/decisions/request/invalid/unknown-authority.v1.json +61 -0
- package/fixtures/decisions/request/valid/triage.v1.json +60 -0
- package/fixtures/decisions/result/invalid/execution-authority.v1.json +50 -0
- package/fixtures/decisions/result/valid/abstained.v1.json +23 -0
- package/fixtures/decisions/result/valid/assessed.v1.json +50 -0
- package/fixtures/obsidian/acceptance/ap05-extra-notes.json +14 -0
- package/fixtures/obsidian/acceptance/receipts/G07.valid.v1.json +63 -0
- package/fixtures/obsidian/acceptance/receipts/G13.valid.v1.json +69 -0
- package/fixtures/obsidian/acceptance/receipts/G14.valid.v1.json +62 -0
- package/fixtures/obsidian/acceptance/receipts/G15.valid.v1.json +56 -0
- package/fixtures/obsidian/acceptance/receipts/G16.valid.v1.json +73 -0
- package/fixtures/obsidian/acceptance/receipts/G17.valid.v1.json +75 -0
- package/fixtures/obsidian/acceptance/receipts/G18.valid.v1.json +64 -0
- package/fixtures/obsidian/acceptance/service-sentinels.json +10 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/duplicate-evidence-name.v1.json +39 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/evidence-by-absolute-path.v1.json +34 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/missing-candidate-tree.v1.json +33 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/no-evidence.v1.json +28 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/unknown-outcome.v1.json +34 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/unknown-top-level-field.v1.json +35 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/valid/node-gate.v1.json +34 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/automatic-without-edit-class.v1.json +27 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/conflict-overwrite.v1.json +29 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/missing-policy-digest.v1.json +28 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unbounded-batch.v1.json +29 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unimplemented-edit-class.v1.json +30 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unknown-mode.v1.json +29 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unknown-selector-operator.v1.json +22 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unknown-top-level-field.v1.json +30 -0
- package/fixtures/obsidian/contracts/apply-policy/valid/automatic-scoped.v1.json +29 -0
- package/fixtures/obsidian/contracts/apply-policy/valid/manual-default.v1.json +20 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/absolute-path-in-ext.v1.json +30 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/absolute-repository-root.v1.json +27 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/duplicate-repository-id.v1.json +27 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/overlapping-managed-roots.v1.json +27 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/unknown-enrollment.v1.json +27 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/unknown-top-level-field.v1.json +28 -0
- package/fixtures/obsidian/contracts/corpus-profile/valid/three-repositories.v1.json +27 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/absolute-recovery-ref.v1.json +21 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/inline-observed-bytes.v1.json +22 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/missing-base-digest.v1.json +20 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/short-idempotency-key.v1.json +21 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/unknown-kind.v1.json +21 -0
- package/fixtures/obsidian/contracts/edit-operation/valid/pending-body-replacement.v1.json +21 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/absolute-path-prefix.v1.json +28 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/apply-policy-in-portable-settings.v1.json +30 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/duplicate-scope-id.v1.json +27 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/machine-local-vault-path.v1.json +28 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/service-port-in-portable-settings.v1.json +28 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/unknown-default-scope.v1.json +27 -0
- package/fixtures/obsidian/contracts/ext-settings/valid/disabled.v1.json +5 -0
- package/fixtures/obsidian/contracts/ext-settings/valid/enabled-with-scopes.v1.json +27 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/absolute-note-path.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/complete-with-unwritten-notes.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/derived-link-claimed-declared.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/duplicate-note-identity.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/in-scope-endpoint-missing.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/title-only-note-path.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/unknown-note-field.v1.json +115 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/unknown-relation-type.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/withheld-endpoint.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/valid/two-notes.v1.json +114 -0
- package/fixtures/obsidian/contracts/oracles/scope-cases.json +412 -0
- package/fixtures/obsidian/contracts/proposal-receipt/invalid/accepted-without-proposal-id.v1.json +12 -0
- package/fixtures/obsidian/contracts/proposal-receipt/invalid/missing-adapter-operation-id.v1.json +11 -0
- package/fixtures/obsidian/contracts/proposal-receipt/invalid/unknown-backpressure-outcome.v1.json +12 -0
- package/fixtures/obsidian/contracts/proposal-receipt/invalid/unknown-top-level-field.v1.json +13 -0
- package/fixtures/obsidian/contracts/proposal-receipt/valid/accepted-new.v1.json +12 -0
- package/fixtures/obsidian/contracts/proposal-receipt/valid/deferred.v1.json +12 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/absolute-recovery-ref.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/duplicate-sequence.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/empty-protocol-id.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/missing-protocol-id.v1.json +46 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/unknown-entry-field.v1.json +48 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/unknown-state.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/valid/committed.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/valid/updating-after-restart.v1.json +22 -0
- package/fixtures/obsidian/contracts/scope/invalid/absolute-path-prefix.v1.json +15 -0
- package/fixtures/obsidian/contracts/scope/invalid/duplicate-ids.v1.json +18 -0
- package/fixtures/obsidian/contracts/scope/invalid/expansion-without-node-budget.v1.json +40 -0
- package/fixtures/obsidian/contracts/scope/invalid/full-mode-with-subset.v1.json +8 -0
- package/fixtures/obsidian/contracts/scope/invalid/unknown-mode.v1.json +41 -0
- package/fixtures/obsidian/contracts/scope/invalid/unknown-selector-key.v1.json +15 -0
- package/fixtures/obsidian/contracts/scope/invalid/unknown-selector-operator.v1.json +14 -0
- package/fixtures/obsidian/contracts/scope/invalid/unknown-top-level-field.v1.json +42 -0
- package/fixtures/obsidian/contracts/scope/valid/explicit-empty.v1.json +8 -0
- package/fixtures/obsidian/contracts/scope/valid/focus.v1.json +11 -0
- package/fixtures/obsidian/contracts/scope/valid/full.v1.json +8 -0
- package/fixtures/obsidian/contracts/scope/valid/scoped-set-expression.v1.json +41 -0
- package/fixtures/obsidian/contracts/service-state/invalid/hostname-instead-of-literal-loopback.v1.json +23 -0
- package/fixtures/obsidian/contracts/service-state/invalid/missing-consent.v1.json +18 -0
- package/fixtures/obsidian/contracts/service-state/invalid/privileged-port.v1.json +23 -0
- package/fixtures/obsidian/contracts/service-state/invalid/unknown-top-level-field.v1.json +24 -0
- package/fixtures/obsidian/contracts/service-state/invalid/wildcard-bind.v1.json +23 -0
- package/fixtures/obsidian/contracts/service-state/valid/healthy.v1.json +23 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/absolute-file-path.v1.json +48 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/duplicate-repository-id.v1.json +48 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/mixed-read.v1.json +48 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/parent-traversal-path.v1.json +48 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/unknown-file-field.v1.json +49 -0
- package/fixtures/obsidian/contracts/source-snapshot/valid/two-repositories.v1.json +48 -0
- package/fixtures/obsidian/edits/workspace.json +65 -0
- package/fixtures/obsidian/materialization/expected-full.json +99 -0
- package/fixtures/obsidian/materialization/expected-scoped.json +39 -0
- package/fixtures/obsidian/materialization/workspace.json +54 -0
- package/fixtures/obsidian/proposals/expected-shapes.json +11 -0
- package/fixtures/projects/sample-workspace/content/source.html.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/data.json.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/logo.png.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/metrics.csv.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/pipeline.yaml.kg.json +4 -1
- package/fixtures/ui/presentation/pane.v1.json +7 -0
- package/fixtures/ui/presentation/reference.v1.json +293 -0
- package/package.json +86 -10
- package/skills/claude/atelier-guided-coauthor/SKILL.md +49 -0
- package/skills/claude/atelier-guided-upgrade/SKILL.md +97 -0
- package/skills/claude/atelier-local-service/SKILL.md +47 -0
- package/skills/claude/atelier-open/SKILL.md +11 -5
- package/skills/claude/atelier-public-boundary/SKILL.md +31 -0
- package/skills/claude/atelier-skill-steward/SKILL.md +62 -0
- package/skills/claude/mnstry-readiness/SKILL.md +5 -0
- package/skills/codex/atelier-guided-coauthor/SKILL.md +49 -0
- package/skills/codex/atelier-guided-upgrade/SKILL.md +97 -0
- package/skills/codex/atelier-local-service/SKILL.md +47 -0
- package/skills/codex/atelier-open/SKILL.md +11 -5
- package/skills/codex/atelier-public-boundary/SKILL.md +31 -0
- package/skills/codex/atelier-skill-steward/SKILL.md +62 -0
- package/skills/codex/mnstry-readiness/SKILL.md +5 -0
- package/src/access/preview-enforcer.mjs +84 -0
- package/src/boundary/content-rules.mjs +283 -20
- package/src/boundary/policy.mjs +213 -91
- package/src/cli/execute-command.mjs +36 -0
- package/src/cli/project-options.mjs +58 -0
- package/src/cli/run.mjs +78 -10
- package/src/coauthor/session.mjs +161 -0
- package/src/coauthor/store.mjs +173 -0
- package/src/collaboration/event-ledger.mjs +348 -0
- package/src/collaboration/index.mjs +17 -0
- package/src/collaboration/inspection-bundle.mjs +223 -0
- package/src/collaboration/proposals.mjs +265 -65
- package/src/collaboration/review-contracts.mjs +25 -0
- package/src/collaboration/review-store.mjs +305 -0
- package/src/commands/attestation.mjs +20 -6
- package/src/commands/coauthor.mjs +26 -0
- package/src/commands/config.mjs +6 -1
- package/src/commands/disclosure.mjs +133 -0
- package/src/commands/distribution.mjs +2 -1
- package/src/commands/extension-pack.mjs +17 -9
- package/src/commands/init.mjs +46 -6
- package/src/commands/obsidian.mjs +371 -0
- package/src/commands/review.mjs +147 -0
- package/src/commands/server.mjs +1 -4
- package/src/commands/setup.mjs +51 -14
- package/src/commands/skills.mjs +199 -0
- package/src/commands/sync.mjs +107 -0
- package/src/composition/registry.mjs +27 -0
- package/src/composition/wire.mjs +122 -0
- package/src/contracts/corpus.mjs +35 -0
- package/src/decisions/contracts.d.mts +96 -0
- package/src/decisions/contracts.mjs +321 -0
- package/src/disclosure/content-scan.mjs +206 -0
- package/src/egress/check.mjs +7 -38
- package/src/egress/forbidden-egress.mjs +32 -18
- package/src/export/atelier-export-contract.mjs +16 -1
- package/src/extension-packs/lifecycle.mjs +154 -0
- package/src/graph/graph.mjs +176 -316
- package/src/graph/knowledge-graph.mjs +643 -43
- package/src/guides/contracts.mjs +54 -0
- package/src/harness/context-client.mjs +9 -1
- package/src/index.mjs +41 -0
- package/src/intake/store.mjs +119 -0
- package/src/preview/channel.mjs +89 -0
- package/src/project/config.mjs +112 -52
- package/src/project/durable-state.mjs +161 -0
- package/src/project/file-class.mjs +180 -0
- package/src/project/package-root.mjs +10 -0
- package/src/project/path-match.mjs +38 -15
- package/src/project/private-state.mjs +120 -0
- package/src/projection/obsidian/contracts.mjs +571 -0
- package/src/projection/obsidian/edits/align.mjs +169 -0
- package/src/projection/obsidian/edits/apply.mjs +889 -0
- package/src/projection/obsidian/edits/arbitrate.mjs +414 -0
- package/src/projection/obsidian/edits/contribution.mjs +108 -0
- package/src/projection/obsidian/edits/index.mjs +19 -0
- package/src/projection/obsidian/edits/object-identity.mjs +61 -0
- package/src/projection/obsidian/edits/object-store.mjs +517 -0
- package/src/projection/obsidian/edits/observe.mjs +123 -0
- package/src/projection/obsidian/edits/policy.mjs +123 -0
- package/src/projection/obsidian/edits/regions.mjs +648 -0
- package/src/projection/obsidian/materialize/byte-lens.mjs +98 -0
- package/src/projection/obsidian/materialize/index.mjs +7 -0
- package/src/projection/obsidian/materialize/path-registry.mjs +105 -0
- package/src/projection/obsidian/materialize/prepare-view.mjs +746 -0
- package/src/projection/obsidian/materialize/settings.mjs +57 -0
- package/src/projection/obsidian/materialize/stage.mjs +27 -0
- package/src/projection/obsidian/proposals/adapter.mjs +572 -0
- package/src/projection/obsidian/proposals/backpressure.mjs +113 -0
- package/src/projection/obsidian/proposals/contribution.mjs +55 -0
- package/src/projection/obsidian/proposals/index.mjs +23 -0
- package/src/projection/obsidian/proposals/observation.mjs +216 -0
- package/src/projection/obsidian/proposals/queue.mjs +277 -0
- package/src/projection/obsidian/proposals/router.mjs +168 -0
- package/src/projection/obsidian/publication/bridge-script.mjs +266 -0
- package/src/projection/obsidian/publication/exchange.mjs +117 -0
- package/src/projection/obsidian/publication/index.mjs +5 -0
- package/src/projection/obsidian/publication/publisher.mjs +588 -0
- package/src/projection/obsidian/publication/test-seam.mjs +16 -0
- package/src/projection/obsidian/publication/transport.mjs +212 -0
- package/src/projection/obsidian/recovery/index.mjs +6 -0
- package/src/projection/obsidian/recovery/journal.mjs +134 -0
- package/src/projection/obsidian/recovery/late-writer.mjs +46 -0
- package/src/projection/obsidian/recovery/restart.mjs +316 -0
- package/src/projection/obsidian/recovery/store.mjs +234 -0
- package/src/projection/obsidian/selection-ui/conflict-view.mjs +91 -0
- package/src/projection/obsidian/selection-ui/contribution.mjs +141 -0
- package/src/projection/obsidian/selection-ui/focus.mjs +82 -0
- package/src/projection/obsidian/selection-ui/index.mjs +12 -0
- package/src/projection/obsidian/selection-ui/policy-setup.mjs +107 -0
- package/src/projection/obsidian/selection-ui/receipt.mjs +173 -0
- package/src/projection/obsidian/selection-ui/selection-state.mjs +122 -0
- package/src/projection/obsidian/selection-ui/selection.mjs +109 -0
- package/src/projection/project.mjs +28 -19
- package/src/readiness-protocols/evidence.mjs +282 -0
- package/src/readiness-protocols/runtime.mjs +4 -3
- package/src/readiness-protocols/source-read.mjs +39 -0
- package/src/runtime/git-adapter.mjs +189 -0
- package/src/runtime/local-state.mjs +439 -0
- package/src/runtime/obsidian/app-capability.mjs +138 -0
- package/src/runtime/obsidian/app-production-seams.mjs +107 -0
- package/src/runtime/obsidian/contributions/proposal-adapter.mjs +4 -0
- package/src/runtime/obsidian/contributions/selection-ui.mjs +4 -0
- package/src/runtime/obsidian/contributions/source-apply.mjs +4 -0
- package/src/runtime/obsidian/contributions.mjs +27 -0
- package/src/runtime/obsidian/documents.mjs +37 -0
- package/src/runtime/obsidian/enablement.mjs +53 -0
- package/src/runtime/obsidian/engine.mjs +532 -0
- package/src/runtime/obsidian/errors.mjs +14 -0
- package/src/runtime/obsidian/extension-points.mjs +103 -0
- package/src/runtime/obsidian/index.mjs +34 -0
- package/src/runtime/obsidian/lifecycle.mjs +258 -0
- package/src/runtime/obsidian/machine-settings.mjs +260 -0
- package/src/runtime/obsidian/observation.mjs +158 -0
- package/src/runtime/obsidian/opening.mjs +280 -0
- package/src/runtime/obsidian/pending-edits.mjs +141 -0
- package/src/runtime/obsidian/pipeline.mjs +122 -0
- package/src/runtime/obsidian/private-lock.mjs +156 -0
- package/src/runtime/obsidian/process-identity.mjs +58 -0
- package/src/runtime/obsidian/service-client.mjs +66 -0
- package/src/runtime/obsidian/service-entry-path.mjs +9 -0
- package/src/runtime/obsidian/service-main.mjs +93 -0
- package/src/runtime/obsidian/service-record.mjs +169 -0
- package/src/runtime/obsidian/service-server.mjs +121 -0
- package/src/runtime/obsidian/service.mjs +216 -0
- package/src/runtime/obsidian/startup-adapters.mjs +87 -0
- package/src/runtime/obsidian/state-store.mjs +180 -0
- package/src/runtime/obsidian/sync-notice.mjs +33 -0
- package/src/runtime/obsidian/tick-loop.mjs +84 -0
- package/src/runtime/obsidian/watchers.mjs +36 -0
- package/src/runtime/repository-observation.mjs +491 -0
- package/src/runtime/supervisor.mjs +803 -0
- package/src/server/local-sidecar.mjs +125 -59
- package/src/server/security.mjs +89 -4
- package/src/server/server.mjs +4 -2
- package/src/skills/steward.mjs +780 -0
- package/src/support/feedback-report.mjs +4 -3
- package/src/ui/presentation/browser.mjs +278 -0
- package/src/ui/presentation/contract.mjs +116 -0
- package/src/ui/presentation/index.mjs +7 -0
- package/src/ui/presentation/native.mjs +153 -0
- package/src/ui/presentation/proof.mjs +57 -0
- package/src/ui/presentation/schema-check.mjs +30 -0
- package/src/ui/presentation/schema.generated.mjs +1371 -0
- package/src/ui/presentation/state.mjs +43 -0
- package/src/ui/presentation/styles.mjs +67 -0
- package/src/ui/presentation/tokens.mjs +74 -0
- package/src/ui/presentation/web.mjs +85 -0
- package/src/ui/review-page.mjs +32 -0
- package/src/upgrade/explanation.mjs +33 -0
- package/src/upgrade/provenance.mjs +338 -0
- package/src/upgrade/transaction-files.mjs +103 -0
- package/src/upgrade/transaction.mjs +475 -0
- package/src/upgrade/upgrade.mjs +65 -29
- package/src/vault/hosts.mjs +21 -0
- package/src/vault/identity.mjs +19 -0
- package/src/vault/index.mjs +7 -0
- package/src/vault/interface.mjs +11 -0
- package/src/vault/metadata.mjs +31 -0
- package/src/vault/privacy.mjs +148 -0
- package/src/vault/probe.mjs +89 -0
- package/src/vault/service.mjs +131 -0
- package/src/vault/source.mjs +45 -0
- package/src/vault/storage.mjs +23 -0
- package/templates/distribution-workspace/.claude/launch.json +6 -2
- package/templates/distribution-workspace/gitignore +1 -0
- package/templates/distribution-workspace/project/README.md +2 -2
- package/templates/external-project-workspace/README.md +45 -0
- package/templates/external-project-workspace/answers.example.json +4 -0
- package/templates/external-project-workspace/atelier.project.json +40 -0
- package/templates/external-project-workspace/boundary-policy.v1.json +60 -0
- package/templates/external-project-workspace/gitignore +8 -0
- package/templates/external-project-workspace/pack-lifecycle.json +14 -0
- package/templates/external-project-workspace/packs/protocols/contract-gate.v1.json +109 -0
- package/templates/external-project-workspace/packs/sample-pack.v1.json +48 -0
- package/templates/external-project-workspace/repo-access.v1.json +9 -0
- package/templates/external-project-workspace/source/README.md +11 -0
- package/templates/launch.json +6 -2
- package/templates/private-domain-workspace/.claude/launch.json +6 -2
- package/templates/private-domain-workspace/domain/README.md +2 -2
- package/templates/private-domain-workspace/gitignore +1 -0
- package/templates/shared-project-workspace/.claude/launch.json +6 -2
- package/templates/shared-project-workspace/gitignore +1 -0
- package/templates/shared-project-workspace/project/README.md +2 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { canonicalize } from '../attestation/jcs.mjs';
|
|
4
|
+
import { validateJsonSchema } from '../export/atelier-export-contract.mjs';
|
|
5
|
+
|
|
6
|
+
const schema = JSON.parse(fs.readFileSync(new URL('../../contracts/atelier-guide.v1.schema.json', import.meta.url), 'utf8'));
|
|
7
|
+
export function guideDocumentDigest(value) { return createHash('sha256').update(canonicalize(value)).digest('hex'); }
|
|
8
|
+
export function validateGuideDocument(value, kind) {
|
|
9
|
+
if (!['offer', 'capability', 'consent', 'engagement'].includes(kind)) return ['unknown guide document kind'];
|
|
10
|
+
const errors = validateJsonSchema({ $schema: schema.$schema, $defs: schema.$defs, $ref: `#/$defs/${kind}` }, value);
|
|
11
|
+
if (kind === 'capability' && !errors.length) {
|
|
12
|
+
const url = new URL(value.serviceRef);
|
|
13
|
+
if (url.username || url.password || url.search || url.hash) errors.push('service reference must not contain credentials, query or fragment');
|
|
14
|
+
}
|
|
15
|
+
return errors;
|
|
16
|
+
}
|
|
17
|
+
function requireValid(value, kind) {
|
|
18
|
+
if (validateGuideDocument(value, kind).length) throw new Error(`invalid guide ${kind}`);
|
|
19
|
+
}
|
|
20
|
+
export function createGuideEngagement(offer) {
|
|
21
|
+
requireValid(offer, 'offer');
|
|
22
|
+
return { schema: 'mnstry.atelier-guide-engagement@v1', offerDigest: guideDocumentDigest(offer),
|
|
23
|
+
revision: 0, status: 'proposed', authority: 'local-assertion-only' };
|
|
24
|
+
}
|
|
25
|
+
export function transitionGuideEngagement(state, { expectedRevision, action, offerDigest }) {
|
|
26
|
+
requireValid(state, 'engagement');
|
|
27
|
+
if (expectedRevision !== state.revision || offerDigest !== state.offerDigest) throw new Error('stale or mismatched guide engagement');
|
|
28
|
+
const routes = { proposed: { accept: 'accepted', revoke: 'revoked' }, accepted: { pause: 'paused', revoke: 'revoked' }, paused: { resume: 'accepted', revoke: 'revoked' }, revoked: {} };
|
|
29
|
+
const status = Object.hasOwn(routes[state.status], action) ? routes[state.status][action] : null;
|
|
30
|
+
if (!status) throw new Error('guide transition refused');
|
|
31
|
+
return { ...state, revision: state.revision + 1, status };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// No connection, credentials, invocation, payment, or permission grant occurs.
|
|
35
|
+
// A host must independently authenticate participants and revalidate revocation,
|
|
36
|
+
// consent, policy, schema and exact bytes immediately before any disclosure.
|
|
37
|
+
export function assessGuideInvocation({ offer, capability, engagement, consent, payload, now }) {
|
|
38
|
+
const blockers = [];
|
|
39
|
+
for (const [kind, value] of Object.entries({ offer, capability, engagement, consent })) {
|
|
40
|
+
if (validateGuideDocument(value, kind).length) blockers.push(`invalid ${kind}`);
|
|
41
|
+
}
|
|
42
|
+
if (blockers.length) return { status: 'blocked', blockers, executionAuthority: false };
|
|
43
|
+
let bytes;
|
|
44
|
+
try { bytes = canonicalize(payload); } catch { blockers.push('payload is not canonical JSON'); }
|
|
45
|
+
if (!Number.isFinite(now)) blockers.push('explicit current time required');
|
|
46
|
+
if (engagement.status !== 'accepted') blockers.push('engagement is not accepted');
|
|
47
|
+
if (engagement.offerDigest !== guideDocumentDigest(offer) || consent.offerDigest !== engagement.offerDigest) blockers.push('offer binding mismatch');
|
|
48
|
+
if (consent.engagementRevision !== engagement.revision) blockers.push('consent revision is stale');
|
|
49
|
+
if (!offer.capabilityIds.includes(capability.id) || consent.capabilityDigest !== guideDocumentDigest(capability)) blockers.push('capability binding mismatch');
|
|
50
|
+
if (consent.status !== 'approved') blockers.push('disclosure consent is not approved');
|
|
51
|
+
if (now < Date.parse(consent.validFrom) || now >= Date.parse(consent.expiresAt) || Date.parse(consent.validFrom) >= Date.parse(consent.expiresAt)) blockers.push('consent is not currently valid');
|
|
52
|
+
if (bytes !== undefined && (Buffer.byteLength(bytes) > capability.maxInputBytes || guideDocumentDigest(payload) !== consent.payloadDigest)) blockers.push('payload binding or byte limit mismatch');
|
|
53
|
+
return { status: blockers.length ? 'blocked' : 'eligible-for-host-validation', blockers, executionAuthority: false };
|
|
54
|
+
}
|
|
@@ -39,7 +39,13 @@ export async function jsonGet(baseUrl, route, params = null, headers = {}) {
|
|
|
39
39
|
const url = new URL(route, `${base.href}/`)
|
|
40
40
|
if (params) appendParams(url, params)
|
|
41
41
|
// @atelier-egress-local-computed
|
|
42
|
-
const response = await fetch(url, {
|
|
42
|
+
const response = await fetch(url, {
|
|
43
|
+
headers: {
|
|
44
|
+
Origin: base.origin,
|
|
45
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
46
|
+
...headers,
|
|
47
|
+
},
|
|
48
|
+
})
|
|
43
49
|
return readJsonResponse(response, route)
|
|
44
50
|
}
|
|
45
51
|
|
|
@@ -51,6 +57,8 @@ export async function jsonPost(baseUrl, route, body = {}, headers = {}) {
|
|
|
51
57
|
method: 'POST',
|
|
52
58
|
headers: {
|
|
53
59
|
'Content-Type': 'application/json',
|
|
60
|
+
Origin: base.origin,
|
|
61
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
54
62
|
...headers,
|
|
55
63
|
},
|
|
56
64
|
body: JSON.stringify(body),
|
package/src/index.mjs
CHANGED
|
@@ -52,6 +52,12 @@ export {
|
|
|
52
52
|
contextEnvelope,
|
|
53
53
|
} from './harness/context.mjs'
|
|
54
54
|
|
|
55
|
+
export {
|
|
56
|
+
ATELIER_COLLABORATION_EVENT_SCHEMA,
|
|
57
|
+
createCollaborationEventLedger,
|
|
58
|
+
validateCollaborationEvent,
|
|
59
|
+
} from './collaboration/index.mjs'
|
|
60
|
+
|
|
55
61
|
export {
|
|
56
62
|
buildSupportBundlePreview,
|
|
57
63
|
validateSupportBundlePayload,
|
|
@@ -61,6 +67,12 @@ export {
|
|
|
61
67
|
checkForbiddenEgress,
|
|
62
68
|
} from './egress/forbidden-egress.mjs'
|
|
63
69
|
|
|
70
|
+
export {
|
|
71
|
+
STRUCTURAL_DISCLOSURE_PATTERNS,
|
|
72
|
+
compileDisclosurePatterns,
|
|
73
|
+
scanDisclosureContent,
|
|
74
|
+
} from './disclosure/content-scan.mjs'
|
|
75
|
+
|
|
64
76
|
export {
|
|
65
77
|
BOUNDARY_POLICY_SCHEMA,
|
|
66
78
|
checkBoundaryPolicy,
|
|
@@ -86,3 +98,32 @@ export {
|
|
|
86
98
|
export {
|
|
87
99
|
analysisAdapterDryRun,
|
|
88
100
|
} from './analysis/adapter.mjs'
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
GitCommandError,
|
|
104
|
+
classifyRemoteAuthentication,
|
|
105
|
+
inspectGitEngine,
|
|
106
|
+
parseGitVersion,
|
|
107
|
+
resolveGitExecutable,
|
|
108
|
+
runGit,
|
|
109
|
+
sanitizeRemoteUrl,
|
|
110
|
+
} from './runtime/git-adapter.mjs'
|
|
111
|
+
|
|
112
|
+
export {
|
|
113
|
+
ATELIER_REPOSITORY_OBSERVATION_SCHEMA,
|
|
114
|
+
classifyFilesystemRoot,
|
|
115
|
+
observeRepository,
|
|
116
|
+
resolveRepositoryRoot,
|
|
117
|
+
validateRepositoryObservation,
|
|
118
|
+
} from './runtime/repository-observation.mjs'
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
ATELIER_COMMIT_PLAN_SCHEMA,
|
|
122
|
+
enrollRepository,
|
|
123
|
+
executeUserConfirmedCommit,
|
|
124
|
+
operationTrace,
|
|
125
|
+
planUserConfirmedCommit,
|
|
126
|
+
reconcileRepository,
|
|
127
|
+
runtimeStatus,
|
|
128
|
+
setRepositoryPaused,
|
|
129
|
+
} from './runtime/supervisor.mjs'
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { withPrivateLock, publishPrivateFile } from '../project/durable-state.mjs';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { execFileSync } from 'node:child_process';
|
|
6
|
+
import { canonicalize } from '../attestation/jcs.mjs';
|
|
7
|
+
import { validateJsonSchema } from '../export/atelier-export-contract.mjs';
|
|
8
|
+
import { ensureContainedPrivateDirectory, openRegularFileNoFollow } from '../project/private-state.mjs';
|
|
9
|
+
|
|
10
|
+
export const INTAKE_MAX_BYTES = 16 * 1024 * 1024;
|
|
11
|
+
const schema = JSON.parse(fs.readFileSync(new URL('../../contracts/atelier-intake.v1.schema.json', import.meta.url), 'utf8'));
|
|
12
|
+
export function validateIntakeDocument(value) { return validateJsonSchema(schema, value); }
|
|
13
|
+
function valid(value) { if (validateIntakeDocument(value).length) throw new Error('invalid intake document'); return value; }
|
|
14
|
+
export function intakeDigest(bytes) { return createHash('sha256').update(bytes).digest('hex'); }
|
|
15
|
+
const idPattern = /^[a-z][a-z0-9-]{0,63}$/;
|
|
16
|
+
const digestPattern = /^[0-9a-f]{64}$/;
|
|
17
|
+
function digest(value) { if (!digestPattern.test(value ?? '')) throw new Error('invalid content digest'); return value; }
|
|
18
|
+
function id(value) { if (!idPattern.test(value ?? '')) throw new Error('invalid intake identifier'); return value; }
|
|
19
|
+
function read(file) {
|
|
20
|
+
const fd = openRegularFileNoFollow(file);
|
|
21
|
+
try {
|
|
22
|
+
if (fs.fstatSync(fd).size > INTAKE_MAX_BYTES) throw new Error('intake byte ceiling exceeded');
|
|
23
|
+
const bytes = fs.readFileSync(fd);
|
|
24
|
+
if (bytes.length > INTAKE_MAX_BYTES) throw new Error('intake byte ceiling exceeded');
|
|
25
|
+
return bytes;
|
|
26
|
+
} finally { fs.closeSync(fd); }
|
|
27
|
+
}
|
|
28
|
+
function immutable(file, bytes) {
|
|
29
|
+
publishPrivateFile(file, bytes);
|
|
30
|
+
if (!read(file).equals(Buffer.from(bytes))) throw new Error('immutable intake readback mismatch');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Local integrity storage, not a worker, semantic acceptance service, or import
|
|
34
|
+
// authority. Callers retain their source trees and choose their existing extractor.
|
|
35
|
+
export function createIntakeStore({ workspaceRoot = process.cwd() } = {}) {
|
|
36
|
+
const root = fs.realpathSync(workspaceRoot);
|
|
37
|
+
function placement() {
|
|
38
|
+
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.toUpperCase().startsWith('GIT_')));
|
|
39
|
+
try {
|
|
40
|
+
if (execFileSync('git', ['-C', root, 'ls-files', '-z', '--', '.atelier-local'], { env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] })) throw new Error('tracked state');
|
|
41
|
+
execFileSync('git', ['-C', root, 'check-ignore', '--quiet', '.atelier-local/'], { env, stdio: 'ignore' });
|
|
42
|
+
} catch { throw new Error('intake requires ignored, untracked .atelier-local/ in a Git workspace'); }
|
|
43
|
+
}
|
|
44
|
+
placement();
|
|
45
|
+
function directory(...parts) {
|
|
46
|
+
return ensureContainedPrivateDirectory({ workspaceRoot: root, directory: path.join(root, '.atelier-local', 'intake', ...parts), label: 'intake state' });
|
|
47
|
+
}
|
|
48
|
+
function locked(fn) {
|
|
49
|
+
placement();
|
|
50
|
+
const file = path.join(directory(), 'operation.lock');
|
|
51
|
+
return withPrivateLock(file, fn);
|
|
52
|
+
}
|
|
53
|
+
function sourceFile(ref) {
|
|
54
|
+
if (typeof ref !== 'string' || !ref || path.isAbsolute(ref) || ref.includes('\\') ||
|
|
55
|
+
ref.split('/').some(p => !p || p === '.' || p === '..' || p.startsWith('.'))) throw new Error('source must be a visible workspace-relative file');
|
|
56
|
+
let file = root;
|
|
57
|
+
for (const part of ref.split('/')) {
|
|
58
|
+
file = path.join(file, part);
|
|
59
|
+
if (fs.lstatSync(file).isSymbolicLink()) throw new Error('redirected intake source refused');
|
|
60
|
+
}
|
|
61
|
+
return file;
|
|
62
|
+
}
|
|
63
|
+
function blob(blobId) {
|
|
64
|
+
const bytes = read(path.join(directory('blobs'), digest(blobId)));
|
|
65
|
+
if (intakeDigest(bytes) !== blobId) throw new Error('stored blob digest mismatch');
|
|
66
|
+
return bytes;
|
|
67
|
+
}
|
|
68
|
+
function record(dir, name, value) { valid(value); immutable(path.join(dir, name), canonicalize(value) + '\n'); return value; }
|
|
69
|
+
return Object.freeze({
|
|
70
|
+
ingest({ ref, expectedDigest }) {
|
|
71
|
+
return locked(() => {
|
|
72
|
+
digest(expectedDigest);
|
|
73
|
+
const file = sourceFile(ref), bytes = read(file);
|
|
74
|
+
if (intakeDigest(bytes) !== expectedDigest) throw new Error('source digest mismatch');
|
|
75
|
+
immutable(path.join(directory('blobs'), expectedDigest), bytes);
|
|
76
|
+
if (intakeDigest(read(sourceFile(ref))) !== expectedDigest) throw new Error('source changed during intake');
|
|
77
|
+
const manifest = { schema: 'mnstry.atelier-intake-source@v1', sourceRef: ref, blobId: expectedDigest, bytes: bytes.length, originalMutation: false };
|
|
78
|
+
return record(directory('sources'), intakeDigest(canonicalize(manifest)) + '.json', manifest);
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
beginAttempt({ attemptId, blobId, extractorId, extractorVersion, configurationDigest }) {
|
|
82
|
+
return locked(() => {
|
|
83
|
+
id(attemptId); id(extractorId); digest(configurationDigest); blob(blobId);
|
|
84
|
+
if (typeof extractorVersion !== 'string' || !/^[a-zA-Z0-9._-]{1,64}$/.test(extractorVersion)) throw new Error('invalid extractor version');
|
|
85
|
+
const manifest = { schema: 'mnstry.atelier-intake-attempt@v1', attemptId, blobId, extractorId, extractorVersion, configurationDigest };
|
|
86
|
+
return record(directory('attempts', attemptId), 'attempt.json', manifest);
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
completeAttempt({ attemptId, output, expectedOutputDigest }) {
|
|
90
|
+
return locked(() => {
|
|
91
|
+
id(attemptId); digest(expectedOutputDigest);
|
|
92
|
+
if (typeof output !== 'string' || Buffer.byteLength(output) > INTAKE_MAX_BYTES) throw new Error('output must be bounded UTF-8 text');
|
|
93
|
+
if (intakeDigest(output) !== expectedOutputDigest) throw new Error('output digest mismatch');
|
|
94
|
+
const dir = directory('attempts', attemptId);
|
|
95
|
+
const attemptBytes = read(path.join(dir, 'attempt.json'));
|
|
96
|
+
const attempt = valid(JSON.parse(attemptBytes));
|
|
97
|
+
if (attempt.attemptId !== attemptId || attempt.schema !== 'mnstry.atelier-intake-attempt@v1') throw new Error('attempt identity mismatch');
|
|
98
|
+
blob(attempt.blobId);
|
|
99
|
+
immutable(path.join(dir, 'output.txt'), output);
|
|
100
|
+
// Completion is written last. A crash before it is incomplete, not success.
|
|
101
|
+
return record(dir, 'completion.json', { schema: 'mnstry.atelier-intake-completion@v1', attemptId,
|
|
102
|
+
attemptDigest: intakeDigest(attemptBytes), outputDigest: expectedOutputDigest, bytes: Buffer.byteLength(output),
|
|
103
|
+
integrity: 'verified', semanticAcceptance: 'pending' });
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
readCompletion(attemptId) {
|
|
107
|
+
placement(); id(attemptId);
|
|
108
|
+
const dir = directory('attempts', attemptId), receipt = valid(JSON.parse(read(path.join(dir, 'completion.json'))));
|
|
109
|
+
if (receipt.schema !== 'mnstry.atelier-intake-completion@v1' || receipt.attemptId !== attemptId ||
|
|
110
|
+
receipt.integrity !== 'verified' || receipt.semanticAcceptance !== 'pending') throw new Error('invalid completion receipt');
|
|
111
|
+
const attemptBytes = read(path.join(dir, 'attempt.json')), output = read(path.join(dir, 'output.txt'));
|
|
112
|
+
if (intakeDigest(attemptBytes) !== receipt.attemptDigest || intakeDigest(output) !== receipt.outputDigest || output.length !== receipt.bytes) throw new Error('completion integrity mismatch');
|
|
113
|
+
const attempt = valid(JSON.parse(attemptBytes));
|
|
114
|
+
if (attempt.attemptId !== attemptId || attempt.schema !== 'mnstry.atelier-intake-attempt@v1') throw new Error('attempt identity mismatch');
|
|
115
|
+
blob(attempt.blobId);
|
|
116
|
+
return receipt;
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Browser-only channel. Host/session/service authority never enters this module.
|
|
2
|
+
import { parseRequest, parseBoundedJSON, closed, need, isRef, isDigest, MODES } from '../composition/wire.mjs';
|
|
3
|
+
const HELLO = 'atelier.preview.mount/experimental-v1';
|
|
4
|
+
function origin(value) { const u = new URL(value); need(u.origin !== 'null' && u.protocol === 'https:' && u.origin === value); return value; }
|
|
5
|
+
function resultCheck(bytes, request, generation) {
|
|
6
|
+
const result = parseBoundedJSON(bytes);
|
|
7
|
+
closed(result, ['state'], ['projectedData']);
|
|
8
|
+
const s = result.state;
|
|
9
|
+
closed(s, ['schema', 'requestId', 'placementId', 'sourceDigest', 'mode', 'state', 'sessionGeneration', 'publicMessage']);
|
|
10
|
+
need(s.schema === 'atelier-preview-state/proposal-v1' && s.requestId === request.requestId && s.placementId === request.placementId && s.sourceDigest === request.sourceDigest && s.mode === request.mode);
|
|
11
|
+
need(s.sessionGeneration === generation && ['loading', 'ready', 'unauthenticated', 'forbidden', 'expired', 'unavailable', 'stale'].includes(s.state));
|
|
12
|
+
need(typeof s.publicMessage === 'string' && s.publicMessage.length <= 160);
|
|
13
|
+
need(s.state === 'ready' ? Object.hasOwn(result, 'projectedData') : !Object.hasOwn(result, 'projectedData'));
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
function fail(request, generation) { return { state: { schema: 'atelier-preview-state/proposal-v1', requestId: request.requestId, placementId: request.placementId,
|
|
17
|
+
sourceDigest: request.sourceDigest, mode: request.mode, state: 'unavailable', sessionGeneration: generation, publicMessage: 'Preview unavailable.' } }; }
|
|
18
|
+
|
|
19
|
+
export function mountPreview({ frame, previewOrigin, requestBytes, generation, handle, onState = () => {} }) {
|
|
20
|
+
origin(previewOrigin); need(new URL(frame.src).origin === previewOrigin && previewOrigin !== window.location.origin);
|
|
21
|
+
const template = parseRequest(requestBytes); need(!template.intentRef && Number.isSafeInteger(generation) && generation >= 0 && typeof handle === 'function');
|
|
22
|
+
const nonce = crypto.randomUUID(), channel = new MessageChannel(), controller = new AbortController();
|
|
23
|
+
let active = true, ready = false, sequence = 0, latest = 0;
|
|
24
|
+
const invalidate = () => {
|
|
25
|
+
if (!active) return; active = false; controller.abort();
|
|
26
|
+
channel.port1.postMessage(JSON.stringify({type:'invalidate',nonce})); channel.port1.close(); frame.removeEventListener('load', invalidate);
|
|
27
|
+
onState('stale');
|
|
28
|
+
};
|
|
29
|
+
frame.addEventListener('load', invalidate); // Future navigation invalidates this mount.
|
|
30
|
+
channel.port1.onmessage = async event => {
|
|
31
|
+
if (!active) return;
|
|
32
|
+
try {
|
|
33
|
+
const v = parseBoundedJSON(event.data);
|
|
34
|
+
if (!ready) { closed(v, ['type', 'nonce']); need(v.type === 'ready' && v.nonce === nonce); ready = true; onState('connected'); return; }
|
|
35
|
+
closed(v, ['type', 'nonce', 'sequence', 'request']);
|
|
36
|
+
need(v.type === 'request' && v.nonce === nonce && Number.isSafeInteger(v.sequence) && v.sequence > sequence);
|
|
37
|
+
const request = parseRequest(v.request);
|
|
38
|
+
need(request.placementId === template.placementId && request.sourceDigest === template.sourceDigest && request.mode === template.mode);
|
|
39
|
+
sequence = v.sequence; latest = sequence; const thisSequence = sequence;
|
|
40
|
+
let result;
|
|
41
|
+
try { result = resultCheck(JSON.stringify(await handle(v.request, controller.signal)), request, generation); }
|
|
42
|
+
catch { result = fail(request, generation); }
|
|
43
|
+
if (!active || controller.signal.aborted || thisSequence !== latest) return;
|
|
44
|
+
channel.port1.postMessage(JSON.stringify({ type: 'result', nonce, sequence: thisSequence, result }));
|
|
45
|
+
} catch { invalidate(); }
|
|
46
|
+
};
|
|
47
|
+
channel.port1.start();
|
|
48
|
+
frame.contentWindow.postMessage(JSON.stringify({ type: HELLO, nonce, generation, request: requestBytes }), previewOrigin, [channel.port2]);
|
|
49
|
+
return Object.freeze({ dispose: invalidate });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function receivePreview({ shellOrigin, onMount, onResult, onInvalidate = () => {} }) {
|
|
53
|
+
origin(shellOrigin); need(shellOrigin !== window.location.origin);
|
|
54
|
+
let active = null;
|
|
55
|
+
function clear() { active?.port.close(); active = null; onInvalidate(); }
|
|
56
|
+
function receive(event) {
|
|
57
|
+
if (event.origin !== shellOrigin || event.source !== window.parent) return;
|
|
58
|
+
try {
|
|
59
|
+
const v = parseBoundedJSON(event.data);
|
|
60
|
+
closed(v, ['type', 'nonce', 'generation', 'request']);
|
|
61
|
+
need(v.type === HELLO && isRef(v.nonce) && Number.isSafeInteger(v.generation) && v.generation >= 0 && event.ports.length === 1);
|
|
62
|
+
const request = parseRequest(v.request); need(!request.intentRef && isDigest(request.sourceDigest) && MODES.includes(request.mode));
|
|
63
|
+
clear();
|
|
64
|
+
const mount = { port: event.ports[0], nonce: v.nonce, generation: v.generation, request, sequence: 0, settled: 0 };
|
|
65
|
+
active = mount;
|
|
66
|
+
mount.port.onmessage = e => {
|
|
67
|
+
if (active !== mount) return;
|
|
68
|
+
try {
|
|
69
|
+
const packet = parseBoundedJSON(e.data);
|
|
70
|
+
if (packet?.type === 'invalidate') { closed(packet, ['type','nonce']); need(packet.nonce === mount.nonce); clear(); return; }
|
|
71
|
+
closed(packet, ['type', 'nonce', 'sequence', 'result']);
|
|
72
|
+
need(packet.type === 'result' && packet.nonce === mount.nonce && packet.sequence === mount.sequence && packet.sequence > mount.settled);
|
|
73
|
+
const result = resultCheck(JSON.stringify(packet.result), mount.pending, mount.generation);
|
|
74
|
+
mount.settled = packet.sequence; onResult(result);
|
|
75
|
+
} catch { clear(); }
|
|
76
|
+
};
|
|
77
|
+
mount.port.start(); mount.port.postMessage(JSON.stringify({ type: 'ready', nonce: mount.nonce }));
|
|
78
|
+
onMount(request);
|
|
79
|
+
} catch { clear(); }
|
|
80
|
+
}
|
|
81
|
+
window.addEventListener('message', receive);
|
|
82
|
+
return Object.freeze({ request(intent) {
|
|
83
|
+
if (!active) return false;
|
|
84
|
+
const sequence = ++active.sequence;
|
|
85
|
+
const request = { ...active.request, requestId: crypto.randomUUID(), ...(intent ? { schema: 'atelier-component-intent/proposal-v1', intentRef: intent.ref, payload: intent.payload } : {}) };
|
|
86
|
+
parseRequest(JSON.stringify(request)); active.pending = request;
|
|
87
|
+
active.port.postMessage(JSON.stringify({ type: 'request', nonce: active.nonce, sequence, request: JSON.stringify(request) })); return true;
|
|
88
|
+
}, dispose() { clear(); window.removeEventListener('message', receive); } });
|
|
89
|
+
}
|