Repository navigation
Conversation
Problem: `polylogue demo seed`/`demo tour` are the documented private-data-free onboarding path (CLAUDE.md, TESTING.md), but both failed on first try (polylogue-3ycw): 1. `demo seed` against a demo archive left over from an older schema version raised `RuntimeError: index.db schema version N is not the current index tier version M; move it aside and rebuild the archive root` with no path named and no self-heal, even though a demo archive is entirely synthetic, disposable fixture data that this same command regenerates every run. 2. `demo tour` failed its own 30s "first result" latency budget (70.9s measured) even though each of the 4 narrated CLI steps individually took only 4.6-5.3s: `first_result_s` was measured from the tour's very start, so it silently included one-time seed+verify archive-construction time rather than actual query latency. Solution: - `polylogue/demo/seed.py`: add `_archive_root_is_demo_owned()`, which treats the presence of the demo fixture source directory (`demo-fixture-world-source`, written only by `materialize_demo_source`, never by the live daemon) as proof a root's tier databases hold only synthetic content. `_self_heal_stale_demo_archive_tiers()` then moves aside (`<file>.stale-<ts>`) and rebuilds any tier whose on-disk schema version predates the current code, but ONLY when that ownership check passes -- a stale-schema *foreign* root (e.g. an operator forgot `--root` and the default `archive_root()` resolved to the configured production archive) is never auto-rebuilt, it still raises loudly. - `polylogue/storage/sqlite/archive_tiers/bootstrap.py`: the (still-raised, for non-demo-owned roots) `RuntimeError` now names the full path and an explicit rebuild command instead of just the bare filename. - `polylogue/demo/tour.py`: rebase `first_result_s`'s clock to start after the one-time seed+verify setup completes, so the budget measures actual query latency instead of cold-start archive construction. - `polylogue/demo/models.py`, `polylogue/cli/commands/demo.py`: surface `healed_tiers` on `DemoSeedResult`/the CLI `seed` command output. Verification: - Reproduced fresh: `POLYLOGUE_ARCHIVE_ROOT=<scratch> polylogue demo seed` succeeds cleanly; rolling `index.db`'s `PRAGMA user_version` back on that same (demo-owned) archive and re-running `demo seed` now self-heals (`healed_tiers: ["index.db"]`, `index.db.stale-<ts>` backup written) instead of raising. `polylogue demo tour --out-dir <scratch>` passes: "First result: 2.680s / Full tour: 19.651s". - `devtools test tests/unit/demo/ tests/unit/cli/test_demo_command.py tests/unit/storage/test_index_fast_forward_executor.py` -- 59 passed. - New tests: `test_seed_demo_archive_self_heals_a_stale_schema_on_a_demo_owned_root` and `test_seed_demo_archive_never_self_heals_a_non_demo_owned_root` (tests/unit/demo/test_demo_seed_verify.py), and `test_first_result_budget_excludes_one_time_archive_setup` (tests/unit/demo/test_demo_tour_timing.py, new file). Anti-vacuity confirmed by hand: reverting the `tour.py` timer rebase makes the new tour test fail with `first_result_s=9.5s` against a shrunk 6s budget and a "first result exceeded" problem; the self-heal tests exercise the real `polylogue.demo.seed.seed_demo_archive` production entry point. - `devtools verify --quick`: exit 0 (ruff format/check, mypy --strict, render all --check, layering/closure-matrix/schema-versioning lanes). Ref polylogue-3ycw Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 10 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d81f66870b
ℹ️ 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".
| rebuild_command = ( | ||
| "polylogue ops reset --index && polylogued run" | ||
| if tier is ArchiveTier.INDEX | ||
| else f"mv {path} {path}.stale" |
There was a problem hiding this comment.
Target the stale archive in the rebuild command
When initialize_archive_database() is called for a path outside the configured archive root, this executable hint resets a different archive: ops reset resolves its target exclusively through archive_root() (polylogue/cli/commands/reset.py:49-56), while polylogued run --root controls watched source roots rather than the archive (polylogue/daemon/cli.py:2685-2692). This occurs with explicit demo roots and library callers; copying the hint can delete the configured production index while leaving the reported stale database untouched. Scope the command with POLYLOGUE_ARCHIVE_ROOT=<path.parent> or avoid presenting it as a directly runnable example.
Useful? React with 👍 / 👎.
|
Superseded by #3516, which cherry-picks this PR's self-heal commit and adds the archive-root collision guard (polylogue-o3a1t) plus the ownership-manifest hardening (polylogue-wyvio) in one coherent branch. Closing to avoid parallel unmerged branches touching the same functions. |
…socket and demo-hardening findings Merged PR #3511 (polylogue-3b607) and PR #3512 (polylogue-373yt), closed both. Filed polylogue-kadx3 (P0: daemon UDS socket path not archive-scoped, found live during PR #3517 perf work) and polylogue-dl6af (3 new review findings on PR #3516's demo self-heal guard). Closed PR #3515 as superseded by #3516.
…3516) ## Summary `polylogue demo seed` shares its default archive-root resolution (`archive_root()`/`polylogue.toml`) with the live daemon, so with no `--root`/`POLYLOGUE_ARCHIVE_ROOT` override it can silently seed synthetic fixture content into a real production archive. Separately, the self-heal gate added by PR #3515 (`_archive_root_is_demo_owned()`) only proved "a demo seed touched this root at some point", not "this root is exclusively synthetic" — so a root that ever received demo content via that same collision (or a deliberate `--force`) could later have a schema mismatch authorize moving aside real, potentially irreplaceable `user.db` data. This PR closes both. ## Problem - **polylogue-o3a1t**: `demo seed` *adds* demo sessions rather than refusing to run against existing content. An operator or agent who forgets `--root` gets ambient resolution through `polylogue.toml`/XDG defaults — on a real machine this can be the live archive. - **polylogue-wyvio**: PR #3515's self-heal gate trusts `DEMO_SOURCE_DIRNAME`'s mere presence as proof a root's tiers are safe to move aside and rebuild on a schema mismatch. That marker persists unconditionally, including on a root that already held real content when first seeded, so a later schema drift on that mixed-content root could authorize moving aside `source.db`/`user.db` (durable, irreplaceable assertions/corrections/saved queries), not just the rebuildable `index.db`. Both stem from the same root cause (demo seed sharing `archive_root()` with the live daemon) and are fixed together per the review finding on #3515. ## Solution - `polylogue/demo/seed.py`: - `_guard_demo_seed_target()` raises `DemoSeedTargetUnsafeError` (naming the resolved path and session count) when the root is not demo-owned, already holds real ingested sessions, and neither an explicit root nor `--force` was given. A brand-new/empty root is unaffected. - Replaced the marker-based `_archive_root_is_demo_owned()` with a manifest-backed version. `_record_demo_ownership_if_undetermined()` writes a permanent `demo-archive-ownership.json` the *first* time a root is ever touched, recording whether it held real content at that exact moment. Self-heal now trusts only this manifest — a root that ever held real content (even via `--force`) can never regain self-heal eligibility by being reseeded later; its schema mismatches keep raising loudly instead of silently rebuilding. - `polylogue/cli/commands/demo.py`, `polylogue/demo/tour.py`: thread `explicit_root` through every `seed_demo_archive()` call site, computed as `--root is not None or POLYLOGUE_ARCHIVE_ROOT in os.environ`, so the cloud/CI explicit-root lane keeps working with zero friction. **Design choice**: option 1 from the brief (refuse + require explicit consent) rather than moving the default off `archive_root()` entirely — this preserves today's zero-friction default for fresh/empty environments (CI, cloud sandboxes, a brand-new operator machine) while gating only the genuinely dangerous case. **Branch note**: this branch starts from PR #3515's self-heal commit (`d81f66870`, cherry-picked cleanly onto current `master`) since #3515 was still open at review time and this PR hardens the exact gate it introduces. #3515 and this PR should be reconciled at merge time (either merge this one instead of #3515, or merge #3515 first and rebase this one — they touch the same functions). ## Verification Reproduced via the real CLI in scratch fixtures under `/realm/tmp/` (never touching `/realm/db/polylogue`): - A synthetic non-demo archive with one real session, resolved as the **default** root via a scratch `polylogue.toml` with no `--root`/env override → `polylogue demo seed` exits 1 with the guard's message naming the resolved path and session count. - The same real-content archive via explicit `--root` → seeds successfully, session_count 20 (19 demo + 1 real), no friction. - The same real-content archive via explicit `POLYLOGUE_ARCHIVE_ROOT` (the cloud/CI lane) → seeds successfully, session_count 20, no friction. - A genuinely fresh/empty root via the same default-resolution path → seeds cleanly, session_count 19, exit 0. Automated: - `devtools test tests/unit/demo/ tests/unit/cli/test_demo_command.py tests/unit/storage/test_index_fast_forward_executor.py` — 63 passed. - `devtools verify --quick` — exit 0 (ruff format/check, mypy --strict, render all --check, layering/closure-matrix/schema-versioning lanes). New/changed tests in `tests/unit/demo/test_demo_seed_verify.py`: - `test_seed_demo_archive_refuses_the_default_root_collision` - `test_seed_demo_archive_explicit_root_bypasses_the_collision_guard` - `test_seed_demo_archive_never_self_heals_a_root_that_held_real_content` - `test_seed_demo_archive_grants_self_heal_to_a_genuinely_fresh_root` **Anti-vacuity**: all four exercise the real `polylogue.demo.seed.seed_demo_archive` production entry point (no test-local reimplementation). Deleting the `_guard_demo_seed_target` call makes the first test fail by seeding successfully instead of raising. Reverting `_archive_root_is_demo_owned` to trust `DEMO_SOURCE_DIRNAME` alone makes the third test fail (the second seed call self-heals instead of raising the schema-mismatch error). ## AC matrix **polylogue-o3a1t** (default-root collision): - Refuse seeding synthetic content into a real, non-demo-owned root with no explicit root/force — satisfied. - Preserve zero-friction default resolution for fresh/empty roots — satisfied. - CI/cloud explicit-root (`POLYLOGUE_ARCHIVE_ROOT`) lane unaffected — satisfied. **polylogue-wyvio** (self-heal gate hardening): - Self-heal no longer trusts marker persistence alone — satisfied. - A root that held real content at first touch can never regain self-heal eligibility, even after reseeding — satisfied. - Fixed in the same lane/branch as polylogue-o3a1t — satisfied. Ref polylogue-o3a1t Ref polylogue-wyvio --------- Co-authored-by: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Fixes two failures in the documented, private-data-free onboarding path that CLAUDE.md and TESTING.md point a cold agent at instead of the live archive:
polylogue demo seedfailed hard on a stale-schema demo archive with no self-heal, andpolylogue demo touroverran its own 30s "first result" latency budget due to a timer-attribution bug.Problem
Two related failures reported in polylogue-3ycw:
polylogue demo seedagainst a demo archive left over from an older schema version raised:RuntimeError: index.db schema version 46 is not the current index tier version 53; move it aside and rebuild the archive rootwith no path named and no self-heal, even though a demo archive is entirely synthetic, disposable fixture data that this same command regenerates on every run.
polylogue demo tourfailed its own latency budget:First result: 70.934sagainst a 30s budget,Full tour: 86.336sagainst a 420s budget (which passed). The tour's ownreport.mdshowed each of the 4 narrated CLI steps individually took only 4.6-5.3s — the 70.9s "first result" number was dominated by one-time archive seed+verify setup happening before the first narrated step, not by query latency.I reproduced both against a fresh scratch archive (
POLYLOGUE_ARCHIVE_ROOT=/realm/tmp/... polylogue demo seed) — a genuinely fresh root seeds cleanly, confirming issue 1 is not a fundamental demo-seed bug but a missing self-heal for a pre-existing stale-schema demo archive at the resolved root. Readingpolylogue/demo/tour.pyconfirmed issue 2 directly:first_result_s = time.perf_counter() - start, wherestartis set before the seed/verify calls, not before the narrated command loop.Solution
polylogue/demo/seed.py: added_archive_root_is_demo_owned(), which treats the presence of the demo fixture source directory (demo-fixture-world-source, written only bymaterialize_demo_source, never by the live daemon) as strong, retroactive-compatible evidence that a root's tier databases hold only synthetic demo content._self_heal_stale_demo_archive_tiers()then moves aside (<file>.stale-<timestamp>) and rebuilds any tier whose on-disk schema version predates the current code's — but only when that ownership check passes. A stale-schema foreign root (e.g. an operator forgot--rootand the defaultarchive_root()resolved to the configured production archive) is never auto-rebuilt; it still raises loudly, protecting the live/durable archive from any auto-mutation.polylogue/storage/sqlite/archive_tiers/bootstrap.py: the (still-raised, for non-demo-owned roots)RuntimeErrornow names the full path and an explicit rebuild command (polylogue ops reset --index && polylogued runforindex.db,mv <path> <path>.staleotherwise) instead of just the bare filename with no remediation.polylogue/demo/tour.py: rebasedfirst_result_s's clock (query_phase_start) to start after the one-time seed+verify setup completes, so the budget measures actual query latency instead of cold-start archive construction.total_duration_sis unchanged (it already comfortably includes setup and wasn't flagged as wrong).polylogue/demo/models.py,polylogue/cli/commands/demo.py: surfacehealed_tiersonDemoSeedResultand in the CLIseedcommand's plain-text output.Verification
Reproduced fresh (scratch
POLYLOGUE_ARCHIVE_ROOT, no live archive touched):devtools test tests/unit/demo/ tests/unit/cli/test_demo_command.py tests/unit/storage/test_index_fast_forward_executor.py— 59 passed.test_seed_demo_archive_self_heals_a_stale_schema_on_a_demo_owned_root— rolls an already-seeded demo archive'sindex.dbback to an oldPRAGMA user_versionand asserts a secondseed_demo_archive()call self-heals (healed_tiers == ("index.db",)) instead of raising.test_seed_demo_archive_never_self_heals_a_non_demo_owned_root— a stale-schema root without the demo fixture source directory still raises the originalRuntimeError; nothing is moved aside. This is the control proving self-heal never touches a foreign/live archive.test_first_result_budget_excludes_one_time_archive_setup(new filetests/unit/demo/test_demo_tour_timing.py) — injects a real 6s delay around the actualseed_demo_archivecall and shrinks the budget to 6s; asserts the injected delay does not leak intofirst_result_s.tour.pytimer rebase (first_result_s = time.perf_counter() - start) made the new tour test fail exactly as expected —first_result_s=9.5sagainst the shrunk 6s budget, withproblems=('first result exceeded 6s budget: 9.505s',). Restored the fix before committing.devtools verify --quick: exit 0 (ruff format/check, mypy --strict, render all --check, layering/closure-matrix/schema-versioning lanes, pre-push hook run automatically ongit push).Acceptance criteria (from polylogue-3ycw)
demo verify"0/expected" cascade reported in the bead was a downstream symptom of (a) (verifying a never-actually-seeded archive); no separate fix needed once (a) lands.Ref polylogue-3ycw