STTP Typed IR Language Specification
Formal Contract for Cognitive State Transfer
Status: Current Version: 1.1.0 Last Updated: 2026-04-25
1. Purpose and Position
STTP defines a typed intermediate representation for cognition state transfer between agents.
This specification defines:
- the language surface,
- the structural and semantic contract,
- conformance profiles,
- security and verification obligations.
This specification does not define:
- storage backend implementation details,
- sync authority policy,
- retrieval ranking policy.
2. Normative Keywords
Keywords have normative meaning:
- MUST and MUST NOT indicate mandatory requirements.
- SHOULD and SHOULD NOT indicate strong recommendations.
- MAY indicates optional behavior.
3. Conceptual Model
An STTP node is a four-layer typed artifact with ordered semantics.
Required semantic order:
- Provenance: orientation and transmission contract.
- Envelope: temporal identity and dual actor state.
- Content: compressed meaning with confidence typing.
- Metrics: quality and compression state verification.
Layer order is part of meaning. Reordering alters interpretation and invalidates strict conformance.
4. Structural Symbols
Reserved protocol symbols:
- Node marker: ⏣
- Provenance marker: ⊕⟨
- Envelope marker: ⦿⟨
- Content marker: ◈⟨
- Metrics marker: ⍉⟨
- Layer stop marker: ⟩
Implementations MUST treat these tokens as structural control symbols when encountered in structural positions.
5. Lexical Domain
5.1 Required Token Classes
A conforming lexer MUST recognize:
- protocol markers,
- braces, brackets, and parentheses,
- delimiters,
- identifiers,
- numeric literals,
- string literals,
- boolean and null literals.
5.2 Identifiers
Canonical identifier regex:
- [A-Za-z_][A-Za-z0-9_]*
5.3 Scalars and Containers
Scalar values:
- String
- Number
- Boolean
- Null
Container values:
- Object
- Array
6. Grammar Skeleton
The following grammar is normative at the layer level.
Node := ProvenanceLayer EnvelopeLayer ContentLayer MetricsLayer
ProvenanceLayer := PROVENANCE_START NodeObject LAYER_END
EnvelopeLayer := ENVELOPE_START NodeObject LAYER_END
ContentLayer := CONTENT_START NodeObject LAYER_END
MetricsLayer := METRICS_START NodeObject LAYER_END
NodeObject := OptionalNodeMarker Object
OptionalNodeMarker := NODE_MARKER [NodeOrdinal]
NodeOrdinal := Integer
Object := '{' Members? '}'
Members := Pair (',' Pair)*
Pair := Key ':' Value
Key := Identifier | String
Value := Object | Array | String | Number | Boolean | Null
Array := '[' (Value (',' Value)*)? ']'
Note:
- legacy compact separators are non-canonical and profile-scoped to tolerant mode.
7. Layer Schema Contract
7.1 Provenance Layer
Required keys:
- trigger
- response_format
- origin_session
- compression_depth
- parent_node
- prime
trigger enum:
- scheduled
- threshold
- resonance
- seed
- manual
response_format enum:
- temporal_node
- natural_language
- hybrid
prime required keys:
- attractor_config
- context_summary
- relevant_tier
- retrieval_budget
attractor_config required keys:
- stability
- friction
- logic
- autonomy
7.2 Envelope Layer
Required keys:
- timestamp
- tier
- session_id
- user_avec
- model_avec
Optional keys:
- schema_version
tier enum:
- raw
- daily
- weekly
- monthly
- quarterly
- yearly
AVEC required keys:
- stability
- friction
- logic
- autonomy
- psi
7.3 Content Layer
Required shape:
- typed object containing one or more semantic fields.
Canonical field signature:
- field_name(.confidence): value
confidence rules:
- confidence MUST parse as float.
- strict range is [0.0, 1.0].
depth rule:
- strict maximum nesting depth is 5.
7.4 Metrics Layer
Required keys:
- rho
- kappa
- psi
- compression_avec
compression_avec required keys:
- stability
- friction
- logic
- autonomy
- psi
8. Semantic Invariants
Strict conformance requires all invariants below.
S1 Layer order invariant:
- provenance precedes envelope.
- envelope precedes content.
- content precedes metrics.
S2 Completeness invariant:
- all required keys exist in all required layers.
S3 Type invariant:
- enum values are members of defined enum sets.
- required numeric fields parse as numeric values.
S4 Confidence invariant:
- every canonical content field includes confidence annotation.
- every confidence annotation is range-valid in strict mode.
S5 Structural depth invariant:
- content object nesting depth is less than or equal to 5.
A node that violates any invariant MUST be marked strict-invalid.
9. Compliance Profiles
9.1 Strict Profile
Strict profile MUST:
- enforce all syntax and invariants,
- fail closed on unresolved structure,
- reject non-canonical legacy forms.
9.2 Tolerant Profile
Tolerant profile MAY accept legacy forms including:
- compact pipe-delimited key-value payloads,
- omitted internal node wrappers,
- unquoted enum-like values where unambiguous,
- mixed formatting and spacing variants.
Tolerant profile MUST:
- preserve raw source,
- emit diagnostics for every deviation,
- produce canonical AST when recoverable,
- never claim strict-valid unless strict invariants pass.
10. Diagnostics Specification
Recommended severities:
- Fatal
- Error
- Warning
- Info
Diagnostic payload SHOULD include:
- code,
- message,
- source span,
- recovery action,
- strict impact.
11. Canonicalization Rules
When tolerant recovery is used, implementation SHOULD canonicalize:
- layer ordering in AST output,
- known aliases into canonical keys,
- parent_node into normalized representation,
- unambiguous numeric strings into numeric values.
Canonicalization MUST NOT:
- modify original raw text,
- alter identity-sensitive semantics,
- fabricate missing semantic values.
12. Adversarial and Security Considerations
Threat classes:
- marker spoofing and layer confusion,
- malformed confidence signatures,
- delimiter smuggling in compact forms,
- layer bleed-through via unbalanced containers.
Required response:
- strict profile fails closed,
- tolerant profile fails informative with bounded recovery,
- diagnostics remain deterministic for equal input.
13. Backward Compatibility Contract
Language evolution policy is additive.
Rules:
- optional fields MAY be introduced without invalidating old nodes.
- old nodes MAY be ingested via tolerant profile.
- strict profile remains the canonical generation target.
14. Conformance Testing Requirements
A conformance suite SHOULD include:
- strict canonical fixtures,
- tolerant legacy fixtures,
- negative fixtures by invariant class,
- adversarial fixtures by threat class,
- canonical AST snapshot expectations.
15. Canonical Example
⊕⟨ ⏣0{ trigger: manual, response_format: temporal_node, origin_session: "session-abc", compression_depth: 1, parent_node: null, prime: { attractor_config: { stability: 0.90, friction: 0.20, logic: 0.98, autonomy: 0.85 }, context_summary: "parser hardening session", relevant_tier: raw, retrieval_budget: 8 } } ⟩
⦿⟨ ⏣0{ timestamp: "2026-04-25T00:00:00Z", tier: raw, session_id: "session-abc", schema_version: "sttp-1.0", user_avec: { stability: 0.90, friction: 0.20, logic: 0.98, autonomy: 0.85, psi: 2.93 }, model_avec: { stability: 0.90, friction: 0.20, logic: 0.98, autonomy: 0.85, psi: 2.93 } } ⟩
◈⟨ ⏣0{ focus(.99): "grammar update", decision(.96): { parser_mode(.95): "strict_and_tolerant" } } ⟩
⍉⟨ ⏣0{ rho: 0.95, kappa: 0.94, psi: 2.93, compression_avec: { stability: 0.90, friction: 0.20, logic: 0.98, autonomy: 0.85, psi: 2.93 } } ⟩
16. Change Control
When schema or grammar rules change, maintainers SHOULD update:
- this language specification,
- sttp_grammar_blueprint.md,
- parser conformance fixtures,
- parser implementation notes.
17. Language Promise
STTP as typed IR is complete only when it can do all three simultaneously:
- represent cognition state faithfully,
- validate structure deterministically,
- survive historical reality without semantic drift.