@gregiteen/ssss-cli 0.14.0 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/VERSION +1 -1
- package/conformance/reference-bundle.ucw.json +1 -1
- package/docs/ssss-spec.md +15 -12
- package/package.json +4 -1
- package/registry/core.json +15 -1
- package/schemas/bundle.schema.json +259 -0
- package/schemas/core-registry.schema.json +386 -0
- package/scripts/audit-registry-field-usage.mjs +3 -0
- package/scripts/check-commit-durability.mjs +1 -0
- package/scripts/cmd-schema.mjs +62 -0
- package/scripts/conformance-09.mjs +147 -0
- package/scripts/ssss.mjs +2 -0
- package/skills/ssss/SKILL.md +2 -2
- package/skills/ssss/core/SKILL.md +3 -3
- package/skills/ssss/core/references/core-registry.json +15 -1
- package/skills/ssss/core/references/ssss-spec.md +127 -19
- package/src/authorization.mjs +31 -3
- package/src/engine.mjs +11 -1
- package/src/kernel.mjs +3 -3
- package/src/registry.mjs +82 -3
- package/src/schema-validator.mjs +134 -0
package/skills/ssss/SKILL.md
CHANGED
|
@@ -3,8 +3,8 @@ type: skill
|
|
|
3
3
|
title: SSSS Protocol Reference
|
|
4
4
|
name: ssss
|
|
5
5
|
description: Validate or change SSSS documents, operations, registries, workflows and portable host adapters.
|
|
6
|
-
timestamp: 2026-11-
|
|
7
|
-
version: 0.
|
|
6
|
+
timestamp: 2026-11-02T19:00:00Z
|
|
7
|
+
version: 0.14.2
|
|
8
8
|
repo_scoped: false
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# SSSS portable core — 0.
|
|
1
|
+
# SSSS portable core — 0.14.2
|
|
2
2
|
|
|
3
3
|
Verified against the SSSS owner package, registry and spec on 2026-11-02. Establish ground truth from the installed validator, composed registry plus lock, and actual host mutation path. Schema support does not prove a configured runner or provider integration.
|
|
4
4
|
|
|
@@ -10,9 +10,9 @@ Read only the relevant sections of the [normative spec](references/ssss-spec.md)
|
|
|
10
10
|
Workflow triggers and standalone trigger documents are distinct canonical primitives. A standalone trigger targets a workflow template with parameters; workflows may own inline trigger definitions. Inspect the current registry/spec for required fields and enums. Use the installed runtime adapter to derive deterministic trigger/task/run operations; duplicate ticks replay through idempotency. A cron/interval/webhook/watcher is a wake-up mechanism, not a second scheduling database. Record observed task/run outcomes separately from declaration, enabled state and scheduler handled slots. Explicitly report unsupported host trigger types and missing execution capability.
|
|
11
11
|
|
|
12
12
|
## Bundles and adapters
|
|
13
|
-
Preserve portability classes: structural definitions, tenant-private data and resource-bound requirements. Validate the complete import plan and references before commit, including forward references; missing references reject the import rather than weakening constraints. Check actual host authorization and
|
|
13
|
+
Preserve portability classes: structural definitions, tenant-private data and resource-bound requirements. Validate the complete import plan and references before commit, including forward references and `x_bind` provisioning bindings (`--bind` / `--remap-ids`); missing references or unbound requirements reject the import rather than weakening constraints. Check actual host authorization (`@<glob>` path grants, core aliases `role` ↔ `security_role` and `thread` ↔ `conversation`), optimistic CAS (`expected_before_hash`), schema upgrades (`ssss upgrade`), and wire/MCP transport (`ssss serve`, `ssss bridge`); local fixtures do not prove provider execution. Use source-owned CLI help for flags and inspect structured validity, not process exit alone.
|
|
14
14
|
|
|
15
15
|
## Verification
|
|
16
16
|
Run relevant schema/registry/lock and operation conformance, with valid and invalid examples. Cover duplicate/conflicting idempotency (including retries answered from the event log), unsafe paths, unauthorized/expired actors, leases, append semantics, rollback and commit-intent crash recovery where changed. Use `ssss --help`, then operation-specific help; commands differ by installed version. Report exact package version, registry/lock identity and actual results. Keep secrets and private runtime data out of skill content, bundles and logs.
|
|
17
17
|
|
|
18
|
-
Normative sources are bundled below from the owner release tag v0.
|
|
18
|
+
Normative sources are bundled below from the owner release tag v0.14.2 (`docs/ssss-spec.md` and `registry/core.json` at that tag). Retain authored local wrappers/references; this managed core is the portable update boundary.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://ssss.dev/registry
|
|
2
|
+
"$schema": "https://ssss.dev/schemas/core-registry.schema.json",
|
|
3
3
|
"registry": "core",
|
|
4
4
|
"spec_version": "0.9",
|
|
5
5
|
"description": "The canonical SSSS core registry and semantic application-kernel contract. Core primitives are qualified as ssss:<name>; applications define namespaced primitives through layered extension registries without copying or redefining core behavior.",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"portability": "structural",
|
|
88
88
|
"required_fields": ["type", "name", "permissions"],
|
|
89
89
|
"optional_fields": ["description"],
|
|
90
|
+
"aliases": ["security_role"],
|
|
90
91
|
"notes": "A named set of capabilities used for role-based access control (RBAC). Canonical form of security_role.",
|
|
91
92
|
"spec_ref": "§5.4 role"
|
|
92
93
|
},
|
|
@@ -97,6 +98,8 @@
|
|
|
97
98
|
"portability": "structural",
|
|
98
99
|
"required_fields": ["type", "name", "permissions"],
|
|
99
100
|
"optional_fields": ["description"],
|
|
101
|
+
"aliases": ["role"],
|
|
102
|
+
"notes": "A named set of capabilities used for role-based access control (RBAC). Legacy alias of role.",
|
|
100
103
|
"spec_ref": "§5.4 security_role"
|
|
101
104
|
},
|
|
102
105
|
"task": {
|
|
@@ -149,6 +152,8 @@
|
|
|
149
152
|
"append_only": false,
|
|
150
153
|
"portability": "structural",
|
|
151
154
|
"required_fields": ["type", "model_id", "provider"],
|
|
155
|
+
"deprecated": true,
|
|
156
|
+
"deprecation_notice": "Inert catalog primitive. Modern hosts configure models through provider runtime settings.",
|
|
152
157
|
"spec_ref": "§5.4 model"
|
|
153
158
|
},
|
|
154
159
|
"thread": {
|
|
@@ -158,6 +163,7 @@
|
|
|
158
163
|
"portability": "tenant_private",
|
|
159
164
|
"required_fields": ["type", "thread_id"],
|
|
160
165
|
"optional_fields": ["workspace_id", "user_id", "status", "turn_count", "created_at"],
|
|
166
|
+
"aliases": ["conversation"],
|
|
161
167
|
"notes": "An append-only multi-turn chat transcript. Canonical form of conversation.",
|
|
162
168
|
"spec_ref": "§5.4 thread"
|
|
163
169
|
},
|
|
@@ -167,6 +173,8 @@
|
|
|
167
173
|
"append_only": true,
|
|
168
174
|
"portability": "tenant_private",
|
|
169
175
|
"required_fields": ["type", "thread_id"],
|
|
176
|
+
"aliases": ["thread"],
|
|
177
|
+
"notes": "An append-only multi-turn chat transcript. Legacy alias of thread.",
|
|
170
178
|
"spec_ref": "§5.4 conversation"
|
|
171
179
|
},
|
|
172
180
|
"run": {
|
|
@@ -186,6 +194,8 @@
|
|
|
186
194
|
"portability": "tenant_private",
|
|
187
195
|
"required_fields": ["type", "conflict_id", "status", "new_slug", "existing_slug", "detected_at"],
|
|
188
196
|
"enums": { "status": ["pending", "resolved"] },
|
|
197
|
+
"deprecated": true,
|
|
198
|
+
"deprecation_notice": "Inert meta primitive. Memory collision handling is managed by host memory kernels.",
|
|
189
199
|
"spec_ref": "§5.4 conflict"
|
|
190
200
|
},
|
|
191
201
|
"page": {
|
|
@@ -194,6 +204,8 @@
|
|
|
194
204
|
"append_only": false,
|
|
195
205
|
"portability": "structural",
|
|
196
206
|
"required_fields": ["type", "slug", "name", "sandbox_entry"],
|
|
207
|
+
"deprecated": true,
|
|
208
|
+
"deprecation_notice": "Inert sandbox primitive with iframe assumptions. Superseded by asset and modern UI primitives.",
|
|
197
209
|
"spec_ref": "§5.4 page"
|
|
198
210
|
},
|
|
199
211
|
"migration": {
|
|
@@ -210,6 +222,8 @@
|
|
|
210
222
|
"append_only": false,
|
|
211
223
|
"portability": "structural",
|
|
212
224
|
"required_fields": ["type", "release_id", "version", "schema_version", "summary", "released_at"],
|
|
225
|
+
"deprecated": true,
|
|
226
|
+
"deprecation_notice": "Inert meta primitive. Release tracking is managed by bundle and package manifests.",
|
|
213
227
|
"spec_ref": "§5.4 release"
|
|
214
228
|
},
|
|
215
229
|
"primitive": {
|
|
@@ -250,19 +250,20 @@ primitive — it implements the subset its product requires — but any primitiv
|
|
|
250
250
|
| `assistant` | actor | structural | The definition of an AI assistant/persona. |
|
|
251
251
|
| `workflow` | work | structural | A reusable **task template**: a defined procedure. Firing a workflow submits a `task`. |
|
|
252
252
|
| `trigger` | work | structural | A standalone schedule or event-driven trigger that fires a workflow. |
|
|
253
|
-
| `model` | catalog | structural | The definition of an inference model. |
|
|
253
|
+
| `model` | catalog | structural | The definition of an inference model (deprecated). |
|
|
254
254
|
| `thread` | transcript | tenant_private | An append-only chat transcript. |
|
|
255
255
|
| `conversation` | transcript | tenant_private | An append-only chat transcript. Legacy alias of `thread`. |
|
|
256
256
|
| `run` | transcript | tenant_private | An append-only workflow execution record. |
|
|
257
|
-
| `conflict` | meta | tenant_private | A record of two contradicting primitives, blocking promotion. |
|
|
258
|
-
| `page` | capability | structural | A VFS-native sandboxed custom workspace page. |
|
|
257
|
+
| `conflict` | meta | tenant_private | A record of two contradicting primitives, blocking promotion (deprecated). |
|
|
258
|
+
| `page` | capability | structural | A VFS-native sandboxed custom workspace page (deprecated). |
|
|
259
259
|
| `migration` | meta | structural | An SSSS schema migration state record. |
|
|
260
|
-
| `release` | meta | structural | An SSSS system schema version release record. |
|
|
260
|
+
| `release` | meta | structural | An SSSS system schema version release record (deprecated). |
|
|
261
261
|
| `primitive` | meta | structural | A governed, versioned definition for a namespaced SSSS primitive. |
|
|
262
262
|
|
|
263
263
|
The **Portability** column is the primitive's default portability class (§5.5); a host
|
|
264
|
-
resolves it from `registry/core.json`.
|
|
265
|
-
|
|
264
|
+
resolves it from `registry/core.json`. The canonical machine-readable registry conforms to the
|
|
265
|
+
JSON Schema (Draft 2020-12) published in `schemas/core-registry.schema.json`. Extension registries
|
|
266
|
+
assign their own primitives a class — notably `resource_bound` for things like domains and phone numbers.
|
|
266
267
|
|
|
267
268
|
### 5.2 Contract Primitives
|
|
268
269
|
|
|
@@ -282,7 +283,7 @@ Document primitives are either:
|
|
|
282
283
|
entirely (`memory`, `skill`, `rule`, `security_role`, `task`, `assistant`,
|
|
283
284
|
`workflow`, `model`, `conflict`, `page`, `migration`, `release`, `primitive`).
|
|
284
285
|
- **Append-type** — the file is an ordered, append-only log; writes add records to
|
|
285
|
-
the body and MUST NOT rewrite prior records (`conversation`, `run`).
|
|
286
|
+
the body and MUST NOT rewrite prior records (`thread`, `conversation`, `run`).
|
|
286
287
|
|
|
287
288
|
Append-type documents MUST be mutated only by appending. A host MUST reject an
|
|
288
289
|
operation that would rewrite or remove existing records of an append-type document.
|
|
@@ -629,7 +630,7 @@ Maintains support assistants and records support events.
|
|
|
629
630
|
|
|
630
631
|
#### `model`
|
|
631
632
|
|
|
632
|
-
The definition of an inference model.
|
|
633
|
+
The definition of an inference model. Deprecated: inert catalog primitive; modern hosts configure models through provider runtime settings.
|
|
633
634
|
|
|
634
635
|
REQUIRED: `type`, `model_id`, `provider`.
|
|
635
636
|
|
|
@@ -731,7 +732,7 @@ Collected 12 messages.
|
|
|
731
732
|
|
|
732
733
|
#### `conflict`
|
|
733
734
|
|
|
734
|
-
A record of two contradicting primitives. Blocks promotion until resolved.
|
|
735
|
+
A record of two contradicting primitives. Blocks promotion until resolved. Deprecated: inert meta primitive; memory collision handling is managed by host memory kernels.
|
|
735
736
|
|
|
736
737
|
REQUIRED: `type`, `conflict_id`, `status` (`pending|resolved`), `new_slug`,
|
|
737
738
|
`existing_slug`, `detected_at`.
|
|
@@ -752,7 +753,7 @@ detected_at: 2026-05-16T18:30:00Z
|
|
|
752
753
|
|
|
753
754
|
#### `page`
|
|
754
755
|
|
|
755
|
-
A VFS-native sandboxed custom workspace page.
|
|
756
|
+
A VFS-native sandboxed custom workspace page. Deprecated: inert sandbox primitive with iframe assumptions; superseded by asset and modern UI primitives.
|
|
756
757
|
|
|
757
758
|
REQUIRED: `type`, `slug`, `name`, `sandbox_entry`.
|
|
758
759
|
|
|
@@ -791,7 +792,7 @@ description: "Add vector_embedding field"
|
|
|
791
792
|
|
|
792
793
|
#### `release`
|
|
793
794
|
|
|
794
|
-
An SSSS system schema version release.
|
|
795
|
+
An SSSS system schema version release. Deprecated: inert meta primitive; release tracking is managed by bundle and package manifests.
|
|
795
796
|
|
|
796
797
|
REQUIRED: `type`, `release_id`, `version`, `schema_version`, `summary`, `released_at`.
|
|
797
798
|
|
|
@@ -957,6 +958,7 @@ An envelope is a JSON object:
|
|
|
957
958
|
"path": "assistants/bot/ASSISTANT.md", // vault-relative, no leading "/", no "." or ".." segments
|
|
958
959
|
"content": "---\ntype: …", // operation: full document; event: JSON payload string
|
|
959
960
|
"patches": { }, // patch only
|
|
961
|
+
"expected_before_hash": "sha256:…", // OPTIONAL — asserts target content hash before mutation (§6.1)
|
|
960
962
|
"primitive_type": "assistant", // OPTIONAL — asserts the target's type
|
|
961
963
|
"operation_id": "uuid", // OPTIONAL — client-chosen; generated if absent
|
|
962
964
|
"lease_id": "uuid", // OPTIONAL — §7
|
|
@@ -970,6 +972,14 @@ verified principal, next to the envelope and never inside it (§6.6). A kernel
|
|
|
970
972
|
MUST ignore any identity-bearing field a client places in the envelope, including
|
|
971
973
|
the pre-0.9 `actor` object.
|
|
972
974
|
|
|
975
|
+
A client or bundle provisioner MAY include `expected_before_hash` on an
|
|
976
|
+
`operation` or `patch` envelope to assert that the target document has not been
|
|
977
|
+
modified locally since the intended baseline was read. For a new document creation,
|
|
978
|
+
`expected_before_hash` is `null`. For an update, it is the `sha256:...` digest of
|
|
979
|
+
the baseline content. If the target document's current hash diverges from
|
|
980
|
+
`expected_before_hash` (and its content is not already equal to the intended write),
|
|
981
|
+
the kernel rejects the mutation with `version_conflict`.
|
|
982
|
+
|
|
973
983
|
A `path` MUST be rejected with `invalid_request` if it is empty, absolute, contains
|
|
974
984
|
a backslash or NUL, or has an empty, `.`, or `..` segment. A host MUST also refuse
|
|
975
985
|
to follow a symbolic link out of the vault.
|
|
@@ -1016,7 +1026,7 @@ Kernels MUST NOT reorder or skip stages. Adapters (§6.7) implement mechanics on
|
|
|
1016
1026
|
|---|-------|------------|
|
|
1017
1027
|
| 1 | **Envelope & identity** — known `type`, required fields present and well-typed (§6.2); a principal with an `id` and `kind` is attached. Nothing is read before this passes, so an anonymous caller learns nothing about the vault. | `invalid_request`, `unauthorized` |
|
|
1018
1028
|
| 2 | **Idempotency** — look up (`workspace_id`, `idempotency_key`). Same request hash: return the stored response with `replay: true` and stop. Different hash: stop (§6.4). | `idempotency_conflict` |
|
|
1019
|
-
| 3 | **Read current state** — load the target, if any, and its version. An unsafe path fails here
|
|
1029
|
+
| 3 | **Read current state & base-version check** — load the target, if any, and its version. An unsafe path fails here with `invalid_request`. If `expected_before_hash` is specified: if the target is absent and `expected_before_hash !== null`, or if the target exists and its hash does not match `expected_before_hash` (and its content differs from the intended write), reject with `version_conflict`. | `invalid_request`, `version_conflict`, or `internal_error` for unreadable stored state |
|
|
1020
1030
|
| 4 | **Content validation** — resolve the primitive and validate the resulting document (§9). Enforce type immutability, `immutable_fields`, patch/delete target existence, and append-only rules. | `not_found`, `validation_failed` |
|
|
1021
1031
|
| 5 | **Authorization** — the verified principal must be complete (§6.6), scoped to `workspace_id`, and hold every capability the primitive and action require. | `unauthorized`, `forbidden` |
|
|
1022
1032
|
| 6 | **Lease** — if the primitive is `lease_required` or the host requires a lease for this path, verify it (§7). | `lease_conflict` |
|
|
@@ -1181,6 +1191,11 @@ envelope, after authenticating the caller:
|
|
|
1181
1191
|
it ends in `:*` and the required capability starts with everything before that
|
|
1182
1192
|
`*`. So `ssss:*` covers every core primitive and `ssss:assistant:*` covers every
|
|
1183
1193
|
action on assistants.
|
|
1194
|
+
- A granted capability string MAY include an optional path selector separated by `@`:
|
|
1195
|
+
`<capability>@<glob>` (for example, `ssss:rule:*@rules/marketing/**` or
|
|
1196
|
+
`*:*@capabilities/messaging/**`). When a selector is present, the capability grants
|
|
1197
|
+
permission only when the envelope's target path matches the glob pattern. When omitted,
|
|
1198
|
+
the capability applies workspace-wide.
|
|
1184
1199
|
- A `system` principal bypasses capability checks. It exists for trusted internal
|
|
1185
1200
|
callers such as import (§17). A host MUST NOT grant `system` to anything a remote
|
|
1186
1201
|
caller controls.
|
|
@@ -1215,6 +1230,73 @@ each with a shared contract test in the conformance suite (§12):
|
|
|
1215
1230
|
"Across every writer" means across threads, processes, and hosts sharing the same
|
|
1216
1231
|
storage, not just within one instance.
|
|
1217
1232
|
|
|
1233
|
+
### 6.8 HTTP/JSON Wire Protocol & Subprocess Bridge
|
|
1234
|
+
|
|
1235
|
+
To enable portable, cross-language interoperation across diverse runtimes (Node.js, Python,
|
|
1236
|
+
Ruby, Go, Rust), SSSS defines a normative HTTP/JSON wire transport contract and a standard
|
|
1237
|
+
subprocess bridge. A host or engine that exposes SSSS over a network MUST conform to this
|
|
1238
|
+
wire contract.
|
|
1239
|
+
|
|
1240
|
+
#### Endpoint & HTTP Headers
|
|
1241
|
+
|
|
1242
|
+
- **Endpoint**: `POST /v1/operations` (hosts MAY also route `POST /` to this handler for convenience).
|
|
1243
|
+
- **Request Content-Type**: `application/json`.
|
|
1244
|
+
- **Response Content-Type**: `application/json`.
|
|
1245
|
+
- **Authentication**: When remote authentication is required, the client MUST present
|
|
1246
|
+
a bearer token via the `Authorization: Bearer <token>` HTTP header. The host verifies
|
|
1247
|
+
the token and resolves it out-of-band to a verified principal (§6.6). The envelope body
|
|
1248
|
+
itself carries no secret credentials.
|
|
1249
|
+
- **Health check**: A host exposing the HTTP interface SHOULD expose `GET /health`, returning
|
|
1250
|
+
HTTP 200 with `{ "ok": true, "version": "<version>" }`.
|
|
1251
|
+
|
|
1252
|
+
#### Request and Response Wire Contract
|
|
1253
|
+
|
|
1254
|
+
- **Request Body**: An Operation Contract envelope (§6.1, §6.2) as a JSON object:
|
|
1255
|
+
```json
|
|
1256
|
+
{
|
|
1257
|
+
"type": "operation",
|
|
1258
|
+
"idempotency_key": "00000000-0000-0000-0000-000000000001",
|
|
1259
|
+
"path": "assistants/support-bot.md",
|
|
1260
|
+
"workspace_id": "ws-main",
|
|
1261
|
+
"content": "---\ntype: assistant\nname: Support Bot\ntitle: Support Bot\ndescription: Customer support assistant\ntimestamp: 2026-07-02T00:00:00Z\n---\nHelp customers.\n"
|
|
1262
|
+
}
|
|
1263
|
+
```
|
|
1264
|
+
Callers attaching an explicit principal context MAY submit:
|
|
1265
|
+
```json
|
|
1266
|
+
{
|
|
1267
|
+
"envelope": {
|
|
1268
|
+
"type": "operation",
|
|
1269
|
+
"idempotency_key": "00000000-0000-0000-0000-000000000001",
|
|
1270
|
+
"path": "assistants/support-bot.md",
|
|
1271
|
+
"workspace_id": "ws-main",
|
|
1272
|
+
"content": "---\ntype: assistant\nname: Support Bot\ntitle: Support Bot\ndescription: Customer support assistant\ntimestamp: 2026-07-02T00:00:00Z\n---\nHelp customers.\n"
|
|
1273
|
+
},
|
|
1274
|
+
"principal": {
|
|
1275
|
+
"id": "agent-1",
|
|
1276
|
+
"kind": "agent",
|
|
1277
|
+
"workspaceIds": ["ws-main"],
|
|
1278
|
+
"capabilities": ["*:*"],
|
|
1279
|
+
"authentication": { "provider": "token", "assurance": "verified" }
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
```
|
|
1283
|
+
- **Response Body**: The kernel response object (§6.5) serialized as JSON:
|
|
1284
|
+
- On commit: `201 Created` with `{ "success": true, "type": "operation", ... }`.
|
|
1285
|
+
- On idempotent replay or dry run: `200 OK` with `{ "success": true, "replay": true, ... }`.
|
|
1286
|
+
- On error: status mapped from `ERROR_STATUS` (§6.5) with `{ "success": false, "error": { "code": "...", "message": "..." } }`.
|
|
1287
|
+
|
|
1288
|
+
#### Subprocess Bridge Contract (`ssss bridge`)
|
|
1289
|
+
|
|
1290
|
+
For local process orchestration without opening network ports (for example, Python hosts
|
|
1291
|
+
integrating SSSS as a subprocess), the reference CLI provides `ssss bridge`:
|
|
1292
|
+
|
|
1293
|
+
- Reads JSON from standard input (`stdin`). Supports:
|
|
1294
|
+
1. A single JSON request object.
|
|
1295
|
+
2. A JSON array of requests (`[...]`).
|
|
1296
|
+
3. Newline-delimited JSON (`NDJSON`), with one request per line when running with `--stream`.
|
|
1297
|
+
- Writes JSON response objects to standard output (`stdout`) matching the wire contract shape.
|
|
1298
|
+
- Does not alter envelope semantics, schema validation, or error status mappings.
|
|
1299
|
+
|
|
1218
1300
|
---
|
|
1219
1301
|
|
|
1220
1302
|
## 7. Leases — Concurrency Control
|
|
@@ -1788,7 +1870,9 @@ A bundle is a JSON object with three top-level members:
|
|
|
1788
1870
|
```
|
|
1789
1871
|
|
|
1790
1872
|
`files` MUST be sorted by `path` (§16.3 order) so that two exports of the same vault state
|
|
1791
|
-
are identical and content-hashable (§16.3, `provenance.content_hash`).
|
|
1873
|
+
are identical and content-hashable (§16.3, `provenance.content_hash`). The normative JSON Schema
|
|
1874
|
+
(Draft 2020-12) for `.ucw` bundle containers is published in `schemas/bundle.schema.json` and
|
|
1875
|
+
exportable via the CLI command `ssss schema bundle`.
|
|
1792
1876
|
|
|
1793
1877
|
### 16.2 The Manifest
|
|
1794
1878
|
|
|
@@ -1868,6 +1952,23 @@ of `source: user` or `source: system` — e.g. the phone number, domain, and mai
|
|
|
1868
1952
|
must bind. This is how the standard guarantees a sold business says exactly what real-world
|
|
1869
1953
|
resources it needs without shipping the seller's own.
|
|
1870
1954
|
|
|
1955
|
+
#### 16.5.1 Frontmatter Parameter Binding (`x_bind`)
|
|
1956
|
+
|
|
1957
|
+
Values bind exclusively through **frontmatter**, never through free-text string substitution in Markdown body text. A template document declares frontmatter parameter bindings using the reserved `x_bind` mapping:
|
|
1958
|
+
|
|
1959
|
+
```yaml
|
|
1960
|
+
x_bind:
|
|
1961
|
+
channel_id: support_channel_id
|
|
1962
|
+
notify_email: primary_admin_email
|
|
1963
|
+
```
|
|
1964
|
+
|
|
1965
|
+
During `provisionBundle` (§17.1):
|
|
1966
|
+
1. For each `field: parameter_key` entry in `x_bind`, the provisioner resolves the value from the supplied `parameters` dictionary, or the parameter's `defaultValue` if omitted.
|
|
1967
|
+
2. If a parameter is `required: true` and has no supplied value or default, provisioning fails with `unresolved`.
|
|
1968
|
+
3. The resolved value MUST match the parameter's declared `type` (`string`, `boolean`, `number`, etc.).
|
|
1969
|
+
4. The target frontmatter field is assigned the resolved value, and the `x_bind` property is stripped from the provisioned output document.
|
|
1970
|
+
5. In `template` and `sale` export profiles (§5.5), when `reduceResourceBoundFile()` strips sensitive infrastructure values from `resource.binds` (such as domain names or phone numbers), it automatically emits corresponding `x_bind` bindings targeting the synthesized resource requirement parameters.
|
|
1971
|
+
|
|
1871
1972
|
---
|
|
1872
1973
|
|
|
1873
1974
|
## 17. The Provisioning Contract
|
|
@@ -1916,12 +2017,18 @@ binding each requires.
|
|
|
1916
2017
|
### 17.3 Determinism, Id-Remap & Link Integrity
|
|
1917
2018
|
|
|
1918
2019
|
When a bundle is provisioned into a target vault, identifiers (slugs, workspace ids,
|
|
1919
|
-
cross-file links) are **remapped** so the imported business is a fresh, self-consistent
|
|
1920
|
-
instance rather than a clone aliasing the seller's ids.
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
2020
|
+
cross-file links, and typed references) are **remapped** so the imported business is a fresh, self-consistent
|
|
2021
|
+
instance rather than a clone aliasing the seller's ids.
|
|
2022
|
+
|
|
2023
|
+
Given a target `workspaceId` and optional `pathPrefix`:
|
|
2024
|
+
1. **Deterministic ID Map:** Every source identifier or slug derives a deterministic target identifier:
|
|
2025
|
+
`newId = "<pathPrefix>-" + sha256(workspaceId + ":" + sourceId).slice(0, 12)`
|
|
2026
|
+
2. **Path Prefixing:** Target file paths are placed under the path prefix:
|
|
2027
|
+
`targetPath = pathPrefix ? `${pathPrefix}/${sourcePath}` : sourcePath`
|
|
2028
|
+
3. **Identifier Fields:** Frontmatter identifier fields (`slug`, `id`, `workflow_id`, `run_id`, `task_id`, `migration_id`) are mapped to their derived `newId`.
|
|
2029
|
+
4. **Link Rewriting:** Body wiki-links `[[source-slug]]` and relative Markdown links `[title](source-path.md)` are rewritten to the target slug and target relative path.
|
|
2030
|
+
5. **Registry-Declared Typed References (§9):** Frontmatter fields constrained by `references` (e.g. `asset.resource_ref`, `trigger.target_workflow`) that point to relative paths within the bundle MUST be rewritten to point to their remapped target paths under `pathPrefix`.
|
|
2031
|
+
6. **Link & Reference Integrity:** Remapping MUST preserve link integrity: every internal `[[link]]`, relative markdown link, and typed frontmatter reference that resolved in the source bundle MUST resolve to the remapped target after import. An importer that cannot resolve a link or reference MUST fail the provision (`danglingLinks`) rather than emit a dangling reference.
|
|
1925
2032
|
|
|
1926
2033
|
### 17.4 Composition & Upgrade
|
|
1927
2034
|
|
|
@@ -1946,6 +2053,7 @@ MUST NOT be repurposed by hosts:
|
|
|
1946
2053
|
`aliases`, `feedback`, `confidence`.
|
|
1947
2054
|
- Lifecycle: `slug`, `schema_version`, `status`.
|
|
1948
2055
|
- Portability (§5.5): `x_portability`.
|
|
2056
|
+
- Parameter Binding (§16.5): `x_bind`.
|
|
1949
2057
|
|
|
1950
2058
|
The patch key `__body__` (§6.2) is reserved and can never be a frontmatter key.
|
|
1951
2059
|
|
package/src/authorization.mjs
CHANGED
|
@@ -65,17 +65,45 @@ export function createCapabilityAuthorizer(options = {}) {
|
|
|
65
65
|
if (principal.kind !== 'system' && !principal.workspaceIds.includes(workspaceId)) {
|
|
66
66
|
return { allowed: false, reason: `Principal '${principal.id}' is not scoped to workspace '${workspaceId}'.` };
|
|
67
67
|
}
|
|
68
|
-
const
|
|
68
|
+
const namespace = definition?.namespace || 'ssss';
|
|
69
|
+
const aliases = Array.isArray(definition?.aliases) ? definition.aliases : [];
|
|
70
|
+
const floorKeys = new Set(
|
|
71
|
+
[
|
|
72
|
+
definition?.qualified_type,
|
|
73
|
+
definition?.primitive_id,
|
|
74
|
+
definition?.type,
|
|
75
|
+
...aliases.flatMap((alias) => [
|
|
76
|
+
alias,
|
|
77
|
+
alias.includes(':') ? alias : `${namespace}:${alias}`,
|
|
78
|
+
]),
|
|
79
|
+
].filter(Boolean),
|
|
80
|
+
);
|
|
81
|
+
const floorCapabilities = [...floorKeys].flatMap((key) => policyFloors[key]?.[action] || []);
|
|
69
82
|
const required = new Set([
|
|
70
83
|
...requiredCapabilities(definition, action),
|
|
71
|
-
...
|
|
84
|
+
...floorCapabilities,
|
|
72
85
|
...(context.policyFloor || []),
|
|
73
86
|
]);
|
|
74
87
|
const granted = new Set(principal.capabilities || []);
|
|
75
88
|
if (principal.kind === 'system' && options.systemBypass !== false) return { allowed: true, required: [...required] };
|
|
76
89
|
const targetPath = context.path || null;
|
|
90
|
+
const defPrefixes = [...new Set([definition?.qualified_type, definition?.primitive_id, definition?.type].filter(Boolean))];
|
|
77
91
|
const missing = [...required].filter((capability) =>
|
|
78
|
-
![...granted].some((grant) =>
|
|
92
|
+
![...granted].some((grant) => {
|
|
93
|
+
if (capabilityCovers(grant, capability, targetPath)) return true;
|
|
94
|
+
if (!aliases.length) return false;
|
|
95
|
+
const matchedPrefix = defPrefixes.find((prefix) => capability.startsWith(`${prefix}:`));
|
|
96
|
+
if (!matchedPrefix) return false;
|
|
97
|
+
const actionTail = capability.slice(matchedPrefix.length + 1);
|
|
98
|
+
return aliases.some((alias) => {
|
|
99
|
+
const qualifiedAlias = alias.includes(':') ? alias : `${namespace}:${alias}`;
|
|
100
|
+
const bareAlias = alias.includes(':') ? alias.slice(alias.indexOf(':') + 1) : alias;
|
|
101
|
+
return (
|
|
102
|
+
capabilityCovers(grant, `${qualifiedAlias}:${actionTail}`, targetPath) ||
|
|
103
|
+
capabilityCovers(grant, `${bareAlias}:${actionTail}`, targetPath)
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
}));
|
|
79
107
|
if (missing.length) return { allowed: false, required: [...required], missing, reason: `Missing capabilities: ${missing.join(', ')}.` };
|
|
80
108
|
if (context.requiresHumanConfirmation && principal.kind !== 'human') {
|
|
81
109
|
return { allowed: false, required: [...required], reason: 'A verified human confirmation is required.' };
|
package/src/engine.mjs
CHANGED
|
@@ -39,7 +39,17 @@ export function legacyRoleCapabilities(permissions, registrySet) {
|
|
|
39
39
|
if (permission === 'write:*' || permission === '*:*') { capabilities.add('*:*'); continue; }
|
|
40
40
|
const match = permission.match(/^(write|\*):(.+)$/);
|
|
41
41
|
const definition = match && resolvePrimitiveDefinition(registrySet, match[2]);
|
|
42
|
-
if (definition?.qualified_type)
|
|
42
|
+
if (definition?.qualified_type) {
|
|
43
|
+
capabilities.add(`${definition.qualified_type}:*`);
|
|
44
|
+
const prefix = definition.qualified_type.includes(':')
|
|
45
|
+
? definition.qualified_type.split(':')[0]
|
|
46
|
+
: 'ssss';
|
|
47
|
+
for (const alias of definition.aliases || []) {
|
|
48
|
+
capabilities.add(`${prefix}:${alias}:*`);
|
|
49
|
+
capabilities.add(`write:${alias}`);
|
|
50
|
+
capabilities.add(`*:${alias}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
54
|
return [...capabilities];
|
|
45
55
|
}
|
package/src/kernel.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
6
|
import { parseDocument, serializeDocument } from './frontmatter.mjs';
|
|
7
7
|
import { createValidator } from './validator.mjs';
|
|
8
|
-
import { isAppendType, isSafeDocumentPath, resolvePortability, resolvePrimitiveDefinition } from './registry.mjs';
|
|
8
|
+
import { isAppendType, isSafeDocumentPath, resolvePortability, resolvePrimitiveDefinition, isSamePrimitiveType } from './registry.mjs';
|
|
9
9
|
import { createCapabilityAuthorizer, validateVerifiedPrincipal } from './authorization.mjs';
|
|
10
10
|
import { createCanonicalEvent, idempotentEventId } from './events.mjs';
|
|
11
11
|
import { MemoryIdempotencyStore } from './idempotency.mjs';
|
|
@@ -284,7 +284,7 @@ export function createKernel(options = {}) {
|
|
|
284
284
|
nextContent = envelope.content;
|
|
285
285
|
nextData = validation.data;
|
|
286
286
|
}
|
|
287
|
-
if (currentData?.type && currentData.type
|
|
287
|
+
if (currentData?.type && !isSamePrimitiveType(registrySet, currentData.type, nextData.type)) {
|
|
288
288
|
return failure('validation_failed', envelope, operationId, ['Operation may not change an existing document type.'], [{ field: 'type', issue: 'Use an explicit migration.' }]);
|
|
289
289
|
}
|
|
290
290
|
// Replaying an identical full operation is a no-op, not a replace. This must
|
|
@@ -317,7 +317,7 @@ export function createKernel(options = {}) {
|
|
|
317
317
|
if (!current) return failure('not_found', envelope, operationId, ['Patch target does not exist.'], [{ field: 'path', issue: 'Target not found.' }]);
|
|
318
318
|
definition = resolvePrimitiveDefinition(registrySet, declaredType);
|
|
319
319
|
if (!definition) return failure('validation_failed', envelope, operationId, [`Unknown SSSS primitive '${declaredType}'.`], [{ field: 'type', issue: 'Unknown primitive.' }]);
|
|
320
|
-
if (Object.hasOwn(envelope.patches, 'type') && envelope.patches.type
|
|
320
|
+
if (Object.hasOwn(envelope.patches, 'type') && !isSamePrimitiveType(registrySet, envelope.patches.type, currentData.type)) {
|
|
321
321
|
return failure('validation_failed', envelope, operationId, ['Patch may not change document type.'], [{ field: 'type', issue: 'Use an explicit migration.' }]);
|
|
322
322
|
}
|
|
323
323
|
nextData = { ...currentData, ...Object.fromEntries(Object.entries(envelope.patches).filter(([key]) => key !== '__body__')) };
|
package/src/registry.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
16
16
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
17
17
|
const DEFAULT_REGISTRY_DIR = path.resolve(__dirname, '..', 'registry');
|
|
18
18
|
|
|
19
|
-
const APPEND_TYPES = new Set(['conversation', 'run']);
|
|
19
|
+
const APPEND_TYPES = new Set(['conversation', 'run', 'thread']);
|
|
20
20
|
const SAFE_REGISTRY_NAME = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
21
21
|
const SAFE_TYPE_NAME = /^(?:[a-z][a-z0-9_-]{0,63}:)?[a-z][a-z0-9_-]{0,127}$/;
|
|
22
22
|
const SAFE_FIELD_NAME = /^[A-Za-z_][A-Za-z0-9_-]*$/;
|
|
@@ -52,6 +52,13 @@ function validatePrimitiveDefinition(name, def, source, portabilityClasses) {
|
|
|
52
52
|
assertStringArray(def.required_fields, `${source}: primitive '${name}' required_fields`);
|
|
53
53
|
assertStringArray(def.optional_fields, `${source}: primitive '${name}' optional_fields`);
|
|
54
54
|
assertStringArray(def.immutable_fields, `${source}: primitive '${name}' immutable_fields`);
|
|
55
|
+
assertStringArray(def.aliases, `${source}: primitive '${name}' aliases`);
|
|
56
|
+
if (def.deprecated !== undefined && typeof def.deprecated !== 'boolean') {
|
|
57
|
+
throw new Error(`${source}: primitive '${name}' deprecated must be a boolean.`);
|
|
58
|
+
}
|
|
59
|
+
if (def.deprecation_notice !== undefined && typeof def.deprecation_notice !== 'string') {
|
|
60
|
+
throw new Error(`${source}: primitive '${name}' deprecation_notice must be a string.`);
|
|
61
|
+
}
|
|
55
62
|
|
|
56
63
|
assertRecord(def.required_when, `${source}: primitive '${name}' required_when`);
|
|
57
64
|
for (const [condition, fields] of Object.entries(def.required_when || {})) {
|
|
@@ -157,6 +164,33 @@ export function composeRegistries({ core, extensions: extensionInputs = [] } = {
|
|
|
157
164
|
aliases.set(`ssss:${name}`, name);
|
|
158
165
|
}
|
|
159
166
|
|
|
167
|
+
for (const [name, def] of Object.entries(core.document_primitives || {})) {
|
|
168
|
+
for (const alias of def.aliases || []) {
|
|
169
|
+
if (!isPrimitiveTypeName(alias)) {
|
|
170
|
+
throw new Error(`core registry: primitive '${name}' has unsafe alias '${alias}'.`);
|
|
171
|
+
}
|
|
172
|
+
const bareAlias = alias.startsWith('ssss:') ? alias.slice('ssss:'.length) : alias;
|
|
173
|
+
const qualifiedAlias = alias.includes(':') ? alias : `ssss:${alias}`;
|
|
174
|
+
if (bareAlias === name) {
|
|
175
|
+
throw new Error(`core registry: primitive '${name}' cannot alias itself.`);
|
|
176
|
+
}
|
|
177
|
+
if (types.has(bareAlias)) {
|
|
178
|
+
const peer = types.get(bareAlias);
|
|
179
|
+
const peerAliases = (peer.aliases || []).map((a) => (a.startsWith('ssss:') ? a.slice('ssss:'.length) : a));
|
|
180
|
+
if (!peerAliases.includes(name)) {
|
|
181
|
+
throw new Error(`core registry: primitive alias '${alias}' on '${name}' collides with existing primitive '${bareAlias}'.`);
|
|
182
|
+
}
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if ((aliases.has(bareAlias) && aliases.get(bareAlias) !== name) ||
|
|
186
|
+
(aliases.has(qualifiedAlias) && aliases.get(qualifiedAlias) !== name)) {
|
|
187
|
+
throw new Error(`core registry: primitive alias '${alias}' collides with an existing primitive.`);
|
|
188
|
+
}
|
|
189
|
+
aliases.set(bareAlias, name);
|
|
190
|
+
aliases.set(qualifiedAlias, name);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
160
194
|
for (const [index, item] of extensionInputs.entries()) {
|
|
161
195
|
const { source, value: ext } = normalizeExtensionInput(item, index);
|
|
162
196
|
if (!SAFE_REGISTRY_NAME.test(ext.registry || '')) {
|
|
@@ -232,6 +266,14 @@ export function composeRegistries({ core, extensions: extensionInputs = [] } = {
|
|
|
232
266
|
);
|
|
233
267
|
}
|
|
234
268
|
}
|
|
269
|
+
const aliasOverlap = (constraint.allowed_types || []).filter((allowed) =>
|
|
270
|
+
(constraint.disallowed_types || []).some((disallowed) => isSamePrimitiveType(registrySet, allowed, disallowed))
|
|
271
|
+
);
|
|
272
|
+
if (aliasOverlap.length) {
|
|
273
|
+
throw new Error(
|
|
274
|
+
`registry '${def.registry}' primitive '${def.type}' reference '${field}' both allows and forbids (via alias): ${aliasOverlap.join(', ')}.`
|
|
275
|
+
);
|
|
276
|
+
}
|
|
235
277
|
}
|
|
236
278
|
}
|
|
237
279
|
|
|
@@ -297,6 +339,42 @@ export function resolvePrimitiveDefinition(registrySet, type) {
|
|
|
297
339
|
return local ? registrySet.types.get(local) || null : null;
|
|
298
340
|
}
|
|
299
341
|
|
|
342
|
+
/**
|
|
343
|
+
* Return all equivalent primitive definitions for a type or definition
|
|
344
|
+
* (the definition itself plus any definitions linked via `aliases`).
|
|
345
|
+
*/
|
|
346
|
+
export function resolveEquivalentDefinitions(registrySet, typeOrDef) {
|
|
347
|
+
const base = typeof typeOrDef === 'string'
|
|
348
|
+
? resolvePrimitiveDefinition(registrySet, typeOrDef)
|
|
349
|
+
: typeOrDef;
|
|
350
|
+
if (!base) return [];
|
|
351
|
+
const seen = new Map([[base.qualified_type || base.type, base]]);
|
|
352
|
+
for (const alias of base.aliases || []) {
|
|
353
|
+
const target = resolvePrimitiveDefinition(registrySet, alias);
|
|
354
|
+
if (target && !seen.has(target.qualified_type || target.type)) {
|
|
355
|
+
seen.set(target.qualified_type || target.type, target);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return [...seen.values()];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Return true if two primitive type identifiers resolve to the same canonical
|
|
363
|
+
* primitive definition (either exact match, qualified match, or mutual alias).
|
|
364
|
+
*/
|
|
365
|
+
export function isSamePrimitiveType(registrySet, typeA, typeB) {
|
|
366
|
+
if (typeA === typeB) return true;
|
|
367
|
+
if (!typeA || !typeB) return false;
|
|
368
|
+
const defA = resolvePrimitiveDefinition(registrySet, typeA);
|
|
369
|
+
const defB = resolvePrimitiveDefinition(registrySet, typeB);
|
|
370
|
+
if (!defA || !defB) return false;
|
|
371
|
+
if (defA.qualified_type === defB.qualified_type) return true;
|
|
372
|
+
const equivalentsA = resolveEquivalentDefinitions(registrySet, defA);
|
|
373
|
+
if (equivalentsA.some((d) => d.qualified_type === defB.qualified_type)) return true;
|
|
374
|
+
const equivalentsB = resolveEquivalentDefinitions(registrySet, defB);
|
|
375
|
+
return equivalentsB.some((d) => d.qualified_type === defA.qualified_type);
|
|
376
|
+
}
|
|
377
|
+
|
|
300
378
|
/**
|
|
301
379
|
* Names of the extensions loaded when a caller does not scope the load.
|
|
302
380
|
*
|
|
@@ -472,14 +550,15 @@ export function validateReferenceConstraints(typeDef, data, resolveReference, ty
|
|
|
472
550
|
continue;
|
|
473
551
|
}
|
|
474
552
|
const referencedType = referenced.data?.type;
|
|
553
|
+
const registrySurface = { types, aliases: types.aliases };
|
|
475
554
|
if (!lookupType(referencedType)) {
|
|
476
555
|
issues.push({ field, issue: `Referenced document declares unknown type '${referencedType || '(missing)'}'.` });
|
|
477
556
|
continue;
|
|
478
557
|
}
|
|
479
|
-
if (constraint.allowed_types && !constraint.allowed_types.
|
|
558
|
+
if (constraint.allowed_types && !constraint.allowed_types.some((allowed) => isSamePrimitiveType(registrySurface, allowed, referencedType))) {
|
|
480
559
|
issues.push({ field, issue: `Referenced type '${referencedType}' is not allowed.` });
|
|
481
560
|
}
|
|
482
|
-
if (constraint.disallowed_types?.
|
|
561
|
+
if (constraint.disallowed_types?.some((disallowed) => isSamePrimitiveType(registrySurface, disallowed, referencedType))) {
|
|
483
562
|
issues.push({ field, issue: `Referenced type '${referencedType}' is forbidden.` });
|
|
484
563
|
}
|
|
485
564
|
const referencedPortability = resolvePortability(lookupType(referencedType), referenced.data);
|