Experimental PHC exchange binding

Exchange 0.1.0-draft · Validator implementation 0.1.1 · 15 October 2026

This binding makes a deliberately bounded part of the PHC semantic proposal executable. Its format is phc-exchange-experimental, version 0.1.0-draft, with schema identifier urn:phc:experimental:exchange:0.1.0. These are local experimental identifiers, not registered media types, OAuth authorization-detail types, or an adopted PHC release. The experimental: capability vocabulary is likewise local to this kit.

The semantic specification remains the broader proposal. Unknown mandatory capabilities and unsupported structure are rejected. Recognized restriction forms can pass offline inspection while their evaluation still requires a receiving service; those checks are reported explicitly and activation remains blocked. This does not convert a mandatory restriction to a preference. The kit accepts no credentials or grants as structural fields and performs no network resolution. Data hidden inside statement text cannot be comprehensively classified or detected as a secret.

1. What the utility actually does

The validator checks bounded JSON parsing, the included JSON Schema, and the specific cross-object consistency conditions described below. It does not evaluate every recognized restriction against an actual operation. A passing result is exactly valid_for_quarantine with activation: blocked. That means the document is a candidate for a receiving service's protected review flow. There is no import database, proof authentication, subject linking, replay ledger, revocation feed, trusted lifecycle checkpoint, or permission grant in this utility.

A production importer must independently establish origin, integrity, recipient binding, export authority, identity/custody mappings, classification semantics, safety sequence completeness, replay prevention and local policy. It must hold content in a protected compartment until those checks and required reviews complete. Its activation transaction must establish fresh local authority; historical confirmation is not local consent.

2. Grammar and limits

exchange.schema.json is the exact machine-readable grammar. Every listed object is closed to unknown properties. Schema changes require an explicit experimental version review; a successful parse does not make a document cryptographically trusted.

Boundary Limit or rule
Input UTF-8; 1 MiB uncompressed; no BOM; no decompression performed
Parser 32 nested container levels; 50,000 values; 16,384 UTF-16 units per string
Identifiers 1–160 ASCII characters, exact and case-sensitive; no implicit normalization
Records / rules / tombstones / mappings At most 256 each
Personas / identity mappings At most 32 each
Statement 1–4,096 Unicode code points, additionally subject to parser limit
Version / sequence Safe JSON integers; version positive, checkpoint sequence nonnegative
Time Real calendar date, whole seconds, YYYY-MM-DDTHH:mm:ssZ; no leap second or offset form
Import time Explicit --at in reproducible tests; system UTC clock by default; zero skew in this offline profile
Relationships Empty only; graph transport remains unimplemented
References Opaque data; never fetched, followed, or executed
Errors At most 32 codes/structural paths; no offending statement, arbitrary reference or unknown field name echoed

Duplicate object keys are rejected after JSON escape decoding. Invalid Unicode, nonfinite numbers, oversized strings, excess depth and malformed JSON are rejected before schema validation. Numeric identifiers and arbitrary JSON policy scripts are excluded. The shared decodeUTF8(bytes) helper rejects invalid byte sequences as INPUT_UTF8, oversized bytes as INPUT_SIZE, and a leading UTF-8 BOM as INPUT_BOM; it never silently strips a BOM. parseStrict(text) also rejects a leading U+FEFF as INPUT_BOM.

3. Attributed records and personas

The binding supports statement-bearing fact, goal, preference and episode records, with the four proposed assertion types and five nondeleted lifecycle states. A statement may still be false, malicious, historical or disputed. The source namespace must match the exporter and each record must have one corresponding source identity tuple, explicit custody, a versioned migration entry and a classification from the local experimental vocabulary.

Classification labels ordinary, sensitive, restricted are ordered only inside this experimental vocabulary. They are not legal categories or mappings to an employer's policy. Another vocabulary requires a new reviewed binding or explicit trusted mapping; this kit rejects it. All records in a bundle share the scoped lifecycle collection. Cross-custodian bundles are not admitted in this slice.

The binding preserves producer versus reported run/release information. Evidence is explicitly unverified or unavailable. A historical confirmation identifies the exact reviewed record version and timestamp; it neither changes an inference's assertion type nor activates the record. user_stated is preserved as a source claim pending destination verification, not authenticated by the validator.

Personas contain explicit record associations, advisory preferences and optional restrictions. They cannot carry grants. A cross-custodian persona association is rejected. One record's restrictions remain attached when associated with a persona.

4. Mandatory restrictions

Every rule has an origin, positive version, record scope, exact capability, typed operands and mandatory: true. Rules must be declared in required_capabilities and be attached to every record in their scope. Parent rules must also cover a derivative explicitly; merely dropping the parent's rule references fails validation.

Capability suffix (experimental:restriction-…:1) Meaning at the eventual service boundary
purposes-subset Requested purpose appears in every applicable set
processing-routes-subset Every actual processing destination is in the intersection
operations-subset Requested operation appears in every applicable set
recipients-subset Exact verified recipient appears in every applicable set
not-after No new operation at or after the deadline
review-required Recipient and record version have the required authorized share/export review
export-forbidden Matched records cannot enter a customer portability export
delegation-forbidden No downstream delegation; absence supplies no authority
qualification-required Current, scope-matching qualification is an additional prerequisite

The offline validator rejects explicit export prohibition, rule deadlines at or before the evaluation clock, and a declared export purpose outside an applicable purpose set. These are bounded checks of the document and evaluation clock. It checks recognized rules' typed operand shapes, declared capabilities, scope resolution, attachment and inheritance. It does not compare processing routes with an actual runtime route, select a requested operation, evaluate recipient-set membership, establish authorized review, enforce delegation prohibition, or establish current qualification. Those six rule families report requires_service, including when the envelope's expected recipient reference matches. Receivers must evaluate every applicable rule against the actual operation. A rule recognized by this library is not a qualified service capability.

--recipient REF compares only the caller-supplied expected reference with intended_recipient_ref. It does not authenticate that reference, identify an eventual service principal, or evaluate recipients-subset. The role of the recipient in that rule and its trusted mapping to a service principal require a subsequent design decision; this offline profile does not invent that mapping.

5. Dependencies and lifecycle

Derivation parents must exist in the same bundle at exact versions, without cycles or different subject/custody/tenant boundaries. Derivatives cannot expand parent purpose sets, lower the local classification rank or remove parent restrictions. External/missing dependencies are blocked; partial import is unsupported. This deliberately conservative closure is stricter than a future authenticated external-lineage profile.

A tombstone carries no deleted plaintext. Its sequence cannot exceed the claimed checkpoint, its namespace must match, and a live record with the same identifier cannot coexist in the same package. The validator does not establish checkpoint completeness, compare with a destination high-water mark, execute deletions or ensure recovery safety. Those remain service obligations.

6. Utilities and results

node bin/phc.mjs validate examples/learning.json \
  --at 2026-10-14T12:30:00Z \
  --recipient synthetic-destination-custodian
node bin/phc.mjs digest examples/learning.json
npm test

Exit 0 means the requested check passed within its declared scope. Exit 1 means validation rejected the artifact after file decoding. Exit 2 means usage, I/O, file-decoding or configuration failure. In particular, an invalid --at returns CLOCK_INVALID with exit 2 before artifact inspection; malformed file UTF-8 or a file BOM returns the corresponding bounded decode code with exit 2. JSON diagnostics are emitted to stdout; usage text goes to stderr. The timestamp in the example is a fixed synthetic evaluation clock, not a suggestion to bypass real expiry.

Reports identify implementation phc-experimental/0.1.1 separately from the unchanged exchange grammar. The stable checks object makes the inspection scope machine-readable:

Field Reported scope and statuses
input, schema Bounded parsing and schema evaluation: passed, failed, or not_run
consistency Bundle times, required declarations, identity-tuple resolution, record/persona/rule associations, lineage, migration and tombstone/checkpoint consistency: passed, failed, or not_run; this is not evidence authentication
recipient not_provided, not_evaluated, matched, or mismatched; always scope: envelope_reference_only and identity: unverified
restrictions One entry per shape-valid rule, with a structural path, allowlisted capability, and status: passed, failed, or requires_service; scope is export_purpose, export_prohibition, evaluation_time, or receiving_service
service_authorization Always status: requires_service, activation: blocked

Each restriction entry has service_required: true: even an offline passed restriction needs fresh evaluation at the eventual service boundary. Shape failures prevent semantic inspection; a malformed evaluation clock also prevents time-dependent inspection. Other consistency failures do not suppress the restriction report. No report includes rule operands, supplied recipient references, identity references or content. Imported provenance and review evidence remain unverified.

The browser runs the same parser, schema evaluator and semantic validator inside a worker. Input is kept in memory, not posted to a server or saved in browser storage. The web host still serves normal page assets and may collect ordinary access logs. File inputs use the same strict UTF-8 decoder as the CLI. Use synthetic examples while the implementation is under review.

The small schema evaluator supports only the keywords used by checked-in PHC/DEC schemas and rejects unknown keywords when compiling. It is not a general-purpose JSON Schema implementation or independently certified validator. contentEncoding is an annotation; DEC signature decoding is enforced separately in the Node adapter. Consumers may use another 2020-12 validator for shape, but must retain duplicate-key/bounds parsing and cross-object checks.

7. Compatibility and open work

The semantic specification's field-projection concept (fields_subset) has no recognized mandatory capability in this binding. A caller cannot treat a selected JSON field list as enforced minimization. An unknown mandatory field-projection capability is rejected; an eventual receiving-service profile must define and enforce its exact projection semantics before claiming support.

No migration adapter or down-conversion to another format is supplied. The original explanatory JSON remains separately labeled and fails this binding. There is no MCP/OIDC server, JWE/JWS migration envelope, network key retrieval, or public registry allocation. Graph exchange, multiple custody collections, external lineage, full crypto vectors and independent cross-language semantic round trips require subsequent profiles and tests. The 30 original service/conformance scenarios remain unrun as end-to-end cases; local unit evidence is reported separately.

Implementation 0.1.1 adds scope reporting without changing the exchange grammar or the rule allow/deny semantics. Its intentional input/configuration changes are: byte inputs containing a BOM are rejected rather than silently stripped; direct-text BOM diagnostics change from JSON_SYNTAX to INPUT_BOM; invalid CLI evaluation clocks change from artifact rejection (exit 1) to configuration failure (exit 2). Inferred records with empty parent lists and historical confirmation claims are not given new acceptance rules in this revision. None of these checks authenticates a historical reviewer or producer.