@sentropic/cluster-mesh 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/comments/storage-schema.d.ts +1 -1
- package/dist/comments/transport-contracts.d.ts +1 -1
- package/dist/compile/contract/diagnostics.d.ts +9 -0
- package/dist/compile/contract/diagnostics.d.ts.map +1 -0
- package/dist/compile/contract/diagnostics.js +82 -0
- package/dist/compile/contract/diagnostics.js.map +1 -0
- package/dist/compile/contract/encoding.d.ts +12 -0
- package/dist/compile/contract/encoding.d.ts.map +1 -0
- package/dist/compile/contract/encoding.js +95 -0
- package/dist/compile/contract/encoding.js.map +1 -0
- package/dist/compile/contract/index.d.ts +9 -0
- package/dist/compile/contract/index.d.ts.map +1 -0
- package/dist/compile/contract/index.js +9 -0
- package/dist/compile/contract/index.js.map +1 -0
- package/dist/compile/contract/json.d.ts +3 -0
- package/dist/compile/contract/json.d.ts.map +1 -0
- package/dist/compile/contract/json.js +75 -0
- package/dist/compile/contract/json.js.map +1 -0
- package/dist/compile/contract/output.d.ts +5 -0
- package/dist/compile/contract/output.d.ts.map +1 -0
- package/dist/compile/contract/output.js +57 -0
- package/dist/compile/contract/output.js.map +1 -0
- package/dist/compile/contract/recipe.d.ts +5 -0
- package/dist/compile/contract/recipe.d.ts.map +1 -0
- package/dist/compile/contract/recipe.js +86 -0
- package/dist/compile/contract/recipe.js.map +1 -0
- package/dist/compile/contract/schema.d.ts +26 -0
- package/dist/compile/contract/schema.d.ts.map +1 -0
- package/dist/compile/contract/schema.js +92 -0
- package/dist/compile/contract/schema.js.map +1 -0
- package/dist/compile/contract/types.d.ts +166 -0
- package/dist/compile/contract/types.d.ts.map +1 -0
- package/dist/compile/contract/types.js +21 -0
- package/dist/compile/contract/types.js.map +1 -0
- package/dist/compile/contract/vectors.d.ts +38 -0
- package/dist/compile/contract/vectors.d.ts.map +1 -0
- package/dist/compile/contract/vectors.js +29 -0
- package/dist/compile/contract/vectors.js.map +1 -0
- package/dist/forge/contracts.d.ts +60 -0
- package/dist/forge/contracts.d.ts.map +1 -0
- package/dist/forge/contracts.js +19 -0
- package/dist/forge/contracts.js.map +1 -0
- package/dist/forge/custody.d.ts +7 -0
- package/dist/forge/custody.d.ts.map +1 -0
- package/dist/forge/custody.js +76 -0
- package/dist/forge/custody.js.map +1 -0
- package/dist/forge/enrollment.d.ts +151 -0
- package/dist/forge/enrollment.d.ts.map +1 -0
- package/dist/forge/enrollment.js +98 -0
- package/dist/forge/enrollment.js.map +1 -0
- package/dist/forge/github-api.d.ts +6 -0
- package/dist/forge/github-api.d.ts.map +1 -0
- package/dist/forge/github-api.js +131 -0
- package/dist/forge/github-api.js.map +1 -0
- package/dist/forge/hono.d.ts +14 -0
- package/dist/forge/hono.d.ts.map +1 -0
- package/dist/forge/hono.js +141 -0
- package/dist/forge/hono.js.map +1 -0
- package/dist/forge/lifecycle.d.ts +108 -0
- package/dist/forge/lifecycle.d.ts.map +1 -0
- package/dist/forge/lifecycle.js +160 -0
- package/dist/forge/lifecycle.js.map +1 -0
- package/dist/forge/records.d.ts +70 -0
- package/dist/forge/records.d.ts.map +1 -0
- package/dist/forge/records.js +2 -0
- package/dist/forge/records.js.map +1 -0
- package/dist/forge/rotation.d.ts +46 -0
- package/dist/forge/rotation.d.ts.map +1 -0
- package/dist/forge/rotation.js +62 -0
- package/dist/forge/rotation.js.map +1 -0
- package/dist/identity/auth-abort.d.ts +9 -0
- package/dist/identity/auth-abort.d.ts.map +1 -0
- package/dist/identity/auth-abort.js +59 -0
- package/dist/identity/auth-abort.js.map +1 -0
- package/dist/identity/auth-binding.d.ts +3 -0
- package/dist/identity/auth-binding.d.ts.map +1 -0
- package/dist/identity/auth-binding.js +87 -0
- package/dist/identity/auth-binding.js.map +1 -0
- package/dist/identity/auth-boundary.d.ts +11 -0
- package/dist/identity/auth-boundary.d.ts.map +1 -0
- package/dist/identity/auth-boundary.js +73 -0
- package/dist/identity/auth-boundary.js.map +1 -0
- package/dist/identity/auth-completion.d.ts +9 -0
- package/dist/identity/auth-completion.d.ts.map +1 -0
- package/dist/identity/auth-completion.js +24 -0
- package/dist/identity/auth-completion.js.map +1 -0
- package/dist/identity/auth-credentials.d.ts +5 -0
- package/dist/identity/auth-credentials.d.ts.map +1 -0
- package/dist/identity/auth-credentials.js +82 -0
- package/dist/identity/auth-credentials.js.map +1 -0
- package/dist/identity/auth-email.d.ts +8 -0
- package/dist/identity/auth-email.d.ts.map +1 -0
- package/dist/identity/auth-email.js +104 -0
- package/dist/identity/auth-email.js.map +1 -0
- package/dist/identity/auth-hono.d.ts +5 -0
- package/dist/identity/auth-hono.d.ts.map +1 -0
- package/dist/identity/auth-hono.js +10 -0
- package/dist/identity/auth-hono.js.map +1 -0
- package/dist/identity/auth-proofs.d.ts +11 -0
- package/dist/identity/auth-proofs.d.ts.map +1 -0
- package/dist/identity/auth-proofs.js +107 -0
- package/dist/identity/auth-proofs.js.map +1 -0
- package/dist/identity/auth-service-tenant.d.ts +4 -0
- package/dist/identity/auth-service-tenant.d.ts.map +1 -0
- package/dist/identity/auth-service-tenant.js +54 -0
- package/dist/identity/auth-service-tenant.js.map +1 -0
- package/dist/identity/auth-sessions.d.ts +8 -0
- package/dist/identity/auth-sessions.d.ts.map +1 -0
- package/dist/identity/auth-sessions.js +141 -0
- package/dist/identity/auth-sessions.js.map +1 -0
- package/dist/identity/auth-social.d.ts +4 -0
- package/dist/identity/auth-social.d.ts.map +1 -0
- package/dist/identity/auth-social.js +82 -0
- package/dist/identity/auth-social.js.map +1 -0
- package/dist/identity/auth-users.d.ts +9 -0
- package/dist/identity/auth-users.d.ts.map +1 -0
- package/dist/identity/auth-users.js +116 -0
- package/dist/identity/auth-users.js.map +1 -0
- package/dist/identity/auth-webauthn.d.ts +22 -0
- package/dist/identity/auth-webauthn.d.ts.map +1 -0
- package/dist/identity/auth-webauthn.js +108 -0
- package/dist/identity/auth-webauthn.js.map +1 -0
- package/dist/identity/cascade.d.ts +12 -0
- package/dist/identity/cascade.d.ts.map +1 -0
- package/dist/identity/cascade.js +19 -0
- package/dist/identity/cascade.js.map +1 -0
- package/dist/identity/connector-custody.d.ts +85 -0
- package/dist/identity/connector-custody.d.ts.map +1 -0
- package/dist/identity/connector-custody.js +288 -0
- package/dist/identity/connector-custody.js.map +1 -0
- package/dist/identity/conversation.d.ts +50 -0
- package/dist/identity/conversation.d.ts.map +1 -0
- package/dist/identity/conversation.js +102 -0
- package/dist/identity/conversation.js.map +1 -0
- package/dist/identity/custody-crypto.d.ts +37 -0
- package/dist/identity/custody-crypto.d.ts.map +1 -0
- package/dist/identity/custody-crypto.js +173 -0
- package/dist/identity/custody-crypto.js.map +1 -0
- package/dist/identity/decision.d.ts +28 -0
- package/dist/identity/decision.d.ts.map +1 -0
- package/dist/identity/decision.js +97 -0
- package/dist/identity/decision.js.map +1 -0
- package/dist/identity/index.d.ts +9 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +13 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/ledger.d.ts +120 -0
- package/dist/identity/ledger.d.ts.map +1 -0
- package/dist/identity/ledger.js +226 -0
- package/dist/identity/ledger.js.map +1 -0
- package/dist/identity/postgres.d.ts +13 -0
- package/dist/identity/postgres.d.ts.map +1 -0
- package/dist/identity/postgres.js +207 -0
- package/dist/identity/postgres.js.map +1 -0
- package/dist/identity/sqlite.d.ts +14 -0
- package/dist/identity/sqlite.d.ts.map +1 -0
- package/dist/identity/sqlite.js +193 -0
- package/dist/identity/sqlite.js.map +1 -0
- package/dist/identity-contracts/accounts.d.ts.map +1 -1
- package/dist/identity-contracts/accounts.js +4 -3
- package/dist/identity-contracts/accounts.js.map +1 -1
- package/dist/identity-contracts/boundary-resolution.d.ts +31 -0
- package/dist/identity-contracts/boundary-resolution.d.ts.map +1 -0
- package/dist/identity-contracts/boundary-resolution.js +56 -0
- package/dist/identity-contracts/boundary-resolution.js.map +1 -0
- package/dist/identity-contracts/composition-descriptors.d.ts +17 -0
- package/dist/identity-contracts/composition-descriptors.d.ts.map +1 -0
- package/dist/identity-contracts/composition-descriptors.js +77 -0
- package/dist/identity-contracts/composition-descriptors.js.map +1 -0
- package/dist/identity-contracts/custody-auth.d.ts +122 -0
- package/dist/identity-contracts/custody-auth.d.ts.map +1 -0
- package/dist/identity-contracts/custody-auth.js +2 -0
- package/dist/identity-contracts/custody-auth.js.map +1 -0
- package/dist/identity-contracts/custody-descriptors.d.ts +18 -0
- package/dist/identity-contracts/custody-descriptors.d.ts.map +1 -0
- package/dist/identity-contracts/custody-descriptors.js +83 -0
- package/dist/identity-contracts/custody-descriptors.js.map +1 -0
- package/dist/identity-contracts/custody-errors.d.ts +21 -0
- package/dist/identity-contracts/custody-errors.d.ts.map +1 -0
- package/dist/identity-contracts/custody-errors.js +80 -0
- package/dist/identity-contracts/custody-errors.js.map +1 -0
- package/dist/identity-contracts/custody-operations.d.ts +79 -0
- package/dist/identity-contracts/custody-operations.d.ts.map +1 -0
- package/dist/identity-contracts/custody-operations.js +2 -0
- package/dist/identity-contracts/custody-operations.js.map +1 -0
- package/dist/identity-contracts/custody.d.ts +587 -0
- package/dist/identity-contracts/custody.d.ts.map +1 -0
- package/dist/identity-contracts/custody.js +7 -0
- package/dist/identity-contracts/custody.js.map +1 -0
- package/dist/identity-contracts/doubles.d.ts +11 -2
- package/dist/identity-contracts/doubles.d.ts.map +1 -1
- package/dist/identity-contracts/doubles.js +20 -0
- package/dist/identity-contracts/doubles.js.map +1 -1
- package/dist/identity-contracts/index.d.ts +10 -0
- package/dist/identity-contracts/index.d.ts.map +1 -1
- package/dist/identity-contracts/index.js +10 -0
- package/dist/identity-contracts/index.js.map +1 -1
- package/dist/identity-contracts/oauth-reads.d.ts +42 -0
- package/dist/identity-contracts/oauth-reads.d.ts.map +1 -0
- package/dist/identity-contracts/oauth-reads.js +38 -0
- package/dist/identity-contracts/oauth-reads.js.map +1 -0
- package/dist/identity-contracts/replica-sync.d.ts +89 -0
- package/dist/identity-contracts/replica-sync.d.ts.map +1 -0
- package/dist/identity-contracts/replica-sync.js +7 -0
- package/dist/identity-contracts/replica-sync.js.map +1 -0
- package/dist/identity-contracts/service-tenancy.d.ts +43 -0
- package/dist/identity-contracts/service-tenancy.d.ts.map +1 -0
- package/dist/identity-contracts/service-tenancy.js +75 -0
- package/dist/identity-contracts/service-tenancy.js.map +1 -0
- package/dist/identity-contracts/workspace-deletion.d.ts +56 -0
- package/dist/identity-contracts/workspace-deletion.d.ts.map +1 -0
- package/dist/identity-contracts/workspace-deletion.js +7 -0
- package/dist/identity-contracts/workspace-deletion.js.map +1 -0
- package/dist/identity-stores/index.d.ts +4 -0
- package/dist/identity-stores/index.d.ts.map +1 -0
- package/dist/identity-stores/index.js +7 -0
- package/dist/identity-stores/index.js.map +1 -0
- package/dist/identity-stores/tenancy-postgres.d.ts +23 -0
- package/dist/identity-stores/tenancy-postgres.d.ts.map +1 -0
- package/dist/identity-stores/tenancy-postgres.js +294 -0
- package/dist/identity-stores/tenancy-postgres.js.map +1 -0
- package/dist/identity-stores/tenancy-schema.d.ts +11 -0
- package/dist/identity-stores/tenancy-schema.d.ts.map +1 -0
- package/dist/identity-stores/tenancy-schema.js +74 -0
- package/dist/identity-stores/tenancy-schema.js.map +1 -0
- package/dist/identity-stores/tenancy-sqlite.d.ts +24 -0
- package/dist/identity-stores/tenancy-sqlite.d.ts.map +1 -0
- package/dist/identity-stores/tenancy-sqlite.js +288 -0
- package/dist/identity-stores/tenancy-sqlite.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/loaders/notifications/index.d.ts +5 -0
- package/dist/loaders/notifications/index.d.ts.map +1 -0
- package/dist/loaders/notifications/index.js +6 -0
- package/dist/loaders/notifications/index.js.map +1 -0
- package/dist/mcp/stateful-preflight.d.ts +1 -1
- package/dist/messaging/email-port.d.ts +49 -0
- package/dist/messaging/email-port.d.ts.map +1 -0
- package/dist/messaging/email-port.js +92 -0
- package/dist/messaging/email-port.js.map +1 -0
- package/dist/messaging/index.d.ts +1 -0
- package/dist/messaging/index.d.ts.map +1 -1
- package/dist/messaging/index.js +1 -0
- package/dist/messaging/index.js.map +1 -1
- package/dist/modules/catalog.d.ts +5 -4
- package/dist/modules/catalog.d.ts.map +1 -1
- package/dist/modules/catalog.js +10 -5
- package/dist/modules/catalog.js.map +1 -1
- package/dist/modules/contracts.d.ts +1 -1
- package/dist/modules/contracts.d.ts.map +1 -1
- package/dist/modules/contracts.js +1 -0
- package/dist/modules/contracts.js.map +1 -1
- package/dist/notifications/incident-policy.d.ts +6 -0
- package/dist/notifications/incident-policy.d.ts.map +1 -0
- package/dist/notifications/incident-policy.js +119 -0
- package/dist/notifications/incident-policy.js.map +1 -0
- package/dist/notifications/incident-schedule.d.ts +14 -0
- package/dist/notifications/incident-schedule.d.ts.map +1 -0
- package/dist/notifications/incident-schedule.js +36 -0
- package/dist/notifications/incident-schedule.js.map +1 -0
- package/dist/notifications/incident-state.d.ts +72 -0
- package/dist/notifications/incident-state.d.ts.map +1 -0
- package/dist/notifications/incident-state.js +72 -0
- package/dist/notifications/incident-state.js.map +1 -0
- package/dist/notifications/index.d.ts +9 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +9 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/ops-job-failure-contract.d.ts +19 -0
- package/dist/notifications/ops-job-failure-contract.d.ts.map +1 -0
- package/dist/notifications/ops-job-failure-contract.js +183 -0
- package/dist/notifications/ops-job-failure-contract.js.map +1 -0
- package/dist/notifications/ops-job-failure-types.d.ts +81 -0
- package/dist/notifications/ops-job-failure-types.d.ts.map +1 -0
- package/dist/notifications/ops-job-failure-types.js +73 -0
- package/dist/notifications/ops-job-failure-types.js.map +1 -0
- package/dist/notifications/recipients-http.d.ts +66 -0
- package/dist/notifications/recipients-http.d.ts.map +1 -0
- package/dist/notifications/recipients-http.js +148 -0
- package/dist/notifications/recipients-http.js.map +1 -0
- package/dist/notifications/recipients.d.ts +50 -0
- package/dist/notifications/recipients.d.ts.map +1 -0
- package/dist/notifications/recipients.js +59 -0
- package/dist/notifications/recipients.js.map +1 -0
- package/dist/prompts/registry.d.ts +55 -0
- package/dist/prompts/registry.d.ts.map +1 -0
- package/dist/prompts/registry.js +76 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/runtime/heavy-phase-queue.d.ts +101 -0
- package/dist/runtime/heavy-phase-queue.d.ts.map +1 -0
- package/dist/runtime/heavy-phase-queue.js +129 -0
- package/dist/runtime/heavy-phase-queue.js.map +1 -0
- package/dist/sessions/content-policy.d.ts +55 -0
- package/dist/sessions/content-policy.d.ts.map +1 -0
- package/dist/sessions/content-policy.js +133 -0
- package/dist/sessions/content-policy.js.map +1 -0
- package/dist/sessions/registry-admin.d.ts +19 -0
- package/dist/sessions/registry-admin.d.ts.map +1 -0
- package/dist/sessions/registry-admin.js +42 -0
- package/dist/sessions/registry-admin.js.map +1 -0
- package/dist/sessions/registry-freshness.d.ts +8 -0
- package/dist/sessions/registry-freshness.d.ts.map +1 -0
- package/dist/sessions/registry-freshness.js +108 -0
- package/dist/sessions/registry-freshness.js.map +1 -0
- package/dist/sessions/registry-ingest.d.ts +5 -0
- package/dist/sessions/registry-ingest.d.ts.map +1 -0
- package/dist/sessions/registry-ingest.js +113 -0
- package/dist/sessions/registry-ingest.js.map +1 -0
- package/dist/sessions/registry-publish.d.ts +18 -0
- package/dist/sessions/registry-publish.d.ts.map +1 -0
- package/dist/sessions/registry-publish.js +134 -0
- package/dist/sessions/registry-publish.js.map +1 -0
- package/dist/sessions/registry-store.d.ts +51 -0
- package/dist/sessions/registry-store.d.ts.map +1 -0
- package/dist/sessions/registry-store.js +134 -0
- package/dist/sessions/registry-store.js.map +1 -0
- package/dist/sessions/registry-types.d.ts +180 -0
- package/dist/sessions/registry-types.d.ts.map +1 -0
- package/dist/sessions/registry-types.js +32 -0
- package/dist/sessions/registry-types.js.map +1 -0
- package/dist/sessions/registry.d.ts +45 -0
- package/dist/sessions/registry.d.ts.map +1 -0
- package/dist/sessions/registry.js +74 -0
- package/dist/sessions/registry.js.map +1 -0
- package/dist/sessions/relay-bind.d.ts +38 -0
- package/dist/sessions/relay-bind.d.ts.map +1 -0
- package/dist/sessions/relay-bind.js +74 -0
- package/dist/sessions/relay-bind.js.map +1 -0
- package/dist/sessions/relay-brand.d.ts +2 -0
- package/dist/sessions/relay-brand.d.ts.map +1 -0
- package/dist/sessions/relay-brand.js +7 -0
- package/dist/sessions/relay-brand.js.map +1 -0
- package/dist/sessions/relay-capsule.d.ts +50 -0
- package/dist/sessions/relay-capsule.d.ts.map +1 -0
- package/dist/sessions/relay-capsule.js +72 -0
- package/dist/sessions/relay-capsule.js.map +1 -0
- package/dist/sessions/relay-chain-failure.d.ts +25 -0
- package/dist/sessions/relay-chain-failure.d.ts.map +1 -0
- package/dist/sessions/relay-chain-failure.js +23 -0
- package/dist/sessions/relay-chain-failure.js.map +1 -0
- package/dist/sessions/relay-chain.d.ts +74 -0
- package/dist/sessions/relay-chain.d.ts.map +1 -0
- package/dist/sessions/relay-chain.js +71 -0
- package/dist/sessions/relay-chain.js.map +1 -0
- package/dist/sessions/relay-composition.d.ts +8 -0
- package/dist/sessions/relay-composition.d.ts.map +1 -0
- package/dist/sessions/relay-composition.js +65 -0
- package/dist/sessions/relay-composition.js.map +1 -0
- package/dist/sessions/relay-credit.d.ts +40 -0
- package/dist/sessions/relay-credit.d.ts.map +1 -0
- package/dist/sessions/relay-credit.js +68 -0
- package/dist/sessions/relay-credit.js.map +1 -0
- package/dist/sessions/relay-engine.d.ts +19 -0
- package/dist/sessions/relay-engine.d.ts.map +1 -0
- package/dist/sessions/relay-engine.js +34 -0
- package/dist/sessions/relay-engine.js.map +1 -0
- package/dist/sessions/relay-frames.d.ts +28 -0
- package/dist/sessions/relay-frames.d.ts.map +1 -0
- package/dist/sessions/relay-frames.js +72 -0
- package/dist/sessions/relay-frames.js.map +1 -0
- package/dist/sessions/relay-lane-client.d.ts +7 -0
- package/dist/sessions/relay-lane-client.d.ts.map +1 -0
- package/dist/sessions/relay-lane-client.js +137 -0
- package/dist/sessions/relay-lane-client.js.map +1 -0
- package/dist/sessions/relay-lane-lease.d.ts +20 -0
- package/dist/sessions/relay-lane-lease.d.ts.map +1 -0
- package/dist/sessions/relay-lane-lease.js +74 -0
- package/dist/sessions/relay-lane-lease.js.map +1 -0
- package/dist/sessions/relay-lane-record.d.ts +28 -0
- package/dist/sessions/relay-lane-record.d.ts.map +1 -0
- package/dist/sessions/relay-lane-record.js +28 -0
- package/dist/sessions/relay-lane-record.js.map +1 -0
- package/dist/sessions/relay-lane-stream.d.ts +13 -0
- package/dist/sessions/relay-lane-stream.d.ts.map +1 -0
- package/dist/sessions/relay-lane-stream.js +148 -0
- package/dist/sessions/relay-lane-stream.js.map +1 -0
- package/dist/sessions/relay-routes.d.ts +368 -0
- package/dist/sessions/relay-routes.d.ts.map +1 -0
- package/dist/sessions/relay-routes.js +46 -0
- package/dist/sessions/relay-routes.js.map +1 -0
- package/dist/sessions/relay-skeleton.d.ts +4 -0
- package/dist/sessions/relay-skeleton.d.ts.map +1 -0
- package/dist/sessions/relay-skeleton.js +85 -0
- package/dist/sessions/relay-skeleton.js.map +1 -0
- package/dist/sessions/relay-types.d.ts +107 -0
- package/dist/sessions/relay-types.d.ts.map +1 -0
- package/dist/sessions/relay-types.js +2 -0
- package/dist/sessions/relay-types.js.map +1 -0
- package/dist/sessions/relay-validate.d.ts +8 -0
- package/dist/sessions/relay-validate.d.ts.map +1 -0
- package/dist/sessions/relay-validate.js +169 -0
- package/dist/sessions/relay-validate.js.map +1 -0
- package/dist/sessions/relay-wire.d.ts +8 -0
- package/dist/sessions/relay-wire.d.ts.map +1 -0
- package/dist/sessions/relay-wire.js +37 -0
- package/dist/sessions/relay-wire.js.map +1 -0
- package/dist/sessions/relay-wiring.d.ts +26 -0
- package/dist/sessions/relay-wiring.d.ts.map +1 -0
- package/dist/sessions/relay-wiring.js +13 -0
- package/dist/sessions/relay-wiring.js.map +1 -0
- package/dist/sessions/relay.d.ts +11 -0
- package/dist/sessions/relay.d.ts.map +1 -0
- package/dist/sessions/relay.js +71 -0
- package/dist/sessions/relay.js.map +1 -0
- package/dist/storage/descriptor.d.ts +1 -1
- package/dist/storage/errors.d.ts +1 -1
- package/dist/storage/identity/atomic-deletion.d.ts +4 -0
- package/dist/storage/identity/atomic-deletion.d.ts.map +1 -0
- package/dist/storage/identity/atomic-deletion.js +235 -0
- package/dist/storage/identity/atomic-deletion.js.map +1 -0
- package/dist/storage/identity/custody-composition.d.ts +9 -0
- package/dist/storage/identity/custody-composition.d.ts.map +1 -0
- package/dist/storage/identity/custody-composition.js +31 -0
- package/dist/storage/identity/custody-composition.js.map +1 -0
- package/dist/storage/identity/custody-delivery-record.d.ts +4 -0
- package/dist/storage/identity/custody-delivery-record.d.ts.map +1 -0
- package/dist/storage/identity/custody-delivery-record.js +11 -0
- package/dist/storage/identity/custody-delivery-record.js.map +1 -0
- package/dist/storage/identity/custody-host.d.ts +16 -0
- package/dist/storage/identity/custody-host.d.ts.map +1 -0
- package/dist/storage/identity/custody-host.js +5 -0
- package/dist/storage/identity/custody-host.js.map +1 -0
- package/dist/storage/identity/custody-import-deliveries.d.ts +6 -0
- package/dist/storage/identity/custody-import-deliveries.d.ts.map +1 -0
- package/dist/storage/identity/custody-import-deliveries.js +46 -0
- package/dist/storage/identity/custody-import-deliveries.js.map +1 -0
- package/dist/storage/identity/custody-import.d.ts +4 -0
- package/dist/storage/identity/custody-import.d.ts.map +1 -0
- package/dist/storage/identity/custody-import.js +364 -0
- package/dist/storage/identity/custody-import.js.map +1 -0
- package/dist/storage/identity/custody-journal-postgres.d.ts +125 -0
- package/dist/storage/identity/custody-journal-postgres.d.ts.map +1 -0
- package/dist/storage/identity/custody-journal-postgres.js +428 -0
- package/dist/storage/identity/custody-journal-postgres.js.map +1 -0
- package/dist/storage/identity/custody-journal-sqlite.d.ts +121 -0
- package/dist/storage/identity/custody-journal-sqlite.d.ts.map +1 -0
- package/dist/storage/identity/custody-journal-sqlite.js +345 -0
- package/dist/storage/identity/custody-journal-sqlite.js.map +1 -0
- package/dist/storage/identity/custody-lifecycle.d.ts +4 -0
- package/dist/storage/identity/custody-lifecycle.d.ts.map +1 -0
- package/dist/storage/identity/custody-lifecycle.js +42 -0
- package/dist/storage/identity/custody-lifecycle.js.map +1 -0
- package/dist/storage/identity/custody-postgres.d.ts +96 -0
- package/dist/storage/identity/custody-postgres.d.ts.map +1 -0
- package/dist/storage/identity/custody-postgres.js +726 -0
- package/dist/storage/identity/custody-postgres.js.map +1 -0
- package/dist/storage/identity/custody-records.d.ts +17 -0
- package/dist/storage/identity/custody-records.d.ts.map +1 -0
- package/dist/storage/identity/custody-records.js +260 -0
- package/dist/storage/identity/custody-records.js.map +1 -0
- package/dist/storage/identity/custody-shared.d.ts +28 -0
- package/dist/storage/identity/custody-shared.d.ts.map +1 -0
- package/dist/storage/identity/custody-shared.js +24 -0
- package/dist/storage/identity/custody-shared.js.map +1 -0
- package/dist/storage/identity/custody-sqlite.d.ts +93 -0
- package/dist/storage/identity/custody-sqlite.d.ts.map +1 -0
- package/dist/storage/identity/custody-sqlite.js +568 -0
- package/dist/storage/identity/custody-sqlite.js.map +1 -0
- package/dist/storage/identity/custody-tombstone-record.d.ts +3 -0
- package/dist/storage/identity/custody-tombstone-record.d.ts.map +1 -0
- package/dist/storage/identity/custody-tombstone-record.js +8 -0
- package/dist/storage/identity/custody-tombstone-record.js.map +1 -0
- package/dist/storage/identity/custody-transaction-guards.d.ts +16 -0
- package/dist/storage/identity/custody-transaction-guards.d.ts.map +1 -0
- package/dist/storage/identity/custody-transaction-guards.js +64 -0
- package/dist/storage/identity/custody-transaction-guards.js.map +1 -0
- package/dist/storage/identity/custody-transaction-ports.d.ts +9 -0
- package/dist/storage/identity/custody-transaction-ports.d.ts.map +1 -0
- package/dist/storage/identity/custody-transaction-ports.js +106 -0
- package/dist/storage/identity/custody-transaction-ports.js.map +1 -0
- package/dist/storage/identity/deletion-planes.d.ts +10 -0
- package/dist/storage/identity/deletion-planes.d.ts.map +1 -0
- package/dist/storage/identity/deletion-planes.js +54 -0
- package/dist/storage/identity/deletion-planes.js.map +1 -0
- package/dist/storage/identity/index.d.ts +18 -0
- package/dist/storage/identity/index.d.ts.map +1 -0
- package/dist/storage/identity/index.js +22 -0
- package/dist/storage/identity/index.js.map +1 -0
- package/dist/storage/identity/postgres.d.ts +16 -0
- package/dist/storage/identity/postgres.d.ts.map +1 -0
- package/dist/storage/identity/postgres.js +345 -0
- package/dist/storage/identity/postgres.js.map +1 -0
- package/dist/storage/identity/records.d.ts +12 -0
- package/dist/storage/identity/records.d.ts.map +1 -0
- package/dist/storage/identity/records.js +84 -0
- package/dist/storage/identity/records.js.map +1 -0
- package/dist/storage/identity/replica-sync.d.ts +4 -0
- package/dist/storage/identity/replica-sync.d.ts.map +1 -0
- package/dist/storage/identity/replica-sync.js +402 -0
- package/dist/storage/identity/replica-sync.js.map +1 -0
- package/dist/storage/identity/schema.d.ts +13 -0
- package/dist/storage/identity/schema.d.ts.map +1 -0
- package/dist/storage/identity/schema.js +418 -0
- package/dist/storage/identity/schema.js.map +1 -0
- package/dist/storage/identity/sqlite-schema.d.ts +4 -0
- package/dist/storage/identity/sqlite-schema.d.ts.map +1 -0
- package/dist/storage/identity/sqlite-schema.js +17 -0
- package/dist/storage/identity/sqlite-schema.js.map +1 -0
- package/dist/storage/identity/sqlite.d.ts +25 -0
- package/dist/storage/identity/sqlite.d.ts.map +1 -0
- package/dist/storage/identity/sqlite.js +233 -0
- package/dist/storage/identity/sqlite.js.map +1 -0
- package/dist/storage/identity/stores.d.ts +10 -0
- package/dist/storage/identity/stores.d.ts.map +1 -0
- package/dist/storage/identity/stores.js +5 -0
- package/dist/storage/identity/stores.js.map +1 -0
- package/dist/storage/identity/wiring.d.ts +20 -0
- package/dist/storage/identity/wiring.d.ts.map +1 -0
- package/dist/storage/identity/wiring.js +26 -0
- package/dist/storage/identity/wiring.js.map +1 -0
- package/dist/storage/identity/workspace-deletion.d.ts +3 -0
- package/dist/storage/identity/workspace-deletion.d.ts.map +1 -0
- package/dist/storage/identity/workspace-deletion.js +100 -0
- package/dist/storage/identity/workspace-deletion.js.map +1 -0
- package/dist/storage/postgres/journal.d.ts +1 -1
- package/dist/storage/postgres/profiles.d.ts +2 -2
- package/dist/storage/postgres/scope.d.ts +1 -1
- package/dist/storage/root-facade.d.ts +1 -1
- package/dist/storage/root-journal.d.ts +1 -1
- package/dist/storage/root-profiles.d.ts +1 -1
- package/package.json +56 -4
- package/ui/AdminUsersScreen.svelte +197 -0
- package/ui/AdminUsersScreen.svelte.d.ts +4 -0
- package/ui/LoginScreen.svelte +15 -0
- package/ui/LoginScreen.svelte.d.ts +4 -0
- package/ui/MembershipDecisionsScreen.svelte +76 -0
- package/ui/MembershipDecisionsScreen.svelte.d.ts +4 -0
- package/ui/RegistrationScreen.svelte +15 -0
- package/ui/RegistrationScreen.svelte.d.ts +4 -0
- package/ui/WorkspaceMembersScreen.svelte +86 -0
- package/ui/WorkspaceMembersScreen.svelte.d.ts +4 -0
- package/ui/auth-flow.ts +44 -0
- package/ui/management-ports.ts +36 -0
- package/ui/management-transport.ts +29 -0
- package/contracts/engram-memory-neutral-contract-v1.d.ts +0 -367
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/** Frozen supplement format for the RC2 content-policy proposal (contract §10). */
|
|
3
|
+
export const POLICY_FORMAT = 'h2a.session-content-policy/1';
|
|
4
|
+
export const POLICY_DIGEST_DOMAIN = 'h2a.session-content-policy/1/policy\0';
|
|
5
|
+
/** The 17 frozen policy-supplement record names (contract §10). */
|
|
6
|
+
export const FROZEN_POLICY_RECORDS = [
|
|
7
|
+
'ContentPolicyV1',
|
|
8
|
+
'ContentPolicyIntentV1',
|
|
9
|
+
'ContentPolicyProposalV1',
|
|
10
|
+
'ContentPolicyChallengeRequestV1',
|
|
11
|
+
'ContentPolicyNonceV1',
|
|
12
|
+
'ContentPolicyNonceAckV1',
|
|
13
|
+
'ContentPolicyEvidenceRequestV1',
|
|
14
|
+
'ContentPolicyIdpClaimsV1',
|
|
15
|
+
'ContentPolicyIdpEvidenceV1',
|
|
16
|
+
'ContentPolicyAppAttestationV1',
|
|
17
|
+
'ContentPolicyProofV1',
|
|
18
|
+
'ContentPolicyActivationAckV1',
|
|
19
|
+
'ContentPolicyActivationReceiptV1',
|
|
20
|
+
'ContentPolicySubmissionV1',
|
|
21
|
+
'ContentPolicyCaptureGrantV1',
|
|
22
|
+
'ContentPolicyCaptureAckV1',
|
|
23
|
+
'ContentPolicyCaptureReceiptV1',
|
|
24
|
+
];
|
|
25
|
+
export const POLICY_CHANNELS = [
|
|
26
|
+
'session.events', 'terminal.live', 'terminal.cache', 'native.mirror',
|
|
27
|
+
];
|
|
28
|
+
export const RETAINED_POLICY_CHANNELS = [
|
|
29
|
+
'session.events',
|
|
30
|
+
'terminal.cache',
|
|
31
|
+
'native.mirror',
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Explicit v1 product interoperability cap: ten Julian years
|
|
35
|
+
* (10 * 365.25 * 86400000 ms), per contract annex E (r2 W-P3-3).
|
|
36
|
+
* It is not a statutory retention obligation.
|
|
37
|
+
*/
|
|
38
|
+
export const TEN_JULIAN_YEAR_MS = 315576000000;
|
|
39
|
+
export class ContentPolicyError extends Error {
|
|
40
|
+
code;
|
|
41
|
+
constructor(code, message) {
|
|
42
|
+
super(message);
|
|
43
|
+
this.code = code;
|
|
44
|
+
this.name = 'ContentPolicyError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
48
|
+
/**
|
|
49
|
+
* Validate the owner-selected per-channel retention map against the frozen
|
|
50
|
+
* ContentPolicyV1 shape. Every retained channel needs an explicit tagged
|
|
51
|
+
* choice: `{ kind: 'none' }` (no expiry, not disabled storage) or
|
|
52
|
+
* `{ kind: 'finite', durationMs }` with an integer 1..TEN_JULIAN_YEAR_MS.
|
|
53
|
+
* Omitted channels and untagged finite values fail as unsigned;
|
|
54
|
+
* zero/negative/fractional/over-cap durations and unknown tags fail as
|
|
55
|
+
* invalid. No environment/tenant/admin default is ever substituted here.
|
|
56
|
+
*/
|
|
57
|
+
export const validateChannelRetention = (value) => {
|
|
58
|
+
if (!isRecord(value)) {
|
|
59
|
+
throw new ContentPolicyError('invalid_retention', 'retention map must be an object');
|
|
60
|
+
}
|
|
61
|
+
for (const key of Object.keys(value)) {
|
|
62
|
+
if (!RETAINED_POLICY_CHANNELS.includes(key)) {
|
|
63
|
+
throw new ContentPolicyError('invalid_request', `unknown retention channel ${key}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const result = {};
|
|
67
|
+
for (const channel of RETAINED_POLICY_CHANNELS) {
|
|
68
|
+
const entry = value[channel];
|
|
69
|
+
if (entry === undefined) {
|
|
70
|
+
throw new ContentPolicyError('unsigned_retention', `${channel} retention is required`);
|
|
71
|
+
}
|
|
72
|
+
if (!isRecord(entry) || typeof entry['kind'] !== 'string') {
|
|
73
|
+
if (isRecord(entry) && typeof entry['durationMs'] === 'number') {
|
|
74
|
+
throw new ContentPolicyError('unsigned_retention', `${channel} retention kind is required`);
|
|
75
|
+
}
|
|
76
|
+
throw new ContentPolicyError('invalid_retention', `${channel} retention is malformed`);
|
|
77
|
+
}
|
|
78
|
+
if (entry['kind'] === 'none') {
|
|
79
|
+
result[channel] = { kind: 'none' };
|
|
80
|
+
}
|
|
81
|
+
else if (entry['kind'] === 'finite') {
|
|
82
|
+
const durationMs = entry['durationMs'];
|
|
83
|
+
if (typeof durationMs !== 'number' || !Number.isSafeInteger(durationMs)
|
|
84
|
+
|| durationMs <= 0 || durationMs > TEN_JULIAN_YEAR_MS) {
|
|
85
|
+
throw new ContentPolicyError('invalid_retention', `${channel} durationMs must be an integer in 1..${TEN_JULIAN_YEAR_MS}`);
|
|
86
|
+
}
|
|
87
|
+
result[channel] = { kind: 'finite', durationMs };
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
throw new ContentPolicyError('invalid_retention', `${channel} retention kind is unknown`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* r2 annex E retention-deadline evaluator (W-P3-3), matching
|
|
97
|
+
* vectors/r2-semantics.json `retentionDeadline`: `none` means no expiry
|
|
98
|
+
* (null), `finite` gives firstAdmissionAt+durationMs set once, with
|
|
99
|
+
* safe-integer overflow rejection. Amend/read/replay/import/reconnect
|
|
100
|
+
* never extend the result; the caller stores it immutably.
|
|
101
|
+
*/
|
|
102
|
+
export const computeRetentionDeadline = (retention, firstAdmissionAt) => {
|
|
103
|
+
if (retention.kind === 'none')
|
|
104
|
+
return null;
|
|
105
|
+
if (!Number.isSafeInteger(firstAdmissionAt)) {
|
|
106
|
+
throw new ContentPolicyError('invalid_retention', 'firstAdmissionAt must be a safe integer');
|
|
107
|
+
}
|
|
108
|
+
if (retention.durationMs > TEN_JULIAN_YEAR_MS) {
|
|
109
|
+
throw new ContentPolicyError('invalid_retention', 'durationMs exceeds the ten-Julian-year product cap');
|
|
110
|
+
}
|
|
111
|
+
const deadline = firstAdmissionAt + retention.durationMs;
|
|
112
|
+
if (!Number.isSafeInteger(deadline)) {
|
|
113
|
+
throw new ContentPolicyError('invalid_retention', 'retention deadline overflows a safe integer');
|
|
114
|
+
}
|
|
115
|
+
return deadline;
|
|
116
|
+
};
|
|
117
|
+
/** Canonical JSON with sorted keys so both authorities hash the same bytes. */
|
|
118
|
+
export const canonicalizePolicy = (policy) => {
|
|
119
|
+
if (Array.isArray(policy))
|
|
120
|
+
return `[${policy.map(canonicalizePolicy).join(',')}]`;
|
|
121
|
+
if (isRecord(policy)) {
|
|
122
|
+
const keys = Object.keys(policy).sort();
|
|
123
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalizePolicy(policy[key])}`).join(',')}}`;
|
|
124
|
+
}
|
|
125
|
+
return JSON.stringify(policy) ?? 'null';
|
|
126
|
+
};
|
|
127
|
+
/** Policy digest under the frozen supplement domain (contract §10). */
|
|
128
|
+
export const computePolicyDigest = (policy) => createHash('sha256')
|
|
129
|
+
.update(POLICY_DIGEST_DOMAIN, 'utf8')
|
|
130
|
+
.update(canonicalizePolicy(policy), 'utf8')
|
|
131
|
+
.digest('hex');
|
|
132
|
+
export const verifyPolicyDigest = (policy, digest) => computePolicyDigest(policy) === digest;
|
|
133
|
+
//# sourceMappingURL=content-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-policy.js","sourceRoot":"","sources":["../../src/sessions/content-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG,8BAA8B,CAAC;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,uCAAuC,CAAC;AAE5E,mEAAmE;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,iBAAiB;IACjB,uBAAuB;IACvB,yBAAyB;IACzB,iCAAiC;IACjC,sBAAsB;IACtB,yBAAyB;IACzB,gCAAgC;IAChC,0BAA0B;IAC1B,4BAA4B;IAC5B,+BAA+B;IAC/B,sBAAsB;IACtB,8BAA8B;IAC9B,kCAAkC;IAClC,2BAA2B;IAC3B,6BAA6B;IAC7B,2BAA2B;IAC3B,+BAA+B;CAChC,CAAC;AASF,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe;CACrE,CAAC;AAKF,MAAM,CAAC,MAAM,wBAAwB,GAAqC;IACxE,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;CAChB,CAAC;AAWF;;;;GAIG;AACH,MAAM,C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ACvE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAe,EAAU,EAAE,CAC7D,UAAU,CAAC,QAAQ,CAAC;KACjB,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC;KACpC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;KAC1C,MAAM,CAAC,KAAK,CAAC,CAAC;AAEnB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAe,EAAE,MAAc,EAAW,EAAE,CAC7E,mBAAmB,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EmitResult, ObservationRecord, SessionRef } from './registry-types.js';
|
|
2
|
+
import type { RegistryState } from './registry-store.js';
|
|
3
|
+
export declare function reportSplitBrain(state: RegistryState, ref: SessionRef, left: {
|
|
4
|
+
readonly writerEpoch: number;
|
|
5
|
+
readonly originRevision: number;
|
|
6
|
+
readonly digest: string;
|
|
7
|
+
}, right: {
|
|
8
|
+
readonly writerEpoch: number;
|
|
9
|
+
readonly originRevision: number;
|
|
10
|
+
readonly digest: string;
|
|
11
|
+
}): {
|
|
12
|
+
readonly quarantined: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function isQuarantined(state: RegistryState, ref: SessionRef): boolean;
|
|
15
|
+
export declare function assertListingStageRoute(state: RegistryState, method: string, path: string): {
|
|
16
|
+
readonly admitted: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function emitObservation(state: RegistryState, observation: ObservationRecord): EmitResult;
|
|
19
|
+
//# sourceMappingURL=registry-admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-admin.d.ts","sourceRoot":"","sources":["../../src/sessions/registry-admin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,UAAU,EACX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAChG,KAAK,EAAE;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAChG;IAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAYnC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAE5E;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAG1H;AAaD,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,GAAG,UAAU,CAWhG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LISTING_STAGE_ROUTES, OBSERVATION_QUEUE_CAP } from './registry-types.js';
|
|
2
|
+
import { sessionKey } from './registry-store.js';
|
|
3
|
+
export function reportSplitBrain(state, ref, left, right) {
|
|
4
|
+
const row = state.sessions.get(sessionKey(ref));
|
|
5
|
+
if (row === undefined)
|
|
6
|
+
return { quarantined: false };
|
|
7
|
+
if (left.writerEpoch !== row.writerEpoch ||
|
|
8
|
+
right.writerEpoch !== row.writerEpoch ||
|
|
9
|
+
(left.originRevision === right.originRevision && left.digest !== right.digest)) {
|
|
10
|
+
row.quarantined = true;
|
|
11
|
+
return { quarantined: true };
|
|
12
|
+
}
|
|
13
|
+
return { quarantined: false };
|
|
14
|
+
}
|
|
15
|
+
export function isQuarantined(state, ref) {
|
|
16
|
+
return state.sessions.get(sessionKey(ref))?.quarantined ?? false;
|
|
17
|
+
}
|
|
18
|
+
export function assertListingStageRoute(state, method, path) {
|
|
19
|
+
void state;
|
|
20
|
+
return { admitted: LISTING_STAGE_ROUTES.includes(`${method} ${path}`) };
|
|
21
|
+
}
|
|
22
|
+
function validObservation(observation) {
|
|
23
|
+
return (observation.format === 'cluster-mesh.session-observation/1' &&
|
|
24
|
+
observation.kind === 'observation' &&
|
|
25
|
+
typeof observation.observerRef === 'string' &&
|
|
26
|
+
typeof observation.sessionTraceId === 'string' &&
|
|
27
|
+
typeof observation.observedAt === 'number' &&
|
|
28
|
+
Number.isFinite(observation.observedAt));
|
|
29
|
+
}
|
|
30
|
+
export function emitObservation(state, observation) {
|
|
31
|
+
if (!validObservation(observation)) {
|
|
32
|
+
state.droppedObservations += 1;
|
|
33
|
+
return { status: 'dropped', dropped: state.droppedObservations };
|
|
34
|
+
}
|
|
35
|
+
if (state.observations.length >= OBSERVATION_QUEUE_CAP) {
|
|
36
|
+
state.droppedObservations += 1;
|
|
37
|
+
return { status: 'dropped', dropped: state.droppedObservations };
|
|
38
|
+
}
|
|
39
|
+
state.observations.push(observation);
|
|
40
|
+
return { status: 'enqueued', queued: state.observations.length };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=registry-admin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-admin.js","sourceRoot":"","sources":["../../src/sessions/registry-admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAMlF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,MAAM,UAAU,gBAAgB,CAC9B,KAAoB,EACpB,GAAe,EACf,IAAgG,EAChG,KAAiG;IAEjG,MAAM,GAAG,GAAG,K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,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAoB,EAAE,WAA8B;IAClF,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,CAAC;QACnC,KAAK,CAAC,mBAAmB,IAAI,CAAC,CAAC;QAC/B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,mBAAmB,EAAE,CAAC;IACnE,CAAC;IACD,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,qBAAqB,EAAE,CAAC;QACvD,KAAK,CAAC,mBAAmB,IAAI,CAAC,CAAC;QAC/B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,mBAAmB,EAAE,CAAC;IACnE,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PublishResult, SessionRef, Visibility } from './registry-types.js';
|
|
2
|
+
import type { RegistryState } from './registry-store.js';
|
|
3
|
+
export declare function ensureScheduler(state: RegistryState): void;
|
|
4
|
+
export declare function renewFreshness(state: RegistryState, ref: SessionRef, visibility: Visibility): PublishResult;
|
|
5
|
+
export declare function isLive(state: RegistryState, ref: SessionRef): boolean;
|
|
6
|
+
export declare function restartRegistry(state: RegistryState): void;
|
|
7
|
+
export declare function signFreshness(state: RegistryState, _ref: SessionRef, _visibility: Visibility): never;
|
|
8
|
+
//# sourceMappingURL=registry-freshness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-freshness.d.ts","sourceRoot":"","sources":["../../src/sessions/registry-freshness.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,qBAAqB,CAAC;AAO7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAczD,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAqB1D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,aAAa,CAoC3G;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAYrE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAK1D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,GAAG,KAAK,CAMpG"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { FRESHNESS_BOUND_MS, FRESHNESS_GRANT_MARGIN_MS, FRESHNESS_INTERVAL_MS, relayError } from './registry-types.js';
|
|
2
|
+
import { currentGrantFor, outboxRefFor, rowRef, sessionKey, } from './registry-store.js';
|
|
3
|
+
function defaultSchedule(callback, intervalMs) {
|
|
4
|
+
const timer = setInterval(callback, intervalMs);
|
|
5
|
+
return () => clearInterval(timer);
|
|
6
|
+
}
|
|
7
|
+
// r2 W-P2-1: B signs expiresAt <= min(issuedAt + 15000, G - 5000), where G is
|
|
8
|
+
// the minimum raw current grant expiry. The margin is never subtracted from an
|
|
9
|
+
// already conservative signed expiresAt; the stop check takes the min.
|
|
10
|
+
function signedFreshnessExpiry(issuedAt, grantExpiry) {
|
|
11
|
+
return Math.min(issuedAt + FRESHNESS_BOUND_MS, grantExpiry - FRESHNESS_GRANT_MARGIN_MS);
|
|
12
|
+
}
|
|
13
|
+
export function ensureScheduler(state) {
|
|
14
|
+
if (state.unschedule !== null || state.sessions.size === 0)
|
|
15
|
+
return;
|
|
16
|
+
const schedule = state.input.schedule ?? defaultSchedule;
|
|
17
|
+
state.unschedule = schedule(() => {
|
|
18
|
+
const timestamp = state.now();
|
|
19
|
+
for (const row of state.sessions.values()) {
|
|
20
|
+
if (row.tombstoned || row.quarantined)
|
|
21
|
+
continue;
|
|
22
|
+
const ref = rowRef(state, row);
|
|
23
|
+
if (ref === null)
|
|
24
|
+
continue;
|
|
25
|
+
const grant = currentGrantFor(state, ref);
|
|
26
|
+
if (grant === null)
|
|
27
|
+
continue;
|
|
28
|
+
if (row.lastFreshnessAt !== null && timestamp - row.lastFreshnessAt > FRESHNESS_INTERVAL_MS) {
|
|
29
|
+
row.missedEmission = true;
|
|
30
|
+
}
|
|
31
|
+
if (row.lastFreshnessAt === null || timestamp - row.lastFreshnessAt >= FRESHNESS_INTERVAL_MS) {
|
|
32
|
+
row.lastFreshnessAt = timestamp;
|
|
33
|
+
row.lastFreshnessExpiry = signedFreshnessExpiry(timestamp, grant.expiresAt);
|
|
34
|
+
row.freshnessValid = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, FRESHNESS_INTERVAL_MS);
|
|
38
|
+
}
|
|
39
|
+
export function renewFreshness(state, ref, visibility) {
|
|
40
|
+
if (ref.originInstanceId !== state.input.originInstanceId) {
|
|
41
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
42
|
+
}
|
|
43
|
+
const timestamp = state.now();
|
|
44
|
+
if (!Number.isSafeInteger(timestamp) || timestamp < 0) {
|
|
45
|
+
return { status: 'refused', error: relayError('relay_unavailable') };
|
|
46
|
+
}
|
|
47
|
+
const key = sessionKey(ref);
|
|
48
|
+
const row = state.sessions.get(key);
|
|
49
|
+
if (row === undefined || row.quarantined || row.tombstoned) {
|
|
50
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
51
|
+
}
|
|
52
|
+
const grant = currentGrantFor(state, ref);
|
|
53
|
+
if (grant === null)
|
|
54
|
+
return { status: 'refused', error: relayError('relay_grant_unavailable') };
|
|
55
|
+
if (visibility === 'activated' && !row.activatedRead) {
|
|
56
|
+
return { status: 'refused', error: relayError('relay_scope_refused') };
|
|
57
|
+
}
|
|
58
|
+
if (row.lastFreshnessAt !== null && timestamp - row.lastFreshnessAt < FRESHNESS_INTERVAL_MS) {
|
|
59
|
+
return { status: 'rate-limited', nextEligibleAt: row.lastFreshnessAt + FRESHNESS_INTERVAL_MS };
|
|
60
|
+
}
|
|
61
|
+
const expiry = signedFreshnessExpiry(timestamp, grant.expiresAt);
|
|
62
|
+
if (expiry <= timestamp) {
|
|
63
|
+
return { status: 'refused', error: relayError('relay_grant_expired') };
|
|
64
|
+
}
|
|
65
|
+
row.lastFreshnessAt = timestamp;
|
|
66
|
+
row.lastFreshnessExpiry = expiry;
|
|
67
|
+
row.freshnessValid = true;
|
|
68
|
+
ensureScheduler(state);
|
|
69
|
+
return {
|
|
70
|
+
status: 'remote-unknown',
|
|
71
|
+
sessionRef: { ...ref },
|
|
72
|
+
writerEpoch: row.writerEpoch,
|
|
73
|
+
originRevision: row.originRevision,
|
|
74
|
+
outboxRef: outboxRefFor(key, row.originRevision),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function isLive(state, ref) {
|
|
78
|
+
const row = state.sessions.get(sessionKey(ref));
|
|
79
|
+
if (row === undefined)
|
|
80
|
+
return false;
|
|
81
|
+
if (row.quarantined || row.tombstoned || row.missedEmission || !row.freshnessValid)
|
|
82
|
+
return false;
|
|
83
|
+
if (row.lastFreshnessAt === null)
|
|
84
|
+
return false;
|
|
85
|
+
const timestamp = state.now();
|
|
86
|
+
if (!Number.isSafeInteger(timestamp) || timestamp < 0)
|
|
87
|
+
return false;
|
|
88
|
+
const grant = currentGrantFor(state, ref);
|
|
89
|
+
if (grant === null)
|
|
90
|
+
return false;
|
|
91
|
+
if (timestamp - row.lastFreshnessAt >= FRESHNESS_BOUND_MS)
|
|
92
|
+
return false;
|
|
93
|
+
if (timestamp >= Math.min(row.lastFreshnessExpiry, grant.expiresAt - FRESHNESS_GRANT_MARGIN_MS))
|
|
94
|
+
return false;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
export function restartRegistry(state) {
|
|
98
|
+
for (const row of state.sessions.values()) {
|
|
99
|
+
row.freshnessValid = false;
|
|
100
|
+
row.lastFreshnessAt = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function signFreshness(state, _ref, _visibility) {
|
|
104
|
+
void state;
|
|
105
|
+
throw new Error('SessionOriginRegistry: no enrolled origin registry key in this scope; ' +
|
|
106
|
+
'signed freshness bytes stay fail-closed (source-gap DEP-AUTH-B/M0)');
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=registry-freshness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-freshness.js","sourceRoot":"","sources":["../../src/sessions/registry-freshness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMvH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,MAAM,EACN,UAAU,GACX,MAAM,qBAAqB,CAAC;AAG7B,SAAS,eAAe,CAAC,QAAoB,EAAE,UAAkB;IAC/D,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAChD,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,8EAA8E;AAC9E,+EAA+E;AAC/E,uEAAuE;AACvE,SAAS,qBAAqB,CAAC,QAAgB,EAAE,WAAmB;IAClE,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,kBAAkB,EAAE,WAAW,GAAG,yBAAyB,CAAC,CAAC;AAC1F,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAoB;IAClD,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO;IACnE,MAAM,QAAQ,GAAG,KAA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K,EAAE,GAAG,CAAC,CAAC;IAC1C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,SAAS,GAAG,GAAG,CAAC,eAAe,IAAI,kBAAkB;QAAE,OAAO,KAAK,CAAC;IACxE,IAAI,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,SAAS,GAAG,yBAAyB,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9G,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAoB;IAClD,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QAC1C,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC;QAC3B,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAoB,EAAE,IAAgB,EAAE,WAAuB;IAC3F,KAAK,KAAK,CAAC;IACX,MAAM,IAAI,KAAK,CACb,wEAAwE;QACxE,oEAAoE,CACrE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CapabilitiesRecord, CommitResult, LifecycleFact, ProcessBindingRef } from './registry-types.js';
|
|
2
|
+
import type { RegistryState } from './registry-store.js';
|
|
3
|
+
export declare function ingestLifecycle(state: RegistryState, binding: ProcessBindingRef, fact: LifecycleFact): CommitResult;
|
|
4
|
+
export declare function ingestCapabilities(state: RegistryState, binding: ProcessBindingRef, capabilities: CapabilitiesRecord): CommitResult;
|
|
5
|
+
//# sourceMappingURL=registry-ingest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-ingest.d.ts","sourceRoot":"","sources":["../../src/sessions/registry-ingest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAqBzD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,aAAa,GAClB,YAAY,CAyDd;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,kBAAkB,GAC/B,YAAY,CAuCd"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { LIFECYCLE_EVENT_KINDS, TERMINAL_KINDS, relayError } from './registry-types.js';
|
|
2
|
+
import { createSessionRow, outboxRefFor, sessionKey, } from './registry-store.js';
|
|
3
|
+
import { ensureScheduler } from './registry-freshness.js';
|
|
4
|
+
function validBinding(binding) {
|
|
5
|
+
return (typeof binding.id === 'string' && binding.id.length > 0 &&
|
|
6
|
+
typeof binding.digest === 'string' && binding.digest.length > 0);
|
|
7
|
+
}
|
|
8
|
+
function validFact(fact) {
|
|
9
|
+
const source = fact.sourceRef;
|
|
10
|
+
return (LIFECYCLE_EVENT_KINDS.includes(fact.kind) &&
|
|
11
|
+
typeof source.sourceSessionId === 'string' && source.sourceSessionId.length > 0 &&
|
|
12
|
+
typeof source.sourceGeneration === 'number' && Number.isSafeInteger(source.sourceGeneration) &&
|
|
13
|
+
typeof source.streamIncarnation === 'string' && source.streamIncarnation.length > 0 &&
|
|
14
|
+
typeof fact.sourceAt === 'number' && Number.isFinite(fact.sourceAt) && fact.sourceAt >= 0);
|
|
15
|
+
}
|
|
16
|
+
export function ingestLifecycle(state, binding, fact) {
|
|
17
|
+
const resolveSession = state.input.resolveSession;
|
|
18
|
+
if (resolveSession === undefined) {
|
|
19
|
+
return { status: 'refused', error: relayError('relay_grant_unavailable') };
|
|
20
|
+
}
|
|
21
|
+
if (!validBinding(binding)) {
|
|
22
|
+
return { status: 'refused', error: relayError('relay_auth_required') };
|
|
23
|
+
}
|
|
24
|
+
const ref = resolveSession(binding);
|
|
25
|
+
if (ref === null || ref.originInstanceId !== state.input.originInstanceId) {
|
|
26
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
27
|
+
}
|
|
28
|
+
if (!validFact(fact)) {
|
|
29
|
+
return { status: 'refused', error: relayError('relay_protocol_refused') };
|
|
30
|
+
}
|
|
31
|
+
const key = sessionKey(ref);
|
|
32
|
+
let row = state.sessions.get(key);
|
|
33
|
+
if (row === undefined) {
|
|
34
|
+
row = createSessionRow();
|
|
35
|
+
state.sessions.set(key, row);
|
|
36
|
+
state.refByRow.set(row, { ...ref });
|
|
37
|
+
}
|
|
38
|
+
if (row.quarantined || row.tombstoned) {
|
|
39
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
40
|
+
}
|
|
41
|
+
const factKey = `${String(fact.factRef.id)}:${String(fact.factRef.revision)}`;
|
|
42
|
+
const factDigest = String(fact.factRef.digest);
|
|
43
|
+
const seen = row.seenFacts.get(factKey);
|
|
44
|
+
if (seen !== undefined) {
|
|
45
|
+
if (seen !== factDigest) {
|
|
46
|
+
row.quarantined = true;
|
|
47
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
status: 'local-committed',
|
|
51
|
+
sessionRef: { ...ref },
|
|
52
|
+
writerEpoch: row.writerEpoch,
|
|
53
|
+
originRevision: row.originRevision,
|
|
54
|
+
outboxRef: outboxRefFor(key, row.originRevision),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (!Number.isSafeInteger(row.originRevision) || row.originRevision >= Number.MAX_SAFE_INTEGER) {
|
|
58
|
+
return { status: 'refused', error: relayError('relay_protocol_refused') };
|
|
59
|
+
}
|
|
60
|
+
row.seenFacts.set(factKey, factDigest);
|
|
61
|
+
row.originRevision += 1;
|
|
62
|
+
row.nativeBinding = { ...fact.sourceRef };
|
|
63
|
+
row.state = TERMINAL_KINDS.has(fact.kind) ? 'ended' : 'running';
|
|
64
|
+
if (fact.kind === 'tombstoned')
|
|
65
|
+
row.tombstoned = true;
|
|
66
|
+
ensureScheduler(state);
|
|
67
|
+
return {
|
|
68
|
+
status: 'local-committed',
|
|
69
|
+
sessionRef: { ...ref },
|
|
70
|
+
writerEpoch: row.writerEpoch,
|
|
71
|
+
originRevision: row.originRevision,
|
|
72
|
+
outboxRef: outboxRefFor(key, row.originRevision),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export function ingestCapabilities(state, binding, capabilities) {
|
|
76
|
+
const resolveSession = state.input.resolveSession;
|
|
77
|
+
if (resolveSession === undefined) {
|
|
78
|
+
return { status: 'refused', error: relayError('relay_grant_unavailable') };
|
|
79
|
+
}
|
|
80
|
+
if (!validBinding(binding)) {
|
|
81
|
+
return { status: 'refused', error: relayError('relay_auth_required') };
|
|
82
|
+
}
|
|
83
|
+
const ref = resolveSession(binding);
|
|
84
|
+
if (ref === null || ref.originInstanceId !== state.input.originInstanceId) {
|
|
85
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
86
|
+
}
|
|
87
|
+
const source = capabilities.sourceRef;
|
|
88
|
+
if (source === undefined ||
|
|
89
|
+
typeof source.sourceSessionId !== 'string' || source.sourceSessionId.length === 0) {
|
|
90
|
+
return { status: 'refused', error: relayError('relay_protocol_refused') };
|
|
91
|
+
}
|
|
92
|
+
const key = sessionKey(ref);
|
|
93
|
+
const row = state.sessions.get(key);
|
|
94
|
+
if (row === undefined || row.quarantined || row.tombstoned) {
|
|
95
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
96
|
+
}
|
|
97
|
+
if (!Number.isSafeInteger(row.originRevision) || row.originRevision >= Number.MAX_SAFE_INTEGER) {
|
|
98
|
+
return { status: 'refused', error: relayError('relay_protocol_refused') };
|
|
99
|
+
}
|
|
100
|
+
const hostKind = typeof capabilities.hostKind === 'string' ? capabilities.hostKind : 'claude';
|
|
101
|
+
const known = ['claude', 'codex', 'agy', 'vibe', 'muse', 'app-native'];
|
|
102
|
+
row.providerClass = known.includes(hostKind) ? hostKind : 'other-cli';
|
|
103
|
+
row.capabilities = { ...capabilities };
|
|
104
|
+
row.originRevision += 1;
|
|
105
|
+
return {
|
|
106
|
+
status: 'local-committed',
|
|
107
|
+
sessionRef: { ...ref },
|
|
108
|
+
writerEpoch: row.writerEpoch,
|
|
109
|
+
originRevision: row.originRevision,
|
|
110
|
+
outboxRef: outboxRefFor(key, row.originRevision),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=registry-ingest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-ingest.js","sourceRoot":"","sources":["../../src/sessions/registry-ingest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQxF,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,UAAU,GACX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,SAAS,YAAY,CAAC,OAA0B;IAC9C,OAAO,CACL,OAAO,OAAO,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC;QACvD,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAChE,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAmB;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;IAC9B,OAAO,CACL,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;QACzC,OAAO,MAAM,CAAC,eAAe,KAAK,QAAQ,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;QAC/E,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ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,EAAE,UAAU,CAAC,wBAAwB,CAAC,EAAE,CAAC;IAC5E,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,YAAY,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC9F,MAAM,KAAK,GAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACxF,GAAG,CAAC,aAAa,GAAI,KAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAE,QAA0B,CAAC,CAAC,CAAC,WAAW,CAAC;IACvG,GAAG,CAAC,YAAY,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;IACvC,GAAG,CAAC,cAAc,IAAI,CAAC,CAAC;IACxB,OAAO;QACL,MAAM,EAAE,iBAAiB;QACzB,UAAU,EAAE,EAAE,GAAG,GAAG,EAAE;QACtB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,SAAS,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ListingGrantRecord, ListingRow, PublishResult, RevisionRef, SessionRef } from './registry-types.js';
|
|
2
|
+
import type { RegistryState } from './registry-store.js';
|
|
3
|
+
export declare function publishListing(state: RegistryState, ref: SessionRef, grantRef: RevisionRef): PublishResult;
|
|
4
|
+
export declare function snapshotSession(state: RegistryState, ref: SessionRef): PublishResult;
|
|
5
|
+
export declare function getListingRow(state: RegistryState, ref: SessionRef): ListingRow | null;
|
|
6
|
+
export declare function setActivatedRead(state: RegistryState, ref: SessionRef, enabled: boolean): boolean;
|
|
7
|
+
export declare function subscribeListing(state: RegistryState, ref: SessionRef, callback: (event: {
|
|
8
|
+
readonly kind: string;
|
|
9
|
+
}) => void): () => void;
|
|
10
|
+
export declare function recordRouteState(state: RegistryState, ref: SessionRef, route: {
|
|
11
|
+
readonly routeId: string;
|
|
12
|
+
readonly generation: number;
|
|
13
|
+
readonly state: string;
|
|
14
|
+
}): boolean;
|
|
15
|
+
export declare function registerGrant(state: RegistryState, grant: ListingGrantRecord): void;
|
|
16
|
+
export declare function withdrawGrant(state: RegistryState, grantId: string): void;
|
|
17
|
+
export declare function commitSourceAck(state: RegistryState, ref: SessionRef, grantId: string, ackDigest: string): void;
|
|
18
|
+
//# sourceMappingURL=registry-publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-publish.d.ts","sourceRoot":"","sources":["../../src/sessions/registry-publish.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACX,MAAM,qBAAqB,CAAC;AAY7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAazD,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,GAAG,aAAa,CAmC1G;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,GAAG,aAAa,CAcpF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAUtF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAOjG;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,UAAU,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,GACnD,MAAM,IAAI,CAOZ;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvF,OAAO,CAOT;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAEnF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAWzE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE/G"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { relayError } from './registry-types.js';
|
|
2
|
+
import { buildProjection, currentGrantFor, grantCovers, grantIsCurrent, outboxRefFor, projectionDigestOf, rowRef, sessionKey, snapshotOf, } from './registry-store.js';
|
|
3
|
+
function parseSessionRef(state, ref) {
|
|
4
|
+
if (typeof ref.originInstanceId !== 'string' || ref.originInstanceId.length === 0 ||
|
|
5
|
+
typeof ref.sessionId !== 'string' || ref.sessionId.length === 0 ||
|
|
6
|
+
typeof ref.incarnation !== 'string' || ref.incarnation.length === 0 ||
|
|
7
|
+
ref.originInstanceId !== state.input.originInstanceId) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return { ...ref };
|
|
11
|
+
}
|
|
12
|
+
export function publishListing(state, ref, grantRef) {
|
|
13
|
+
const parsed = parseSessionRef(state, ref);
|
|
14
|
+
if (parsed === null)
|
|
15
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
16
|
+
const grant = state.grants.get(grantRef.id);
|
|
17
|
+
if (grant === undefined)
|
|
18
|
+
return { status: 'refused', error: relayError('relay_grant_unavailable') };
|
|
19
|
+
if (grant.withdrawn)
|
|
20
|
+
return { status: 'refused', error: relayError('relay_grant_revoked') };
|
|
21
|
+
if (!grantIsCurrent(state, grant) || grant.revision !== grantRef.revision) {
|
|
22
|
+
return { status: 'refused', error: relayError('relay_grant_expired') };
|
|
23
|
+
}
|
|
24
|
+
if (!grantCovers(grant, parsed))
|
|
25
|
+
return { status: 'refused', error: relayError('relay_scope_refused') };
|
|
26
|
+
const key = sessionKey(parsed);
|
|
27
|
+
const row = state.sessions.get(key);
|
|
28
|
+
if (row === undefined || row.quarantined) {
|
|
29
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
30
|
+
}
|
|
31
|
+
const ackDigest = state.sourceAcks.get(`${key}|${grant.grantId}`);
|
|
32
|
+
if (ackDigest === undefined) {
|
|
33
|
+
return {
|
|
34
|
+
status: 'remote-unknown',
|
|
35
|
+
sessionRef: parsed,
|
|
36
|
+
writerEpoch: row.writerEpoch,
|
|
37
|
+
originRevision: row.originRevision,
|
|
38
|
+
outboxRef: outboxRefFor(key, row.originRevision),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const projection = buildProjection(parsed, row);
|
|
42
|
+
return {
|
|
43
|
+
status: 'remote-committed',
|
|
44
|
+
sessionRef: parsed,
|
|
45
|
+
writerEpoch: row.writerEpoch,
|
|
46
|
+
originRevision: row.originRevision,
|
|
47
|
+
projection,
|
|
48
|
+
projectionDigest: projectionDigestOf(projection),
|
|
49
|
+
sourceAckDigest: ackDigest,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function snapshotSession(state, ref) {
|
|
53
|
+
const parsed = parseSessionRef(state, ref);
|
|
54
|
+
if (parsed === null)
|
|
55
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
56
|
+
const key = sessionKey(parsed);
|
|
57
|
+
const row = state.sessions.get(key);
|
|
58
|
+
if (row === undefined)
|
|
59
|
+
return { status: 'refused', error: relayError('relay_origin_refused') };
|
|
60
|
+
return {
|
|
61
|
+
status: 'remote-unknown',
|
|
62
|
+
sessionRef: parsed,
|
|
63
|
+
writerEpoch: row.writerEpoch,
|
|
64
|
+
originRevision: row.originRevision,
|
|
65
|
+
outboxRef: outboxRefFor(key, row.originRevision),
|
|
66
|
+
snapshot: snapshotOf(parsed, row),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function getListingRow(state, ref) {
|
|
70
|
+
const parsed = parseSessionRef(state, ref);
|
|
71
|
+
if (parsed === null)
|
|
72
|
+
return null;
|
|
73
|
+
const row = state.sessions.get(sessionKey(parsed));
|
|
74
|
+
if (row === undefined || currentGrantFor(state, parsed) === null)
|
|
75
|
+
return null;
|
|
76
|
+
return {
|
|
77
|
+
visibility: row.activatedRead ? 'activated' : 'listing',
|
|
78
|
+
projection: buildProjection(parsed, row),
|
|
79
|
+
state: row.state,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export function setActivatedRead(state, ref, enabled) {
|
|
83
|
+
const parsed = parseSessionRef(state, ref);
|
|
84
|
+
if (parsed === null)
|
|
85
|
+
return false;
|
|
86
|
+
const row = state.sessions.get(sessionKey(parsed));
|
|
87
|
+
if (row === undefined || currentGrantFor(state, parsed) === null)
|
|
88
|
+
return false;
|
|
89
|
+
row.activatedRead = enabled;
|
|
90
|
+
return enabled;
|
|
91
|
+
}
|
|
92
|
+
export function subscribeListing(state, ref, callback) {
|
|
93
|
+
const parsed = parseSessionRef(state, ref);
|
|
94
|
+
if (parsed === null)
|
|
95
|
+
return () => { };
|
|
96
|
+
const row = state.sessions.get(sessionKey(parsed));
|
|
97
|
+
if (row === undefined)
|
|
98
|
+
return () => { };
|
|
99
|
+
row.subscribers.add(callback);
|
|
100
|
+
return () => { row.subscribers.delete(callback); };
|
|
101
|
+
}
|
|
102
|
+
export function recordRouteState(state, ref, route) {
|
|
103
|
+
const parsed = parseSessionRef(state, ref);
|
|
104
|
+
if (parsed === null)
|
|
105
|
+
return false;
|
|
106
|
+
const row = state.sessions.get(sessionKey(parsed));
|
|
107
|
+
if (row === undefined)
|
|
108
|
+
return false;
|
|
109
|
+
row.routeStates.set(route.routeId, { generation: route.generation, state: route.state });
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
export function registerGrant(state, grant) {
|
|
113
|
+
state.grants.set(grant.grantId, { ...grant });
|
|
114
|
+
}
|
|
115
|
+
export function withdrawGrant(state, grantId) {
|
|
116
|
+
const grant = state.grants.get(grantId);
|
|
117
|
+
if (grant === undefined)
|
|
118
|
+
return;
|
|
119
|
+
state.grants.set(grantId, { ...grant, withdrawn: true });
|
|
120
|
+
for (const row of state.sessions.values()) {
|
|
121
|
+
const ref = rowRef(state, row);
|
|
122
|
+
if (ref === null)
|
|
123
|
+
continue;
|
|
124
|
+
if (currentGrantFor(state, ref) !== null)
|
|
125
|
+
continue;
|
|
126
|
+
for (const subscriber of row.subscribers)
|
|
127
|
+
subscriber({ kind: 'listing-withdrawn' });
|
|
128
|
+
row.subscribers.clear();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export function commitSourceAck(state, ref, grantId, ackDigest) {
|
|
132
|
+
state.sourceAcks.set(`${sessionKey(ref)}|${grantId}`, ackDigest);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=registry-publish.js.map
|