hyf

Context-aware query service for Radroots
git clone https://radroots.dev/git/hyf.git
Log | Files | Refs | README | LICENSE

commit 6fecd18e466a54000098f2fe7b121d547c4a801b
parent 9d40dc38cc120a7fb073c3a7e2eef16fa0c66476
Author: triesap <tyson@radroots.org>
Date:   Mon, 21 Sep 2026 03:36:53 +0000

spec: bind temporal and evidence semantics

Diffstat:
Aschemas/hyf_v1_jev/evidence.schema.json | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_v1_jev/examples/invalid/evidence.bad_kind.json | 6++++++
Aschemas/hyf_v1_jev/examples/invalid/evidence.missing_revision.json | 7+++++++
Aschemas/hyf_v1_jev/examples/invalid/temporal.bad_ambiguity.json | 5+++++
Aschemas/hyf_v1_jev/examples/invalid/temporal.bad_boundary.json | 5+++++
Aschemas/hyf_v1_jev/examples/valid/evidence.record_field.json | 8++++++++
Aschemas/hyf_v1_jev/examples/valid/evidence.span_unicode.json | 8++++++++
Aschemas/hyf_v1_jev/examples/valid/temporal.ambiguous_local.json | 7+++++++
Aschemas/hyf_v1_jev/examples/valid/temporal.date_only.json | 10++++++++++
Aschemas/hyf_v1_jev/examples/valid/temporal.missing_zone.json | 8++++++++
Aschemas/hyf_v1_jev/examples/valid/temporal.relative_replay.json | 11+++++++++++
Aschemas/hyf_v1_jev/examples/valid/temporal.window_exclusive.json | 10++++++++++
Aschemas/hyf_v1_jev/temporal.schema.json | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_v1_jev/temporal_manifest.json | 32++++++++++++++++++++++++++++++++
Mtests/test_hyf.mojo | 18+++++++++++++-----
15 files changed, 268 insertions(+), 5 deletions(-)

diff --git a/schemas/hyf_v1_jev/evidence.schema.json b/schemas/hyf_v1_jev/evidence.schema.json @@ -0,0 +1,57 @@ +{ + "$comment": "Evidence references use exact byte offsets into the immutable source revision, or trusted record fields", + "type": "object", + "properties": { + "source_id": { + "type": "string", + "minLength": 1 + }, + "revision": { + "type": "string", + "minLength": 1 + }, + "kind": { + "type": "string", + "enum": [ + "span", + "record_field" + ] + }, + "start": { + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "end": { + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "record_id": { + "type": [ + "string", + "null" + ] + }, + "field": { + "type": [ + "string", + "null" + ] + }, + "method": { + "type": "string" + } + }, + "required": [ + "source_id", + "revision", + "kind", + "method" + ], + "additionalProperties": false +} diff --git a/schemas/hyf_v1_jev/examples/invalid/evidence.bad_kind.json b/schemas/hyf_v1_jev/examples/invalid/evidence.bad_kind.json @@ -0,0 +1,6 @@ +{ + "source_id": "s1", + "revision": "r1", + "kind": "guess", + "method": "span" +} diff --git a/schemas/hyf_v1_jev/examples/invalid/evidence.missing_revision.json b/schemas/hyf_v1_jev/examples/invalid/evidence.missing_revision.json @@ -0,0 +1,7 @@ +{ + "source_id": "s1", + "kind": "span", + "start": 4, + "end": 23, + "method": "span" +} diff --git a/schemas/hyf_v1_jev/examples/invalid/temporal.bad_ambiguity.json b/schemas/hyf_v1_jev/examples/invalid/temporal.bad_ambiguity.json @@ -0,0 +1,5 @@ +{ + "kind": "relative", + "resolution": "unresolved", + "ambiguity": "maybe" +} diff --git a/schemas/hyf_v1_jev/examples/invalid/temporal.bad_boundary.json b/schemas/hyf_v1_jev/examples/invalid/temporal.bad_boundary.json @@ -0,0 +1,5 @@ +{ + "kind": "window", + "resolution": "resolved", + "boundary": "half-open" +} diff --git a/schemas/hyf_v1_jev/examples/valid/evidence.record_field.json b/schemas/hyf_v1_jev/examples/valid/evidence.record_field.json @@ -0,0 +1,8 @@ +{ + "source_id": "s1", + "revision": "r1", + "kind": "record_field", + "record_id": "lot-1", + "field": "unreserved_quantity", + "method": "trusted_record" +} diff --git a/schemas/hyf_v1_jev/examples/valid/evidence.span_unicode.json b/schemas/hyf_v1_jev/examples/valid/evidence.span_unicode.json @@ -0,0 +1,8 @@ +{ + "source_id": "s1", + "revision": "r1", + "kind": "span", + "start": 4, + "end": 23, + "method": "span" +} diff --git a/schemas/hyf_v1_jev/examples/valid/temporal.ambiguous_local.json b/schemas/hyf_v1_jev/examples/valid/temporal.ambiguous_local.json @@ -0,0 +1,7 @@ +{ + "kind": "timestamp", + "expression": "2026-11-01T01:30:00", + "timezone": "America/Vancouver", + "resolution": "unresolved", + "ambiguity": "ambiguous_local" +} diff --git a/schemas/hyf_v1_jev/examples/valid/temporal.date_only.json b/schemas/hyf_v1_jev/examples/valid/temporal.date_only.json @@ -0,0 +1,10 @@ +{ + "kind": "date_only", + "expression": "2026-09-25", + "timezone": "America/Vancouver", + "resolution": "resolved", + "start": "2026-09-25", + "end": "2026-09-25", + "boundary": "inclusive", + "ambiguity": "none" +} diff --git a/schemas/hyf_v1_jev/examples/valid/temporal.missing_zone.json b/schemas/hyf_v1_jev/examples/valid/temporal.missing_zone.json @@ -0,0 +1,8 @@ +{ + "kind": "relative", + "expression": "Friday", + "reference_time": "2026-09-21T09:00:00", + "timezone": null, + "resolution": "unresolved", + "ambiguity": "missing_zone" +} diff --git a/schemas/hyf_v1_jev/examples/valid/temporal.relative_replay.json b/schemas/hyf_v1_jev/examples/valid/temporal.relative_replay.json @@ -0,0 +1,11 @@ +{ + "kind": "relative", + "expression": "Friday", + "reference_time": "2026-09-21T09:00:00-07:00", + "timezone": "America/Vancouver", + "resolution": "resolved", + "start": "2026-09-25", + "end": "2026-09-25", + "boundary": "inclusive", + "ambiguity": "none" +} diff --git a/schemas/hyf_v1_jev/examples/valid/temporal.window_exclusive.json b/schemas/hyf_v1_jev/examples/valid/temporal.window_exclusive.json @@ -0,0 +1,10 @@ +{ + "kind": "window", + "expression": "until Friday", + "timezone": "America/Vancouver", + "resolution": "resolved", + "start": "2026-09-21", + "end": "2026-09-25", + "boundary": "exclusive", + "ambiguity": "none" +} diff --git a/schemas/hyf_v1_jev/temporal.schema.json b/schemas/hyf_v1_jev/temporal.schema.json @@ -0,0 +1,81 @@ +{ + "$comment": "Source-anchored temporal semantics; byte-offset evidence convention; no model arithmetic", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "timestamp", + "date_only", + "window", + "relative" + ] + }, + "expression": { + "type": [ + "string", + "null" + ] + }, + "reference_time": { + "type": [ + "string", + "null" + ] + }, + "timezone": { + "type": [ + "string", + "null" + ] + }, + "resolution": { + "type": "string", + "enum": [ + "resolved", + "unresolved" + ] + }, + "start": { + "type": [ + "string", + "null" + ] + }, + "end": { + "type": [ + "string", + "null" + ] + }, + "boundary": { + "type": [ + "string", + "null" + ], + "enum": [ + "inclusive", + "exclusive", + null + ] + }, + "ambiguity": { + "type": [ + "string", + "null" + ], + "enum": [ + "none", + "ambiguous_local", + "missing_zone", + "nonexistent_local", + null + ] + } + }, + "required": [ + "kind", + "resolution" + ], + "additionalProperties": false +} diff --git a/schemas/hyf_v1_jev/temporal_manifest.json b/schemas/hyf_v1_jev/temporal_manifest.json @@ -0,0 +1,32 @@ +{ + "schema_version": 1, + "spec_id": "hyf_v1_jev", + "family": "temporal_evidence", + "bindings": [ + { + "schema": "temporal.schema.json", + "valid": [ + "examples/valid/temporal.date_only.json", + "examples/valid/temporal.relative_replay.json", + "examples/valid/temporal.window_exclusive.json", + "examples/valid/temporal.missing_zone.json", + "examples/valid/temporal.ambiguous_local.json" + ], + "invalid": [ + "examples/invalid/temporal.bad_boundary.json", + "examples/invalid/temporal.bad_ambiguity.json" + ] + }, + { + "schema": "evidence.schema.json", + "valid": [ + "examples/valid/evidence.span_unicode.json", + "examples/valid/evidence.record_field.json" + ], + "invalid": [ + "examples/invalid/evidence.missing_revision.json", + "examples/invalid/evidence.bad_kind.json" + ] + } + ] +} diff --git a/tests/test_hyf.mojo b/tests/test_hyf.mojo @@ -1065,8 +1065,8 @@ def test_wire_operation_schemas_accept_valid_and_reject_invalid() raises: assert_true(validated >= 6) -def test_domain_representation_schemas_accept_valid_and_reject_invalid() raises: - var manifest = _wire_schema_json("domain_manifest.json") +def _assert_manifest_examples(manifest_name: String, expected_valid: Int) raises: + var manifest = _wire_schema_json(manifest_name) assert_equal(manifest["spec_id"].string_value(), "hyf_v1_jev") var valid_count = 0 for binding in manifest["bindings"].array_items(): @@ -1083,7 +1083,7 @@ def test_domain_representation_schemas_accept_valid_and_reject_invalid() raises: ) assert_true( validate(doc, schema).valid, - "valid domain example failed schema: " + rel.string_value(), + "valid example failed schema: " + rel.string_value(), ) valid_count += 1 for rel in binding["invalid"].array_items(): @@ -1098,9 +1098,17 @@ def test_domain_representation_schemas_accept_valid_and_reject_invalid() raises: ) assert_true( not validate(doc, schema).valid, - "invalid domain example unexpectedly passed: " + rel.string_value(), + "invalid example unexpectedly passed: " + rel.string_value(), ) - assert_equal(valid_count, 5) + assert_equal(valid_count, expected_valid) + + +def test_domain_representation_schemas_accept_valid_and_reject_invalid() raises: + _assert_manifest_examples("domain_manifest.json", 5) + + +def test_temporal_evidence_schemas_accept_valid_and_reject_invalid() raises: + _assert_manifest_examples("temporal_manifest.json", 7) def main() raises: