Skip to content

Reject boolean timestamps in TRACE finalization - #128

Closed
drk-ram wants to merge 1 commit into
agentrust-io:mainfrom
drk-ram:fix-126-boolean-timestamps
Closed

drk-ram wants to merge 1 commit into
agentrust-io:mainfrom
drk-ram:fix-126-boolean-timestamps

Conversation

@drk-ram

@drk-ram drk-ram commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #126. TRACE finalization and approval binding now validate canonical Unix-nanosecond decimal strings instead of coercing booleans or malformed values through int().

Contract impact

  • No wire-contract change
  • Backward-compatible contract change with fixtures
  • Breaking contract change with migration notes

Evidence

  • python tools/sync_schemas.py (not applicable; no schema change)
  • python tools/check_schemas.py (not applicable; no schema change)
  • python conformance/runner/validate.py (not run; no schema change)
  • python -m unittest discover -s tests -v
  • python -m build (not run)
  • pytest -q (164 passed, 2 skipped, 155 subtests passed)
  • mypy --follow-imports=skip src/agentrust_telemetry/trace_adapter.py

Privacy and security

  • No real prompts, source, credentials, personal data, or production identifiers added
  • New fields have capture semantics and privacy classification (N/A; no new fields)
  • Security-sensitive changes received maintainer review (requested through this PR)

Limits

This changes Python adapter validation only. Existing wire schemas are unchanged, and invalid timestamps continue to produce a finalization refusal rather than a signed record.

@drk-ram
drk-ram requested review from a team and imran-siddique as code owners November 6, 2026 16:25
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🔴 Contributor Check: HIGH

Check Result
Profile HIGH
Credential LOW
Overall HIGH

Automated check by AgenTrust Contributor Check.

@github-actions github-actions Bot added the needs-review:HIGH Contributor check flagged HIGH risk label Nov 6, 2026
Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
@drk-ram
drk-ram force-pushed the fix-126-boolean-timestamps branch from 47216c2 to 73d4dae Compare November 13, 2026 01:13

@dinakarjs dinakarjs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 73d4dae. The shared timestamp parser matches the existing canonical decimal-string schema (zero or a nonzero leading digit, at most 20 ASCII digits) and is applied before issued_at conversion and approval/action time comparisons. Malformed values are refused or remain unresolved; valid request-window and action-binding behavior is retained.

Independent Linux/Python 3.12.14 validation with the hash-locked test dependencies and OTEL_TRACES_SAMPLER=always_on: the full tests/ suite passed, 169 tests plus 178 subtests. Additional direct checks refused 17 malformed cases (including Boolean, numeric, whitespace, Unicode-digit, leading-zero and overlength inputs) and accepted three canonical boundary controls. Temporarily replacing only _unix_nano_timestamp with int(value) made all four Boolean-negative subtests fail. Restoring the implementation returned the 13 focused TRACE adapter tests to passing; checkout is clean.

No blocking source finding in this bounded Python validation change. The four returned hosted workflows currently require maintainer authorization (action_required); this approval is not a claim of green hosted CI or completion of the requested maintainer security review. Please run those checks before merging. Prepared with OpenAI Codex.

Copy link
Copy Markdown
Contributor

Hosted-check follow-through for my approval of 73d4dae: CI 43343259339, CodeQL 43343259464 and ClusterFuzzLite PR 43343259550 now report success; Dependabot auto-merge is inapplicable/skipped. This supersedes the action_required status in my review, not its technical scope. The source head is unchanged. Maintainer/security acceptance remains separate; no merge performed. Prepared with OpenAI Codex.

@imran-siddique imran-siddique left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 73d4dae: ran conformance, the Python suite and the TS check on this head; each new test fails against main's source; all 11 PRs in this series merge onto main together without conflicts and pass combined.

rajnisht7 added a commit that referenced this pull request Nov 25, 2026
Reject noncanonical decimal-string timestamps before TRACE
appraisal/signing, including self-consistent imported snapshots.
Rehashed negative controls prevent chain-integrity failure from hiding
timestamp validation.

**Current head:** `e80778e53030e94978076001d1d1b70f8136542d`. Merged
main `f66a847adda531ad21fdfb940858f55a64ad303a` and resolved the
CHANGELOG.md conflict by retaining both entries. Full Python suite on
Python 3.12 with the repository's hash-locked dependencies and default
OpenTelemetry sampler: 187 passed. Source compilation and whitespace
checks pass. The initial run inherited this workspace's 1% sampling
overrides and had two failures and one error in sampling-dependent
tracing tests. Removing those two process-local overrides restored the
CI-default sampler and all 187 tests passed. Hosted CI, fuzzing and
CodeQL are running on this head. The November 19 approval applies to the
preceding head; current-head review and the #128 consolidation decision
remain pending.

**Consolidation decision pending with #128:** maintain one
implementation for #126. This PR refuses malformed timestamps before
signing; #128 can sign a warning appraisal for a malformed copied
request timestamp, while its helper verdicts differ. That is an
outcome-contract choice, not proof of approval-authority bypass. Retain
canonical boundary, each-position, authentic rehashed-snapshot and
no-signing controls in the selected implementation.

The existing wire representation is enforced; valid streams retain
behavior. This is not full event-schema revalidation or proof of
approval authority. Imran's existing request remains; no competing
implementation is merged by this description.

Prepared with OpenAI Codex; source head and existing review history
retained.

<details>
<summary>Historical description and validation snapshots (superseded by
current status above)</summary>

## Summary

Fixes #126. A self-consistent imported evidence snapshot could contain
boolean or otherwise noncanonical timestamps that Python's `int()`
coerced into an approval window or TRACE issuance time. The adapter now
accepts only the existing ASCII decimal-string timestamp format before
appraisal/signing, and applies the same parser in request/resolution and
executed-action binding.

The regression tests rehash malformed snapshots so chain-integrity
validation cannot mask the timestamp defect. They exercise each
timestamp position, booleans/numbers/noncanonical strings, canonical
boundaries, expiry, a valid signed appraisal, and refusal before
signing.

## Contract impact

- [x] No wire-contract change: enforces `common.schema.json`'s existing
timestamp representation.
- Valid streams retain their appraisal and issuance time.
- Malformed approval/action times cannot establish binding; public
finalization raises `TraceFinalizationError`.

## Evidence

Python 3.12, fresh environment installed with `--require-hashes -r
requirements/test.txt`:

- Full Python suite: **170 tests passed**. This workspace injects
`OTEL_TRACES_SAMPLER=parentbased_traceidratio` and
`OTEL_TRACES_SAMPLER_ARG=0.01`; removing those two process-local
overrides restores the default sampler. The first run with those
overrides had three unrelated tracing failures; they are not concealed
as a passing run.
- The new six-test selection fails on unmodified main (negative subtests
expose the defect); all six methods pass with the repair. Final focused
TRACE suite after import/style cleanup: **31 passed**.
- `sync_schemas.py`, schema/version/OTel compatibility/TypeScript
schema/OIDC checks, conformance runner, compileall, `pip check`,
touched-file Ruff, and whitespace checks pass.
- Wheel and sdist build and installed-artifact smoke checks pass.

Hosted checks on `658eca654f4f05e8904fca19f193d6ae871b0556` are now
complete: Python 3.10–3.13, TypeScript, fuzzing, CodeQL analysis and
contributor check all pass; the inapplicable auto-merge job is skipped.
Imran is already a requested reviewer. Independent maintainer review
remains pending.

## Privacy and security

- [x] Synthetic fixtures only; no production data or credentials added.
- [ ] Security-sensitive change received maintainer review.

## Limits

This is a Python TRACE-adapter timestamp repair, not a full event-schema
revalidation or proof of approval authority. TypeScript, dependency
locks, wire schemas and policy semantics are unchanged. Hosted CI and
independent maintainer review remain required.

Prepared and validated with OpenAI Codex; DCO signed.

</details>

Signed-off-by: Srinivasa Dinakar Jainti <78673153+dinakarjs@users.noreply.github.com>
Signed-off-by: Srinivasa Consultants <78673153+dinakarjs@users.noreply.github.com>
Co-authored-by: Rajnish Tiwari <121179385+rajnisht7@users.noreply.github.com>
@rajnisht7

Copy link
Copy Markdown
Member

Closing, superseded by #127.

@rajnisht7 rajnisht7 closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:HIGH Contributor check flagged HIGH risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: trace_adapter binds an approval whose timestamps are booleans

4 participants