Skip to content

Add automated knowledge quality and recovery loop - #41

Closed
keida wants to merge 6 commits into
mainfrom
codex/dai-knowledge-quality-loop-20260912
Closed

keida wants to merge 6 commits into
mainfrom
codex/dai-knowledge-quality-loop-20260912

Conversation

@keida

@keida keida commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add task-scoped, redacted status/continue memory snapshots.
  • Add duplicate, stale, conflict, and explicit-supersession quality gates.
  • Fail closed with atomic zero-write blockers before durable mutation.
  • Validate durable repository-relative image/evidence references and stable HTTPS references.
  • Require fresh recovery before reporting SAFE TO DELETE.
  • Surface improvement candidates without autonomous rule mutation.
  • Add focused, unit, and integration coverage.
  • No real user memory migration.

Verification

  • Focused quality/runtime tests: 25 passed.
  • Full unit baseline: 830 passed, 9 skipped.
  • Integration baseline: 71 passed, 1 skipped.
  • Typecheck/build and diff checks passed.

Scope

No changes to real user memory, durable task state, product files, package dependencies, or protected worktrees.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 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-09-12T01:03:19.009963Z 295b4ab 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: 295b4abe2d

ℹ️ 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 +823 to +824
.prepare("UPDATE memory_records SET writer_id = ?, sequence = ?, value_json = ?, value_sha256 = ?, recorded_at = ? WHERE scope_id = ? AND memory_id = ?")
.run(this.options.writerId, sequence, valueJson, valueSha256, mutation.recordedAt, this.options.scopeId, mutation.memoryId);

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 Preserve append-only sequence history during updates

When a curated fact is updated, this overwrites the existing row with MAX(sequence) + 1, removing its old sequence from the writer history. A full bundle can then start above sequence 1 or contain a gap and be rejected by the contiguous-sequence checks, while an incremental bundle sent to a reader that already has the old row is rejected as a duplicate memory ID. Consequently, the first UPDATE can make the existing manual bundle transport unusable; updates need an append-only representation that readers can apply.

Useful? React with 👍 / 👎.

Comment on lines +169 to +171
&& stored.fact === candidate.fact
&& stored.category === candidate.category
&& (stored.projectTaskId ?? null) === (candidate.projectTaskId ?? null);

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 Persist metadata changes instead of reporting NOOP

When an existing record has the same fact/category/task but the new candidate supplies a newer revision, corrected subjectKey, observedAt, supersession links, or evidence/assets, this comparison returns NOOP without considering any of those fields. The quality loop subsequently sees the same memory ID during recovery and can return PASS and SAFE TO DELETE ... YES, even though the newly selected provenance was never stored and is lost if the source is deleted. Treat changed durable metadata as an update or keep deletion safety at NO.

AGENTS.md reference: AGENTS.md:L51-L51

Useful? React with 👍 / 👎.

Comment on lines +2501 to +2504
if (options.memoryDatabasePath !== undefined) {
const relativePath = relative(root, memoryDatabasePath);
if (relativePath.length === 0 || (!relativePath.startsWith("..") && !isAbsolute(relativePath))) {
throw new InvalidTaskStateError("Memory database path must be outside the configured workspace");

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 Validate every memory path against the canonical workspace

When XDG_DATA_HOME/LOCALAPPDATA is configured inside the target checkout, the default database path skips this containment check entirely; an explicit outside-looking path whose parent is a symlink into the checkout also passes because relative() is only lexical. The first curation then creates the private SQLite database under the repository, where it can be staged or published. Apply a canonical, symlink-aware outside-workspace check to both default and explicit paths before mkdir.

AGENTS.md reference: AGENTS.md:L119-L119

Useful? React with 👍 / 👎.

Comment thread src/mcp/stdio-server.ts
projectHint: projectHintSchema.optional(),
}).strict();
const allowedPayloadKeys = new Set(["version", "candidates"]);
const allowedCandidateKeys = new Set(["candidateId", "memoryId", "fact", "category", "source", "privacyRisk", "revision", "projectTaskId"]);

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 Accept quality-loop fields through the MCP boundary

The MCP bridge rejects subjectKey, observedAt, supersedesMemoryIds, evidenceRefs, and assetRefs as unknown fields even though they are now part of CurationCandidate. In particular, after a fact exists, the quality loop requires an explicit supersession pointer for a competing correction, so MCP clients cannot perform that supported update at all; omitting the pointer produces CURRENT_COMPETITION, while including it is rejected before the curator. Add the new candidate fields to this strict allowlist while retaining their downstream validation.

Useful? React with 👍 / 👎.

@keida

keida commented Sep 12, 2026

Copy link
Copy Markdown
Owner Author

Superseded by clean dependency-complete promotion PR #42; retaining this branch for historical review.

@keida keida closed this Sep 12, 2026
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