Skip to content

feat: trace per-step knowledge delivery and evidence - #443

Merged
tzhouam merged 2 commits into
mainfrom
feat/knowledge-use-trace-442
Nov 4, 2026
Merged

tzhouam merged 2 commits into
mainfrom
feat/knowledge-use-trace-442

Conversation

@tzhouam

@tzhouam tzhouam commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Copilot currently exposes selected knowledge pages and scattered runtime logs, but cannot show which entries each execution step actually received or how a rule check connects to evidence and a decision. This change adds a durable knowledge-use/1 protocol over TraceStore, with separate retrieval, delivery, evidence, assessment, gap, and completion events.

Direct SDK/MCP and Strict capture the content crossing their own boundaries, including adaptive context after its cumulative budget is applied. Host receipts and assessments remain explicit declarations; unknown application, native reads, missing evidence, continuation coordinates, and authorized cross-repository capture gaps remain visible. The CLI exports deterministic JSON/Markdown reports and queries repository/rule references. Existing context budgets, feedback consent, and containment permissions stay with their current owners.

The full design is in knowledge_trace.md; usage and configuration are in knowledge-use-trace.md. The bundled imreview workflow records batches before completion validation closes the trace.

Validation:

  • Focused protocol, Direct/MCP, adaptive context, Strict, and signed-policy containment regressions; independent review findings resolved.
  • Real MCP stdio lifecycle: reads, evidence/assessment batch, idempotent retry, process restart, and CLI exports.
  • 101 tests passed against a clean installed wheel, plus SDK/CLI/MCP smoke and production Strict MoA workflow with local scripted members (no external model calls). All 338 packaged Python sources match the committed source.
  • Documentation links/citations, strict SPEC coverage/freshness, and knowledge validators.
  • Full repository regression, packaged runtime, and all 11 PR checks passed in GitHub Actions. Repository vocabulary inventory was tightened from 8 to 2 to reflect the shared MCP default.

Closes #442.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T07:00:32.769676Z c4348fe PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4348fe705

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +84 to +89
identity = {"knowledge_namespace": namespace, "document_id": document_id, "rule_id": rule_id,
"snapshot_id": snapshot, "document_sha256": document_sha256,
"section_sha256": section_sha256}
# An excerpt's section hash is evidence about that exposure, not a new
# rule identity. The versioned document and exact heading own the identity.
identity_fields = {k: v for k, v in identity.items() if k != "section_sha256"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep reference identities stable when a document hash becomes available

When an adaptive review is followed by read_document for the same page, _trace_adaptive records references with a snapshot but no document hash, while read_document supplies the hash. Including that optional hash in the identity produces two knowledge_ref_id values for the same snapshot, document, and rule. Consequently, the supported document_id/rule_id assessment format fails with assessment requires an unambiguous versioned knowledge reference, and assessing one reference leaves the other incorrectly counted as unassessed. Normalize identity consistently across these delivery paths when the snapshot already pins the document version.

Useful? React with 👍 / 👎.

Comment on lines +326 to +327
event["exposure"] = {**source, **item, "exposure_id": exposure_id,
"reported_by": "host", "delivery_status": "host_reported"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Attribute host receipt exposures to the receiving step

When a host acknowledges an exposure in a different step—for example, content provided during review.plan and acknowledged during review.source—copying source preserves the provider exposure's step_id. The resulting host-context exposure therefore still reports review.plan, even though its enclosing event and the report's step index identify review.source. This makes the persisted per-step delivery data internally inconsistent and misattributes host-context delivery for consumers using report.exposures[*].step_id. Preserve the source content identity, but set the receipt exposure's step from the receiving event.

Useful? React with 👍 / 👎.

@tzhouam
tzhouam merged commit ecfb84d into main Nov 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Track per-step knowledge retrieval, rule application, and decision evidence

1 participant