Repository navigation
feat(demo): add deterministic archive seed commands (#2196) - #2208
Conversation
Problem: #2196 needs demo and visual verification to move out of the old showcase/QA catalog path. The deterministic demo fixture world existed, but it was only reachable through internal tests or daemon import scheduling, so an operator could not create a ready-to-query demo archive synchronously.\n\nWhat changed: add a polylogue.demo product module that materializes the existing fixture world, ingests it directly into an archive file set, optionally seeds deterministic overlays, verifies semantic archive facts, and renders a copy-pastable demo script. Register a root polylogue demo command with seed, verify, and script subcommands, and reuse the same source materialization from import --demo.\n\nVerification: devtools test tests/unit/storage/test_no_string_interpolated_sql.py tests/unit/demo/test_demo_seed_verify.py tests/unit/cli/test_demo_command.py tests/unit/cli/test_import.py -q passed (18 passed). devtools test tests/unit/cli/test_help_contract.py tests/unit/cli/test_plain_cli_snapshots.py -q passed (225 passed). devtools verify --quick passed.
|
Warning Review limit reached
More reviews will be available in 43 minutes and 31 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?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 credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. 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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds a new ChangesDemo Archive Package and CLI
Sequence Diagram(s)sequenceDiagram
participant User
participant demo_command as demo CLI group
participant seed_demo_archive
participant verify_demo_archive
participant render_demo_script
participant SQLite as Archive SQLite DBs
User->>demo_command: polylogue demo seed [--json] [--with-overlays]
demo_command->>seed_demo_archive: asyncio.run(seed_demo_archive(root, force, with_overlays))
seed_demo_archive-->>demo_command: DemoSeedResult
demo_command-->>User: JSON payload or formatted console lines
User->>demo_command: polylogue demo verify [--require-overlays]
demo_command->>verify_demo_archive: verify_demo_archive(root, require_overlays)
verify_demo_archive->>SQLite: query index.db / source.db / user.db
SQLite-->>verify_demo_archive: counts, paths, overlay rows
verify_demo_archive-->>demo_command: DemoVerifyResult
demo_command-->>User: status output (or ClickException on failure)
User->>demo_command: polylogue demo script [--shell bash]
demo_command->>render_demo_script: render_demo_script(root, shell)
render_demo_script-->>demo_command: bash script string
demo_command-->>User: printed script (no trailing newline)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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: 3782f5e879
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@polylogue/demo/seed.py`:
- Around line 21-28: The _pushd context manager uses os.chdir() to mutate global
process state, which creates a concurrency hazard when called from async
contexts like seed_demo_archive because interleaved async calls will interfere
with each other's working directories. Refactor demo_source_specs to accept a
source_root parameter and return absolute Source paths instead of relative ones,
then remove the _pushd call from seed_demo_archive and pass the required
source_root to demo_source_specs. Finally, delete the now-unused _pushd helper
function and remove the os import statement that is no longer needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a68f90d7-b324-41bb-954a-caac3542f949
📒 Files selected for processing (16)
docs/cli-reference.mddocs/plans/topology-target.yamldocs/test-quality-workflows.mddocs/topology-status.mdpolylogue/cli/click_command_registration.pypolylogue/cli/commands/demo.pypolylogue/cli/commands/import_command.pypolylogue/demo/__init__.pypolylogue/demo/models.pypolylogue/demo/script.pypolylogue/demo/seed.pypolylogue/demo/verify.pytests/unit/cli/__snapshots__/test_help_snapshots.ambrtests/unit/cli/__snapshots__/test_terminal_snapshots.ambrtests/unit/cli/test_demo_command.pytests/unit/demo/test_demo_seed_verify.py
| @contextmanager | ||
| def _pushd(path: Path) -> Iterator[None]: | ||
| previous = Path.cwd() | ||
| os.chdir(path) | ||
| try: | ||
| yield | ||
| finally: | ||
| os.chdir(previous) |
There was a problem hiding this comment.
Concurrency hazard: os.chdir in async context.
The _pushd context manager mutates global process state (os.chdir), which is unsafe when used inside an async function like seed_demo_archive (line 66). If multiple seed_demo_archive calls are interleaved on the same thread (typical in asyncio), their working directories can interfere, causing one call to execute parse_sources_archive from the wrong directory.
🔄 Recommended fix: pass absolute paths instead of relying on cwd
Refactor demo_source_specs to accept source_root and return absolute Source paths, then remove the _pushd call:
-def demo_source_specs(source_root: Path) -> list[Source]:
+def demo_source_specs(source_root: Path) -> list[Source]:
"""Return relative source specs for the materialized demo world."""
return [
- Source(name="chatgpt", path=Path("chatgpt")),
- Source(name="claude-code", path=Path("claude-code")),
- Source(name="codex", path=Path("codex")),
+ Source(name="chatgpt", path=source_root / "chatgpt"),
+ Source(name="claude-code", path=source_root / "claude-code"),
+ Source(name="codex", path=source_root / "codex"),
]Then remove the _pushd call in seed_demo_archive:
source_root = materialize_demo_source(archive_root, force=force)
- with _pushd(source_root):
- result = await parse_sources_archive(archive_root, demo_source_specs(source_root))
+ result = await parse_sources_archive(archive_root, demo_source_specs(source_root))And remove the now-unused _pushd helper and its os import.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@polylogue/demo/seed.py` around lines 21 - 28, The _pushd context manager uses
os.chdir() to mutate global process state, which creates a concurrency hazard
when called from async contexts like seed_demo_archive because interleaved async
calls will interfere with each other's working directories. Refactor
demo_source_specs to accept a source_root parameter and return absolute Source
paths instead of relative ones, then remove the _pushd call from
seed_demo_archive and pass the required source_root to demo_source_specs.
Finally, delete the now-unused _pushd helper function and remove the os import
statement that is no longer needed.
|
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. |
|
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
Adds a product demo namespace that can seed, verify, and describe a deterministic Polylogue archive without relying on showcase internals. The demo archive is created synchronously from the existing synthetic corpus fixture and can optionally include assertion-backed user overlays.
Problem
#2196 needs a demo/verifiability surface that operators and future visual/demo work can invoke directly. The existing demo corpus helpers were useful, but the archive-ready path was split between import internals and verification-lab/showcase assumptions, so there was no compact command that seeded a ready-to-query archive and proved the expected archive facts.
Solution
polylogue.demomodels, seed, verify, and script helpers.polylogue demo seed,polylogue demo verify, andpolylogue demo script.import --demoinstead of keeping separate fixture-writing logic in the import command.This does not implement a daemon-backed
import --demo --waitpath; the new seed command is intentionally the synchronous operator/demo path for this phase.Verification
nix develop --command devtools test tests/unit/demo/test_demo_seed_verify.py tests/unit/cli/test_demo_command.py tests/unit/cli/test_import.py -q-> 16 passednix develop --command devtools test tests/unit/cli/test_help_contract.py tests/unit/cli/test_plain_cli_snapshots.py -q-> 225 passed, 9 snapshots passednix develop --command devtools test tests/unit/storage/test_no_string_interpolated_sql.py tests/unit/demo/test_demo_seed_verify.py tests/unit/cli/test_demo_command.py tests/unit/cli/test_import.py -q-> 18 passednix develop --command devtools test tests/unit/cli/test_terminal_snapshots.py::TestHelpOutput::test_help_output_snapshot tests/unit/cli/test_terminal_snapshots.py::TestTerminalDimensions::test_help_at_narrow_width tests/unit/cli/test_terminal_snapshots.py::TestTerminalDimensions::test_help_at_wide_width tests/unit/cli/test_help_snapshots.py::test_root_help_snapshot -q-> 4 passed, 4 snapshots passednix develop --command devtools lab scenario verify-baselines-> 106 exercises, all baselines matchnix develop --command devtools verify --quick-> exit_code 0nix develop --command devtools verify --seed-testmon --skip-slow-> 11,628 passed, exit_code 0