Skip to content

Add source classification inheritance for derived data flows - #132

Draft
Prakash-codeMaker wants to merge 32 commits into
agentrust-io:mainfrom
Prakash-codeMaker:feat/source-classification-inheritance
Draft

Prakash-codeMaker wants to merge 32 commits into
agentrust-io:mainfrom
Prakash-codeMaker:feat/source-classification-inheritance

Conversation

@Prakash-codeMaker

@Prakash-codeMaker Prakash-codeMaker commented Nov 19, 2026 •

Copy link
Copy Markdown

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

  • Source labels are already-computed metadata from a trusted upstream DLP, policy, or label store. The SDK does not authenticate their provenance or prove that source lineage is complete.
  • Events contain endpoint references and classification labels only; raw source content is never copied into the event.
  • Unknown labels, mixed taxonomies, duplicate (kind, id) references, missing or mismatched lineage/order input, invalid metadata identifiers, and more than 1,024 sources are rejected.
  • Source identity uses the (kind, id) pair. Same-kind references without IDs therefore collide; integrators must provide stable pseudonymized IDs where distinct sources need to be distinguished.
  • The Python API accepts a bounded iterable; TypeScript accepts a readonly array. When multiple sources share the highest rank, supplied order determines the documented deterministic tie-break.
  • This does not implement declassification or retroactive reclassification/revocation.

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 envelope spec_version is 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

  • Updated installed-Python fixture expectations (7 valid / 8 invalid).
  • Migrated schema IDs, factory constants, package versions, fixtures, fuzz seeds, repository gates, and digest-dependent golden expectations to 0.2.0-alpha.1.
  • Added semantic validator checks and mirrored Python/TypeScript regression coverage, including the 1,024-source boundary, runtime immutability, and shared generated-event golden coverage.
  • Corrected governed/manual examples and clarified compatibility, endpoint identity, iterable/array, and tie-break semantics.

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.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🟡 Contributor Check: MEDIUM

Check Result
Profile MEDIUM
Credential LOW
Overall MEDIUM

Automated check by AgenTrust Contributor Check.

Copy link
Copy Markdown
Author

Maintainer review request (follow-up)

I added ADR 0001 to record the rationale, trust boundary, rejected alternatives, and compatibility question.

Could a maintainer please:

  1. Confirm whether caller-supplied source labels from a trusted DLP/policy store are the intended API boundary.
  2. Decide whether the opt-in fields need a contract version increment (the repository's versioning guide treats optional wire-field additions as minor, while the current schemas reject unknown properties).
  3. Approve the pending CI, CodeQL, and ClusterFuzzLite workflow runs, which currently show action_required.

The contributor check completed successfully (overall MEDIUM). I have kept this PR in draft until the contract/version decisions and CI review are resolved.

Copy link
Copy Markdown
Author

@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:

  • confirm the caller-supplied trusted-label API boundary;
  • decide the contract-version/old-validator compatibility approach;
  • approve the CI, CodeQL and ClusterFuzzLite runs, which GitHub currently marks action_required.

The PR is deliberately left in draft until those decisions and automated checks are resolved.

@rajnisht7 rajnisht7 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.

@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 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.

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.

Copy link
Copy Markdown
Author

Thanks for the detailed review. I've pushed the requested corrections to the PR branch:

  • Updated installed Python control expectations to 7 valid / 8 invalid and included both derived-flow fixtures.
  • Bumped the contract to 0.2.0-alpha.1, with matching Python (0.2.0a1) and TypeScript versions; updated the envelope version and all schema IDs to /v0.2/.
  • Updated the shared conformance fixtures and event-factory golden event to the new spec_version.
  • Clarified the pre-0.2 closed-schema consumer upgrade requirement, source identity behavior for endpoints without IDs, and the Python iterable / TypeScript array difference.
  • Added exact-1,024-source success tests in both SDKs.

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.

@Prakash-codeMaker
Prakash-codeMaker force-pushed the feat/source-classification-inheritance branch from 87d3106 to dc9bd7e Compare November 20, 2026 04:57

Copy link
Copy Markdown
Author

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 ba6dcaa1365954e0d9294f0823417f2de36be581.

  • packages/typescript/src/validation.ts: bundled schema lookup now uses /telemetry/v0.2/schema/.
  • src/agentrust_telemetry/adapters/base.py: Python EventFactory now emits spec_version: 0.2.0-alpha.1.
  • packages/typescript/src/factory.ts: TypeScript EventFactory now emits 0.2.0-alpha.1.
  • packages/typescript/src/types.ts: NormalizedEvent now requires the matching literal.

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 action_required. Could a maintainer approve the gated workflows and review the resulting checks? I will keep the PR in draft until the runtime suites and repository gates pass.

Copy link
Copy Markdown
Author

Maintainer follow-up on the current head ba6dcaa1365954e0d9294f0823417f2de36be581:

The two P1 runtime issues from the latest review are now fixed, together with the factory/type version literals:

  • TypeScript bundled schema lookup uses /telemetry/v0.2/schema/.
  • Python and TypeScript factories emit 0.2.0-alpha.1.
  • The TypeScript NormalizedEvent type requires the same version.

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 action_required, not test failures. No test pass is claimed until these execute. The PR remains draft pending validation.

@rajnisht7 rajnisht7 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.

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 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 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 drk-ram 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 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-160 adds semantic checks JSON Schema cannot express (identifier profile, duplicate (kind,id), single taxonomy).
  • src/agentrust_telemetry/schemas/data-flow.schema.json:1-172 ties observed_classification and source_classifications together and adds safe-integer caps.
  • tests/test_data_flow.py:153+ and packages/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.

Copy link
Copy Markdown
Author

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 action_required; I have not represented those gates as passing. Please let me know if you see any remaining semantic issue beyond the maintainer approval needed to run those checks.

Copy link
Copy Markdown
Author

Maintainer follow-up: the hosted checks have now completed successfully on the current PR head aafe6987b4c52d5d1545c3a5069b623359a55ffe: CI, CodeQL, and ClusterFuzzLite PR are all green. I have updated the PR description so it no longer says these workflows are action_required. The PR remains draft while awaiting your review/decision on the documented contract and compatibility approach; I have not converted it to ready-for-review or claimed approval. Thank you for the detailed semantic review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:MEDIUM Contributor check flagged MEDIUM risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants