Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conformance/parity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Projection boundary corpus

Both SDK test suites consume projection-boundaries.json. This slice covers six canonical timestamps, thirteen noncanonical spellings, and five scalar projection cases. Nonfinite values use local special-value tags because they have no JSON representation. These projection inputs are not assertions that arbitrary event fields pass the event schema.

This companion is based on telemetry #119. Other adapter timestamp/duration and EventFactory corrections remain in #116–120; it neither replaces those fixes nor claims their acceptance. The 20-digit tuple is an explicit positive boundary; logs, delivery, collector behavior and hardware are separate.
123 changes: 123 additions & 0 deletions conformance/parity/projection-boundaries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"timestamps": [
{
"input": "0",
"tuple": [
0,
0
]
},
{
"input": "1",
"tuple": [
0,
1
]
},
{
"input": "999999999",
"tuple": [
0,
999999999
]
},
{
"input": "1000000000",
"tuple": [
1,
0
]
},
{
"input": "1000000001",
"tuple": [
1,
1
]
},
{
"input": "99999999999999999999",
"tuple": [
99999999999,
999999999
]
}
],
"invalid_timestamps": [
"",
" ",
"-1",
"+1",
"01",
"0x10",
"1.0",
"1e9",
"1\n",
"1\r",
"1
",
"١",
"111111111111111111111"
],
"projections": [
{
"id": "finite-scalars",
"event": {
"run_id": "run-1",
"task_id": 0,
"decision": false
},
"expected": {
"agentrust.run.id": "run-1",
"agentrust.task.id": 0,
"agentrust.policy.decision": false
}
},
{
"id": "structured-and-null-omit",
"event": {
"run_id": "run-1",
"task_id": null,
"workflow_id": [],
"agent_id": {}
},
"expected": {
"agentrust.run.id": "run-1"
}
},
{
"id": "unmapped-payload-omit",
"event": {
"run_id": "run-1",
"payload": "synthetic"
},
"expected": {
"agentrust.run.id": "run-1"
}
},
{
"id": "nonfinite-omit",
"event": {
"run_id": "run-1"
},
"special": {
"task_id": "nan",
"workflow_id": "positive_infinity",
"agent_id": "negative_infinity"
},
"expected": {
"agentrust.run.id": "run-1"
}
},
{
"id": "fractional-scalar",
"event": {
"run_id": "run-1",
"task_id": 1.5
},
"expected": {
"agentrust.run.id": "run-1",
"agentrust.task.id": 1.5
}
}
]
}
30 changes: 30 additions & 0 deletions packages/typescript/test/projection-parity.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import assert from "node:assert/strict";
import {readFileSync} from "node:fs";
import test from "node:test";
import {hrTime, spanAttributes} from "../src/projection.js";
import type {NormalizedEvent} from "../src/types.js";

const corpus = JSON.parse(readFileSync(
new URL("../../../conformance/parity/projection-boundaries.json", import.meta.url), "utf8",
));
for (const row of corpus.timestamps) {
test("shared timestamp " + row.input, () => assert.deepEqual(hrTime(row.input), row.tuple));
}
for (const value of corpus.invalid_timestamps) {
test("shared noncanonical timestamp " + JSON.stringify(value), () => {
assert.throws(() => hrTime(value));
});
}
const special: Record<string, number> = {
nan: Number.NaN, positive_infinity: Number.POSITIVE_INFINITY,
negative_infinity: Number.NEGATIVE_INFINITY,
};
for (const row of corpus.projections) {
test("shared scalar projection " + row.id, () => {
const event = {...row.event};
for (const [key, value] of Object.entries(row.special ?? {})) {
event[key] = special[value as string];
}
assert.deepEqual(spanAttributes(event as NormalizedEvent), row.expected);
});
}
35 changes: 35 additions & 0 deletions tests/test_projection_parity_corpus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Shared Python/TypeScript normalization and projection cases, not schema acceptance."""
import json
import math
import unittest
from pathlib import Path

from agentrust_telemetry.adapters.base import _unix_nano
from agentrust_telemetry.projection import span_attributes

CORPUS = json.loads(
(Path(__file__).resolve().parents[1] / "conformance/parity/projection-boundaries.json")
.read_text(encoding="utf-8")
)


class TestProjectionParityCorpus(unittest.TestCase):
def test_timestamp_normalization(self):
for case in CORPUS["timestamps"]:
with self.subTest(value=case["input"]):
normalized = _unix_nano(case["input"])
self.assertEqual(normalized, case["input"])
self.assertEqual(list(divmod(int(normalized), 1_000_000_000)), case["tuple"])

def test_noncanonical_timestamps(self):
for value in CORPUS["invalid_timestamps"]:
with self.subTest(value=value), self.assertRaises((ValueError, TypeError)):
_unix_nano(value)

def test_scalar_projection(self):
special = {"nan": math.nan, "positive_infinity": math.inf, "negative_infinity": -math.inf}
for case in CORPUS["projections"]:
with self.subTest(case=case["id"]):
event = dict(case["event"])
event.update({key: special[value] for key, value in case.get("special", {}).items()})
self.assertEqual(span_attributes(event), case["expected"])
Loading