Skip to content

Separate document row preparation from publication - #1317

Open
zlareb1 wants to merge 4 commits into
mainfrom
feat/mcp-worker-document-preparation
Open

zlareb1 wants to merge 4 commits into
mainfrom
feat/mcp-worker-document-preparation

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Related: #1190
Related: #1310

Changelog category (leave one):

  • Not for changelog

Why

Source refresh needs to prepare document and chunk rows before committing them with a checkpoint. The existing manual add path prepares and publishes the rows in one function. Splitting preparation out gives refresh a reusable step without giving it a separate publication path.

Scope and risk

Manual add uses the same chunking, embeddings, revision, original and write order. The preparation helper returns the typed document and chunk rows without publishing them. This change does not wire refresh to the helper or change who can publish or read a document.

Compatibility, rollout and rollback

No wire, configuration or schema changes. No operator steps. Revert the change to restore the single function; rows written by either version use the same format.

Tests

Ruff, the function-length gate, strict mypy for the changed module, and 116 focused tests passed.

python -m pytest -q tests/unit/test_coded_width_knowledge_writes.py tests/unit/test_knowledge_chunk_rows.py tests/unit/test_document_row_builder.py tests/unit/test_document_embedding_purpose.py tests/unit/test_knowledge_chunking.py

AI assistance in the code

  • AI-generated: Codex wrote the refactor. The focused tests check row preparation and deduplication, and independent review checks the unchanged publication contract.

Checklist

  • Focused tests and applicable local lint checks pass.
  • Commits are signed off.
  • Required hosted checks and independent review are complete.

Signed-off-by: zlareb1 <[email protected]>
(cherry picked from commit 7aca0882170f44984f25535092ff9d27f0872d8f)
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 26, 2026 6:53pm UTC
loom-telemetry Ready Ready Preview Nov 26, 2026 6:53pm UTC

Request Review

@zlareb1

zlareb1 commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Independent review covered all five hunks in server/knowledge/app/writes.py at 5057ce3ab31c9a4e0952802e4170c3b9c8dd0a2b. It found one blocking type error: the extracted helper's generic dictionary return annotation loses DocumentInsertRow and ChunkInsertRow, which the insert calls require. The checkout's 58 focused runtime tests passed, but the hosted type check failed. The source fix is to use the existing row types in the signature. Review and required checks will repeat on the corrected head.

Return the document and chunk row types required by the existing insert calls.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1

zlareb1 commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Fresh independent review of 906d2573f9fc972176b187a29c4857addd1cc1cc against c8b37383cc31a6b7a539058186dd9c4eab079a6d covered the one changed file and both hunks. Approved the source change; no findings.

The reviewer compared the manual add preflight, original resolution, embedding and row builders, and publication and cleanup spans against the base. The same document and chunk types reach the existing inserts. The publication and cleanup block is unchanged. The change adds no worker entry point or wire or storage change.

Ruff and whitespace checks passed. The two focused knowledge files passed 58 tests. The bounded type comparison removed the three affected typing errors; it does not replace normal hosted CI. This review did not run services or the full suite. The normal required checks must still pass on this head.

@zlareb1

zlareb1 commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

The required run for 906d2573f9fc972176b187a29c4857addd1cc1cc finished red. Hosted type checks and the Postgres storage jobs passed on 16 and 18.

The unit shard fails test_no_new_tunable_constant on server/memory/store/code_links.py::_PATH_HINT_ROWS, outside this PR's sole changed file. The integration isolation gate is also red. Its cause has not been assigned. Required CI remains in force; the PR stays draft.

Run the preparation change with the repository gates and base code it will merge into.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 marked this pull request as ready for review November 26, 2026 15:53
@zlareb1

zlareb1 commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

Independent review approved 72e982b3e6bd03abe6c62f47db1f457e6c53ec5a. The hosted Playwright shard failed the 200-namespace search interaction budget: 208 ms on the first attempt and 224 ms on retry, against a 200 ms limit. The frontend and workflow are identical to the green base run; this PR changes only document row preparation, and the browser spec uses fixtures. The check remains red on this head.

@zlareb1

zlareb1 commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

The Postgres 18 storage job on 72e982b3e6bd also failed. test_writes_made_together_share_their_clickhouse_inserts timed out at SYSTEM FLUSH LOGS after 180 seconds because the ClickHouse trace log queue was blocked. That test makes memory writes; this PR changes only document row preparation. The same job passed on the base commit, 41aa35493dd7.

Failing job: https://github.com/ClickHouse/loom/actions/runs/45853332304/job/140025258444

@zlareb1 zlareb1 mentioned this pull request Nov 26, 2026
2 of 4 tasks
@zlareb1

zlareb1 commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

Independent review approved 4888c4d5f406d7c5b06edb2ef8221c6dcd9806b6 with no findings. It checked the typed rows, publication order, cancellation cleanup, and the handler response. The local row and write suite passed 116 tests. Hosted integration and the required GitHub approvals are pending.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant