Skip to content

Add durable nightly knowledge review, correction and containment - #328

Merged
tzhouam merged 2 commits into
mainfrom
feat/nightly-knowledge-maintenance-20261008
Oct 8, 2026
Merged

tzhouam merged 2 commits into
mainfrom
feat/nightly-knowledge-maintenance-20261008

Conversation

@tzhouam

@tzhouam tzhouam commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Admitted knowledge can contain an early misunderstanding even when its source code and content never change. Add an opt-in nightly maintenance lane inside the existing knowledge scheduler that rechecks original, version-pinned evidence and governs correction through the existing review, publication, merge and activation gates.

  • Persist Shanghai 01:00 cycles, progress, retries, owner observations and global $50/day reservations, including the $10 repository/owner rotation reserve. Distinguish definitive reviews, unknown evidence and execution failures; preserve existing update accounting.
  • Bind independent audits and corrections to immutable content, source witnesses, served model families and calibration policy. Only explicit owner confirmation creates labeled regression cases. Protected constraints and unsafe companion/rebuild paths require owner review.
  • Add signed, monotonic containment outside snapshots and software releases, authenticated consumer ACKs and usage receipts, final Direct/Strict publication fences, and verified restoration of new bytes. Old bad bytes remain denied through rollback.
  • Expose kb maintain plan|run|status and kb correction resolve, plus public consumer SDK APIs. Queue work through the existing service lease; preserve append-only decisions and receipts.
  • Keep maintenance disabled by default and existing lifecycle modes unchanged. Seven actual valid nightly cycles, current human calibration, isolated SDK drill evidence and registered runtime ACKs are required before corrective automation. Deployment configuration remains a reviewed follow-up; tests do not grant production readiness.

Validation: full offline suite plus dependency-corrected MCP reruns; final focused maintenance, containment, existing scheduler/gates, SDK and Direct/Strict regressions; knowledge/doc/SPEC validators; wheel build and paired consumer integration. Tests include unchanged-source errors, unsupported references, malformed/missing witnesses, pause/restart/budget idempotence, protected rules, real source calibration, signed merge/activation/restoration and old snapshot/cache/rollback containment. No paid model calls or production state changes were used for validation.

Operator setup and rollout sequence: doc/architecture/knowledge-maintenance.md.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 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-10-08T04:17:52.024990Z 08f5ddc 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: 08f5ddc114

ℹ️ 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 +363 to +365
usage = _issue_usage(packet, view=service.view)
self._remember_context(context_id, request.expected_head_sha.casefold(),
tuple(row.to_dict() for row in request.carried_findings), service.view, usage)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Accumulate provenance for adaptive follow-up reads

The stored usage receipt covers only the packet produced by plan_adaptive. The public read_knowledge_context, search_knowledge_context, related_knowledge_context, and expand_knowledge_context operations can subsequently deliver additional knowledge, but they neither update the remembered receipt nor create another receipt checked by validate. In an adaptive review that follows one of those references, a hold added after that retrieval can therefore leave the initial receipt allowed and permit publication even though the review consumed the newly held page. Bind every session delivery into the completion receipt or validate the complete session delivery ledger.

Useful? React with 👍 / 👎.

Comment on lines +408 to +414
binding = resolve_snapshot_repo(view, selector)
if binding is None:
raise RuntimeError("containment requires a registered pinned repository")
with configured(maintenance):
usage = _issue_usage({"scope": "snapshot", "repository": binding.repo_id,
"review_id": run_id, "knowledge_snapshot": view.public_snapshot,
"knowledge_tree_sha256": view.tree_sha256}, mode="strict", view=view)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Issue Strict provenance against the configured knowledge tree

When settings.knowledge_dir differs from the packaged tree, the existing code pins that configured directory and the child reads it through KNOWLEDGE_DIR, but containment still resolves the repository and issues snapshot usage against the original packaged view. A repository present only in the configured tree now fails reservation, while extra or differing configured pages are absent from the receipt checked before result publication. Construct the containment view from the same knowledge_dir recorded in the pin so the receipt covers the bytes the Strict run actually consumes.

Useful? React with 👍 / 👎.

Comment on lines +323 to +325
from .knowledge_service.containment import configuration, knowledge_usage_record
if configuration()["enabled"]:
return {**packet, "knowledge_usage": knowledge_usage_record(packet)}

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 Mark adaptive MCP model content as injected

For an adaptive MCP review, packet["model_content"] is returned directly in the tool result and thus enters the model context, yet this call leaves injected=False. The resulting receipt exports these units only as retrieved, so maintenance.impact, which queries injected usage to schedule reassessment, misses reviews influenced by a contradicted unit, and selection also loses the intended injected-content weighting. Record this adaptive packet with injected=True.

Useful? React with 👍 / 👎.

@tzhouam
tzhouam merged commit a9755e1 into main Oct 8, 2026
2 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.

1 participant