--- id: TREV-WP-0002 type: workplan title: "Trust Service foundation — schemas, pure fold, golden fixture" domain: infotech repo: target-revenue status: active owner: claude topic_slug: infotech created: "2026-07-28" updated: "2026-07-28" state_hub_workstream_id: "2b31c2c6-7c68-4c66-ae26-5f25e91a9af0" supersedes_title: "Trust Service implementation bootstrap" --- # Trust Service foundation — schemas, pure fold, golden fixture **Rescoped (2026-07-28)** from “Trust Service implementation bootstrap” per `history/260728-SWOT-Assessment.md` I-05 and `SCOPE.md` sequencing rules. This workplan delivers the **runnable specification foundation** for the Trust Layer (PRD NFR-1, NFR-3; TSD §3, §5, §6) **without** a hosted multi-user Trust Service: - machine-readable schemas; - pure Outstanding Target fold and offline validators; - golden Phase package (`examples/`) from concept §23; - conversion status as a pure function of Manifest + Ledger (attestation optional evidence only). It does **not** implement Phase Registry hosting, multi-tenant ledger APIs, metrics productization, production key management, or federation (PRD Roadmap Phases 4 service, 6–7). Those require a later workplan after WP-0003 normative extract and a Trust Service PRD (`SCOPE.md` §3–§4). **Depends on / parallels:** Working defaults in `specs/OpenQuestions-WorkingDefaults.md` (currency, longstop, Future License enum, hash/signature Stage 0 choices). Normative prose extract is WP-0003; keep schema field names aligned with TSD §3 and that extract. **Human gate:** Task T01 (library stack ADR) MUST NOT be marked `done` without explicit human accept if it locks language/runtime for the repo. ## Record library stack ADR (schemas + fold only) ```task id: TREV-WP-0002-T01 status: todo priority: high state_hub_task_id: "bdaa3e6a-e13d-4d4f-a6b0-9c56c18850a9" human_accept_required: true ``` `specs/TechnicalSpecificationDocument.md` is non-binding on language and storage (§10). Record an ADR for the **Stage 0 library only**: language for JSON Schema (or equivalent) validators and the pure fold, canonical serialization for hashing, and signature approach consistent with `OpenQuestions-WorkingDefaults.md` Q14 (SHA-256 chain, Ed25519 for examples). **Do not** select production database hosting, multi-tenant ops, or federation protocols in this ADR. Full service storage ADRs wait for a later Trust Service implementation workplan. **Human accept gate:** Required before treating the ADR as locking repo technology choices. Agents may draft the ADR for review. ## Phase Manifest schema and pure conformance validator ```task id: TREV-WP-0002-T02 status: todo priority: high state_hub_task_id: "92568684-2dff-497c-9593-7a0e91cb95a3" ``` Implement machine-readable schema + pure validator for Phase Manifest (TSD §3.1), applying Stage 0 working defaults: - Required fields per TSD §3.1; - `phase.longstop_at` required (working default Q8); - `future_license` ∈ {MIT, Apache-2.0} (Q3); - immutability rules documented for `phase.id` and initial target after credits (enforced in validator docs; registry service not required). Reject non-conformant manifests offline. **No hosted Phase Registry** in this workplan. ## Target Ledger schema, hash chain, and pure Outstanding Target fold ```task id: TREV-WP-0002-T03 status: todo priority: high state_hub_task_id: "df4133ee-9776-438d-901a-78a906356cfb" ``` Implement ledger entry schema (TSD §3.2): six entry types, currency match to Phase native currency (Q6), `previous_entry_hash` chain, signature field shape. Implement Outstanding Target as a pure fold: `max(0, T0 − Σ development-credit effective − Σ remission-credit effective)` with reversals/corrections as compensating entries (Rule 8). No update/delete API. Folder layout under `schemas/` + library/CLI `fold` is sufficient; hosted append service is out of scope. ## Extension contract schema and conformance validator ```task id: TREV-WP-0002-T04 status: todo priority: medium state_hub_task_id: "8454269e-fb3d-4751-b564-ef0cc33f9c97" ``` Implement Monetization Extension Contract schema (TSD §3.3) and conformance check: required fields; `allocation.rule` must not redefine core terms. Support status values `registered` / `canonical` / `deprecated` as data; canonical promotion remains a documented human/governance action (not automated). Include at least one conforming and one deliberately non-conforming extension fixture (align names with working default Q11 where practical). ## Conversion detection and attestation schema (evidence only) ```task id: TREV-WP-0002-T05 status: todo priority: high state_hub_task_id: "e60c8ccf-cd98-4b15-8ad2-e7718b08acc4" ``` Implement Conversion Event detection as pure read over Manifest + fold (Outstanding Target reaches zero) and Conversion Attestation **document schema** / optional generator (TSD §3.5). Enforce: attestation is never a precondition for conversion status; tooling must recompute conversion without an attestation file (PRD FR-7 / G6; working default Q13). ## Golden Phase package and conformance suite ```task id: TREV-WP-0002-T06 status: todo priority: medium state_hub_task_id: "90711ebf-3d89-4b45-8300-489f39cfa3cc" ``` Build `examples/phase-001/` (or equivalent) exercising concept §23: - Initial Target $100,000; - mixed Development/Remission credits through Outstanding Target zero; - expected fold series and optional attestation matching final totals. Automated suite: valid/invalid manifests, hash-chain integrity, extension conformance, full lifecycle fold. Prefer tests runnable without network services. ## Deferred (not tasks of this workplan) Do **not** implement under WP-0002: - Hosted Phase / Extension Registry services - Multi-user ledger append API and auth - Metrics product and forecasts UI - Federation replication protocol - Production operator continuity SLA Track those only after WP-0003 Stage 0 normative extract and an explicit Trust Service PRD / successor workplan (`SCOPE.md` §4).