Repository navigation
Add source classification inheritance for derived data flows - #132
Prakash-codeMaker wants to merge 32 commits into
Conversation
|
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check. |
|
Maintainer review request (follow-up) I added ADR 0001 to record the rationale, trust boundary, rejected alternatives, and compatibility question. Could a maintainer please:
The contributor check completed successfully (overall MEDIUM). I have kept this PR in draft until the contract/version decisions and CI review are resolved. |
|
@imran-siddique @rajnisht7 @carloshvp — could one of the maintainers please take the next review action on this draft? I have added the proposed ADR and corrected its versioning note so it does not equate an alpha sequence bump with a minor-version increment. The remaining maintainer-only items are:
The PR is deliberately left in draft until those decisions and automated checks are resolved. |
rajnisht7
left a comment
There was a problem hiding this comment.
@Prakash-codeMaker Thank you for the write-up, verified on main - classified_data_flow/classifiedDataFlow only classify the emitted value today, theres no mechanism to carry a stricter upstream label through a summarize/aggregate step
Implementation looks good, but the new conformance fixtures (derived-data-flow.json valid, derived-data-flow-missing-observed.json invalid) arent refelected in tools/installed_python_controls.py’s EXPECTED_FIXTURES, that list still has the old 6/7 counts, so test_real_controls, test_accept_all_is_caught, test_reject_all_is_caught, and test_changed_factory_is_caught all fail right now, also as the installed-wheel smoke path uses the same helper, that’s affected too. Needs an EXPECTED_FIXTURES update (7 valid / 8 invalid) before anything else
on the two things you asked for:
-
Caller-supplied trusted-label boundary -this is the right call. It matches the existing posture of this SDK (same pattern as agtDataAccessFlow, which already accepts an externally-produced decision without authenticating it). The SDK doesn’t own source data or a policy engine, so it shouldn’t be in the business of validating label authenticity
-
Version/compatibility - needs a real minor bump, not just the next alpha: this schema has never had an optional field added post-release, so there’s no precedent either way. But docs/architecture.md is explicit that schemas are closed to unknown fields by design across the whole project, which means an older validator will reject these events even though they’re optional at the producer. That’s a real incompatibility per VERSIONING.md’s own definition of “minor,” and pre-1.0 it still has to be called out explicitly, hence bump to 0.2.0-alpha.1 rather than alpha.7, and add an explicit changelog line that consumers pinned to the pre-0.2 schema will reject events carrying these fields and need to update their copy first
Docs nit: the line in docs/data-flow-classification.md saying “no migration is required” is a bit too strong, that’s true for producers who don’t opt in, but not for consumers on the old closed schema. Worth rewording to match the ADR’s own caveat so the two don’t contradict each other.
non-blocking:
- Duplicate-source check keys on (kind, id), so two distinct sources of the same kind with no id would collide, worth one sentence in the docs.
- Python takes a bounded iterable, TypeScript requires an array minor surface difference, just document it.
- Classifier runs before the new lineage validation (same as before this PR) fine to leave, but moving the cheap static checks first would save a wasted classify() call on invalid input.
- A shared golden event vector and an exact-1024-sources success test would strengthen cross-language coverage
dinakarjs
left a comment
There was a problem hiding this comment.
Follow-up validation while the 0.2 migration is in progress. The earlier EXPECTED_FIXTURES and 7/8 count omissions are fixed. Two runtime blockers remain in the inspected head 432bef6:
- P1 — packages/typescript/src/validation.ts:49 still looks up schema IDs under /telemetry/v0.1/schema/, while the bundled schema IDs now use /v0.2/. SchemaValidator.bundled() raises 'required schema is missing: action.schema.json' before event validation. Update the lookup with the schema migration.
- P1 — src/agentrust_telemetry/adapters/base.py:58 and packages/typescript/src/factory.ts:29 still emit spec_version 0.1.0-alpha.6, and packages/typescript/src/types.ts:3 still requires that literal. The envelope now requires 0.2.0-alpha.1. A normal factory-generated event is therefore rejected by the new bundled schema. Complete the factory/type migration along with fixtures, fuzz seeds and digest-dependent golden expectations.
Reproduction at c68ccd6: hash-locked Python environment, PYTHONPATH=src and default OTel sampler, python -m unittest discover -s tests ran 182 tests with 11 failures and 101 errors. TypeScript tests invoked as node --import tsx --test test/*.test.ts reproduce the missing-schema exception. The ordinary tsx CLI was blocked by this environment's IPC permission, so I used its Node loader. Later commits through the inspected head update fixtures but leave the cited runtime lines unchanged; those earlier aggregate counts are not claimed for the newer head.
The author is actively updating this branch, so I have not opened a competing migration patch. Please rerun the full Python and TypeScript suites and repository/schema/installed-package gates once the version migration is complete. Prepared with OpenAI Codex.
|
Thanks for the detailed review. I've pushed the requested corrections to the PR branch:
The normative, Python-bundled and TypeScript-bundled copies of all eight schemas have been verified byte-identical. The latest CI, CodeQL and ClusterFuzzLite workflow runs are still marked action_required, so the test suites have not executed on this revision. I've kept the PR in draft and have not represented those checks as passing. |
87d3106 to
dc9bd7e
Compare
|
Follow-up on the P1 runtime blockers from the review: I have pushed the missing 0.2.0-alpha.1 alignment to the PR branch. The current head is
I fetched the four files again from the branch after the updates and confirmed none of those old v0.1 references remain in these runtime locations. The earlier review's EXPECTED_FIXTURES 7-valid/8-invalid update is also present in this branch. Validation caveat: I do not have a successful full Python/TypeScript test result to report. At the time of this update, the new head had no reported combined status checks; the prior PR-triggered CI, CodeQL, and ClusterFuzzLite runs were blocked with |
|
Maintainer follow-up on the current head The two P1 runtime issues from the latest review are now fixed, together with the factory/type version literals:
I checked successful review/CI precedents in this repository: #102 (independent reviews and successful CI, CodeQL, ClusterFuzzLite on its later head), #117 (approved with the principal workflows green), and #100 (independent approval and successful CI/workflow-lint/CodeQL/Collector runs). Those approvals cannot be transferred to this PR, but they show the established review path. @dinakarjs @imran-siddique @rajnisht7 — could one of you review the exact current head and, if satisfied, approve the PR-triggered workflows? The current-head CI, CodeQL, ClusterFuzzLite PR, and Dependabot runs are all |
rajnisht7
left a comment
There was a problem hiding this comment.
Thank you for the update, a few things still needs to be looked upon:
- compatibility/golden/evidence-chain.json still has the old digests. Both Python and TypeScript delivery-fault tests fail because of this.
- Tool transcript digest is stale in tests/test_trace_adapter.py and packages/typescript/test/trace-finalizer.test.ts (expected c6a971b9…, actual 08017772…).
- .clusterfuzzlite/_fuzz_seeds.py still has 0.1.0-alpha.6, the fuzz-seed gate fails for all six fixtures.
- tests/test_repository_gates.py still expects v0.1.0-alpha.6 for the release tag.
- TypeScript classes (ClassificationOrder, ClassificationResult, DataEndpoint, SourceClassification) are mutable at runtime. Reassigning order.levels after construction can reverse the inheritance result (e.g. confidential -> public), kindly fix and add a mutation regression test. Python’s frozen dataclasses avoid this
- CHANGELOG/ADR currently imply that only opted-in derived events break old consumers. In reality every event from the new SDK has spec_version: 0.2.0-alpha.1, so old v0.1 schemas reject even plain non-derived events. Please make that explicit.
- SchemaValidator does not enforce the helper’s lineage rules (duplicate (kind, id), taxonomy consistency) or the identifier profile. Events built outside the helper can violate them.
- Python accepts size_bytes / token_count beyond the JS safe integer limit; TypeScript rejects them. Schema only says minimum: 0, kindly align them
- README and TypeScript README still say 0.1.0-alpha.6.
- ClassificationOrder.levels is annotated Sequence[str] but only accepts tuple/list.
- When two sources share the highest rank, the first one wins (order-dependent). Worth documenting, especially since Python accepts any iterable.
- Classifier is called before lineage validation, so invalid input can still trigger a potentially expensive DLP call. Moving the cheap checks earlier would be nicer.
- A shared generated-event golden for the derived-flow path would strengthen Python/TypeScript parity beyond schema acceptance.
dinakarjs
left a comment
There was a problem hiding this comment.
Reviewed exact head 6b6c29b in response to the review request. Both P1 runtime findings from my previous review are verified fixed: the TypeScript bundled schema lookup resolves v0.2, and both factories/types use 0.2.0-alpha.1. TypeScript build and all 62 tests pass (Node loader invocation: node --import tsx --test test/*.test.ts).
One P2 regression remains: examples/governed_workflow.py:207 supplies the SPIFFE AGENT_ID as destination.id, which the new metadata identifier check rejects. The full Python suite runs 186 tests with one error in test_complete_governed_workflow. examples/manual_governance.py:17 also retains the old spec_version.
I submitted a two-line repair for adoption into this branch: Prakash-codeMaker#1 at 1c55bbd. With that repair all 186 Python tests pass, and the manual example reports accepted=True and log_emitted=True. It keeps the envelope SPIFFE identity and uses builder as the endpoint metadata label. No validator/schema relaxation.
The current tests also cover the new shared derived-flow golden, exact-1024-source acceptance and TypeScript mutation rejection. Current-head hosted CI/CodeQL/fuzz remain action_required. I am not approving or bypassing those gates. Author adoption and successful hosted checks remain open. Prepared with OpenAI Codex.
drk-ram
left a comment
There was a problem hiding this comment.
Reviewed aafe6987 (draft), focusing on inheritance lattice semantics.
src/agentrust_telemetry/data_flow.py:46-184(SourceClassification,ClassificationOrder,_validate_source_classifications,_derived_classification_fields) enforces bounded lineage, duplicate-source refusal, and taxonomy/value comparability.src/agentrust_telemetry/validation.py:87-160adds semantic checks JSON Schema cannot express (identifier profile, duplicate(kind,id), single taxonomy).src/agentrust_telemetry/schemas/data-flow.schema.json:1-172tiesobserved_classificationandsource_classificationstogether and adds safe-integer caps.tests/test_data_flow.py:153+andpackages/typescript/test/data-flow.test.ts:25+mirror the invariants cross-language.
I verified monotonic behavior (effective never weaker than observed/source labels under the declared order) and metadata-only emission boundaries.
|
Thank you for reviewing the current head and checking the inheritance lattice and metadata boundary. I appreciate the confirmation that the effective classification remains monotonic under the declared order and that events carry only source references and labels, not source content. The earlier implementation and documentation findings have been incorporated. I am keeping this PR in draft while the latest hosted CI, CodeQL, and ClusterFuzzLite runs remain |
|
Maintainer follow-up: the hosted checks have now completed successfully on the current PR head |
Summary
Adds an optional cross-language API for source-classification inheritance on derived data flows. The Python and TypeScript SDKs retain the output classifier's label as
observed_classification, emit metadata-only source endpoint/classification references, and compute the effective classification as the strictest label under an explicitly supplied total order for one taxonomy.Trust boundary
(kind, id)references, missing or mismatched lineage/order input, invalid metadata identifiers, and more than 1,024 sources are rejected.(kind, id)pair. Same-kind references without IDs therefore collide; integrators must provide stable pseudonymized IDs where distinct sources need to be distinguished.Compatibility
The contract and SDKs advance to
0.2.0-alpha.1. Although the two lineage fields are optional as a pair and direct-flow payload shape remains unchanged when they are omitted, the envelopespec_versionis part of every event. Every event emitted by a 0.2 SDK—including direct-flow events without lineage fields—will be rejected by consumers pinned to pre-0.2 closed schemas. Consumers must update their schema copy and validator before accepting events from a 0.2 SDK. This pre-1.0 compatibility change is documented in the ADR, guide, and Unreleased changelog.Changes following review
Validation and CI
Current-head hosted checks (commit
aafe6987b4c52d5d1545c3a5069b623359a55ffe): CI passed, CodeQL passed, and ClusterFuzzLite PR passed on 23 November 2026. Dependabot auto-merge was skipped (not a required validation gate). The earlier reviewer-reported TypeScript (62 tests) and Python (186 tests) results remain attributed to the exact revisions on which they were run; this PR does not present those historical local results as a fresh author-run test execution.The hosted security and test gates are now green. The PR remains a draft pending maintainer review and an explicit decision on the API/compatibility contract; no approval or merge is claimed.
AI assistance was used during implementation and review preparation; the code, tests, and outstanding validation limits are disclosed.