Implement TREV-WP-0002 Stage 0 foundation: schemas, pure fold, golden Phase
Delivers the offline runnable specification foundation for the Trust Layer
(TSD §3-§6), not a hosted Trust Service:
- JSON Schemas for Phase Manifest, Ledger Entry, Extension Contract, and
Conversion Attestation, encoding the Stage 0 working defaults (Q3 future
license enum, Q6 single-currency Phases, Q8 required longstop_at).
- src/target_revenue: pure Outstanding Target fold, SHA-256 hash-chain
verification, Ed25519 signing helpers, extension conformance checks
(including a core-term-redefinition heuristic), and conversion detection
that never requires an attestation document to determine conversion status.
- examples/phase-001: golden Phase package matching the concept doc's
worked example, generated via scripts/generate_golden_phase.py so the
hash chain is computed by the library itself, not hand-typed.
- 32 passing pytest tests covering manifest/ledger/extension conformance,
tamper/reorder detection, and the full lifecycle fold to conversion.
- docs/adr/ADR-0001: proposed (not accepted) Stage 0 stack choice, per the
WP-0002-T01 human-accept gate — implementation proceeded against the
proposal as the workplan note permits, but the task stays open.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-28 18:47:29 +02:00
{
"$schema" : "https://json-schema.org/draft/2020-12/schema" ,
"$id" : "https://target-revenue.example/schemas/ledger_entry.schema.json" ,
"title" : "Target Ledger Entry" ,
"description" : "Stage 0 schema per specs/TechnicalSpecificationDocument.md §3.2 and specs/OpenQuestions-WorkingDefaults.md Q6/Q10/Q14. Append-only; corrections are new compensating entries, never mutation." ,
"type" : "object" ,
"required" : [
"id" ,
"phase" ,
"type" ,
"amount" ,
"currency" ,
"recognized_at" ,
"evidence_reference" ,
"previous_entry_hash"
] ,
"additionalProperties" : false ,
"properties" : {
"id" : {
"type" : "string" ,
"pattern" : "^trsl:entry:[a-zA-Z0-9]+$" ,
"description" : "Globally unique, monotonically orderable (ULID or equivalent)."
} ,
"phase" : {
"type" : "string" ,
"pattern" : "^trsl:phase:[a-zA-Z0-9._-]+$"
} ,
"type" : {
"type" : "string" ,
"enum" : [
"development-credit" ,
"remission-credit" ,
"credit-reversal" ,
"remission-correction" ,
2026-07-29 09:16:22 +02:00
"administrative-correction-development" ,
"administrative-correction-remission" ,
Implement TREV-WP-0002 Stage 0 foundation: schemas, pure fold, golden Phase
Delivers the offline runnable specification foundation for the Trust Layer
(TSD §3-§6), not a hosted Trust Service:
- JSON Schemas for Phase Manifest, Ledger Entry, Extension Contract, and
Conversion Attestation, encoding the Stage 0 working defaults (Q3 future
license enum, Q6 single-currency Phases, Q8 required longstop_at).
- src/target_revenue: pure Outstanding Target fold, SHA-256 hash-chain
verification, Ed25519 signing helpers, extension conformance checks
(including a core-term-redefinition heuristic), and conversion detection
that never requires an attestation document to determine conversion status.
- examples/phase-001: golden Phase package matching the concept doc's
worked example, generated via scripts/generate_golden_phase.py so the
hash chain is computed by the library itself, not hand-typed.
- 32 passing pytest tests covering manifest/ledger/extension conformance,
tamper/reorder detection, and the full lifecycle fold to conversion.
- docs/adr/ADR-0001: proposed (not accepted) Stage 0 stack choice, per the
WP-0002-T01 human-accept gate — implementation proceeded against the
proposal as the workplan note permits, but the task stays open.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-28 18:47:29 +02:00
"conversion-checkpoint"
] ,
2026-07-29 09:16:22 +02:00
"description" : "Closed set per TSD §3.2; not extensible per-project. administrative-correction-development/-remission split 2026-07-29 to make the corrected target side explicit in the type name (specs/TargetLedgerSpecification.md §2)."
Implement TREV-WP-0002 Stage 0 foundation: schemas, pure fold, golden Phase
Delivers the offline runnable specification foundation for the Trust Layer
(TSD §3-§6), not a hosted Trust Service:
- JSON Schemas for Phase Manifest, Ledger Entry, Extension Contract, and
Conversion Attestation, encoding the Stage 0 working defaults (Q3 future
license enum, Q6 single-currency Phases, Q8 required longstop_at).
- src/target_revenue: pure Outstanding Target fold, SHA-256 hash-chain
verification, Ed25519 signing helpers, extension conformance checks
(including a core-term-redefinition heuristic), and conversion detection
that never requires an attestation document to determine conversion status.
- examples/phase-001: golden Phase package matching the concept doc's
worked example, generated via scripts/generate_golden_phase.py so the
hash chain is computed by the library itself, not hand-typed.
- 32 passing pytest tests covering manifest/ledger/extension conformance,
tamper/reorder detection, and the full lifecycle fold to conversion.
- docs/adr/ADR-0001: proposed (not accepted) Stage 0 stack choice, per the
WP-0002-T01 human-accept gate — implementation proceeded against the
proposal as the workplan note permits, but the task stays open.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-28 18:47:29 +02:00
} ,
"amount" : {
"type" : "number" ,
"description" : "Positive for credits; the fold interprets sign by entry type (see fold.py). Reversal/correction entries reduce their target's cumulative total."
} ,
"currency" : {
"type" : "string" ,
"pattern" : "^[A-Z]{3}$" ,
"description" : "Must match the Phase's initial_target.currency (working default Q6). No FX conversion in the pure fold."
} ,
"recognized_at" : {
"type" : "string" ,
"format" : "date-time" ,
"description" : "Settlement time, not invoice time (Rule 4 / working default Q10 payment-settled)."
} ,
"extension" : {
"type" : "object" ,
"description" : "Required for development-credit/remission-credit entries." ,
"required" : [ "id" , "version" ] ,
"additionalProperties" : false ,
"properties" : {
"id" : {
"type" : "string" ,
"pattern" : "^trsl:(extension|policy):[a-zA-Z0-9._-]+$"
} ,
"version" : { "type" : "string" }
}
} ,
"evidence_reference" : {
"type" : "string" ,
"description" : "URI, may use the confidential: scheme. Tiering per working default Q10 (E0/E1/E2)."
} ,
"previous_entry_hash" : {
"type" : "string" ,
"pattern" : "^[a-f0-9]{64}$|^GENESIS$" ,
"description" : "SHA-256 hex digest of the previous entry's canonical serialization for this Phase, or the literal GENESIS for the first entry."
} ,
"signature" : {
"type" : "string" ,
"description" : "Ed25519 signature over the canonical serialization (working default Q14). Optional in Stage 0 fixtures, required for any public claim."
} ,
"reverses" : {
"type" : "string" ,
"pattern" : "^trsl:entry:[a-zA-Z0-9]+$" ,
"description" : "Required on credit-reversal and remission-correction entries: the entry id being reversed or corrected."
}
} ,
"allOf" : [
{
"if" : {
"properties" : { "type" : { "const" : "credit-reversal" } }
} ,
"then" : { "required" : [ "reverses" ] }
} ,
{
"if" : {
"properties" : { "type" : { "const" : "remission-correction" } }
} ,
"then" : { "required" : [ "reverses" ] }
} ,
{
"if" : {
"properties" : {
"type" : { "enum" : [ "development-credit" , "remission-credit" ] }
}
} ,
"then" : { "required" : [ "extension" ] }
}
]
}