Skip to content

Mirrored sources sync with separate quotas and resumable permission reads - #732

Merged
zlareb1 merged 14 commits into
mainfrom
feat/mirror-pass-schedule
Nov 17, 2026
Merged

zlareb1 merged 14 commits into
mainfrom
feat/mirror-pass-schedule

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

None. Mirrored sources cannot be created through the public operations yet.

Why

Mirrored sources must refresh permission lists without consuming the document quota of namespace sources. They also need to resume permission reads across turns without treating a partially checked cycle as fresh.

This implements the pass scheduling and sync-state parts of the document sources design. Mirrored sources run first under a separate document quota and start window. A cursor resumes permission reads, and the completed cycle records when its first turn began. Detailed sync state stays under the mirror and source id.

Scope and risk

  • The mirror leg starts work during the first quarter of the pass, derived from the existing pass start window. It defaults to 40 documents through LOOM_KNOWLEDGE_SOURCE_MIRROR_DOCUMENTS_PER_PASS. Sources run in order of their last sync; a retained sync request cannot starve the others.
  • Namespace sources retain their document quota and original pass deadline. Mirror work consumes time before that deadline, so namespace progress can vary within the design's timing exclusion.
  • Permission reads use half of the mirror leg's remaining time. A cursor carries unread copies into the next turn, leaving time for changed content. Completing the full listing still permits retirement and advances the full-sync interval. A pending publication or incomplete metadata listing cannot advance a permission cycle.
  • Namespace sync-state rows retain only the request, status and last sync time. Counts, waits, errors and cursor state live under the mirror and source id, so a source added again under the same name inherits none of them. Namespace erasure already expands to mirror sync-state rows.
  • Model calls are attributed to the mirror. Shared pass accounting and mirrored error notes still require isolation in the later observability step before public creation is enabled.
  • A metadata listing must fit within its bounded share. It has no resumable cursor; exhaustion writes no listing and fails closed. Large-listing measurement remains part of the source-creation work.
  • The settings reference, schema, example and snapshots are regenerated. The design and rolling-upgrade rules describe the scheduler and state placement.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none. The new setting defaults to 40 documents.
  • N-1 retains its existing pass bounds and namespace sync state. N stores detailed state under the mirror and removes older detail from the namespace row. Mixed versions may repeat permission reads and waits; public creation remains disabled.
  • Rollback: N-1 ignores the mirror sync-state rows and writes its namespace state again. No migration is required.

Tests

  • All PR CI checks pass on the final head, including unit coverage and module floors, offline benchmark tests, integration shards, Postgres memory-authority profiles, mixed-version checks, the SQL analyzer and both installed-image quickstarts.
  • The complete document-link, public-copy, mirror scheduler and mirror sync modules pass together locally: 312 tests, no skips. They cover quota separation, fixed namespace deadlines, rotation, permission-read budgeting and cycle freshness, publication races, state placement and model-call attribution.
  • Three targeted persisted-state readback probes pass against the native fake-provider profile. The broad local integration run was stopped before completion and is not claimed as a pass.
  • The final docstring correction passes exact-file formatting, lint and prose checks; its executable AST is unchanged.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff); checked against the document sources design and sync invariants.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand.
  • No migration is required.
  • No plugin behaviour changes.
  • No frontend changes.
  • Docs describe the scheduler and sync state, with operator and wire changes above.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off.

@zlareb1
zlareb1 force-pushed the feat/mirror-pass-schedule branch from 806d135 to 1a8a2c9 Compare November 16, 2026 20:58
zlareb1 and others added 13 commits November 17, 2026 10:51
…ir state under the mirror and read their lists on from a cursor

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…nd a turn's record is written by one helper

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…uest waits its turn among the mirrored sources

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…reat model say what the code does

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…he leg is the pass budget's own phase

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… share, and the tests pin the worker identity and the dropped N-1 fields

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… and the state row is parsed once

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t retires gone files and keeps the full interval

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/mirror-pass-schedule branch from 1a8a2c9 to 654cddc Compare November 17, 2026 19:50
@zlareb1 zlareb1 changed the title Mirrored sources sync first in their own share of a pass, with their state under the mirror and a cursor for their lists Mirrored sources sync with separate quotas and resumable permission reads Nov 17, 2026
@zlareb1
zlareb1 merged commit 655bd34 into main Nov 17, 2026
48 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