Repository navigation
Conversation
…ed in reconcile (I-000405) - compute_reconcile_diff no longer emits a ResyncFileStatus op when render_frontmatter_status cannot produce bytes, so `resynced` counts only files that are actually written. - ReconcileReport/ReconcileDiff carry a `skipped` list (chapter path + reason) and log a reconcile warn; the sum of created/updated/resynced/preserved/skipped still accounts for every chapter once. - Added a regression test: one unclosed-frontmatter chapter plus one unchanged chapter must yield no resync op, one skip entry, and consistent counters. - apps/nexus42 wire projection adapted to the new field (JSON shape unchanged via skip_serializing_if).
[Medium impact] The changes affect the bounded chapter-reconciliation workflow. The PR appears safe to merge, with a non-blocking clarification needed about what a skipped chapter means. Findings
Fix with agent prompt### Issue 1
crates/nexus-local-db/src/work_chapters.rs:623-624
`ReconcileDiff::skipped` says no write decision was produced, but an unclosed block with a conflicting status and a changed `word_count` produces both a skip and `UpdateWordCount`. `apply_reconcile_diff` still updates that row.
Document that only the file status rewrite is skipped, and add a mixed-case test. Otherwise callers may treat skipped chapters as untouched or assume the counts cover each chapter once.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe PR records failed chapter status rewrites in
Acknowledged by Reviews (1) · Last reviewed commit: "fix(nexus-local-db): report unrenderable..." · Reviewed by Greptile |
✅ Verdict:
|
| Findings | Count |
|---|---|
| 🔴 must-fix | 0 |
| 🟠 should-fix | 0 |
| 🟡 may-fix | 2 |
| 🔵 nit | 0 |
📋 Review
What this PR does: Reconcile currently no-ops in silence when a chapter's frontmatter status cannot be rendered: nothing is written, no op is emitted, but the chapter is still counted. This PR makes that an explicit, countable outcome — compute_reconcile_diff emits ResyncFileStatus only when render_frontmatter_status produced bytes, records the failure as ReconcileSkip { path, reason } on ReconcileDiff/ReconcileReport, derives the report from the diff so counters match what was written, re-exports the type, and adds DB tests for both the skip and the word-count-still-mirrors case. It also keeps the Creator CLI JSON shape unchanged by hardcoding skipped: Vec::new() in the wire projection. The skip is additionally printed to stderr from inside nexus-local-db, which is the subject of both open may-fix findings.
Findings
🟡 [DEBT-01] Reconcile skip diagnostic is written as raw stderr from the DB library, on a justification bounded only to the Creator CLI
-
Evidence:
[DEBT-01] Reconcile skip diagnostic is written as raw stderr from the DB library, on a justification bounded only to the Creator CLI
- Evidence:
crates/nexus-local-db/src/work_chapters.rs:966— the newly addedrecord_skipped_status_write_backcallseprintln!from the read-only compute phase; the call site iscrates/nexus-local-db/src/work_chapters.rs:925insidecompute_reconcile_diff. - Evidence:
crates/nexus-local-db/src/work_chapters.rs:883— the same function already emits its other per-chapter diagnostic throughtracing::warn!(invalid-volume fallback), so the diff introduces a second, differently-routed output channel inside one function. - Evidence:
crates/nexus-local-db/src/cas.rs:169,crates/nexus-local-db/src/file_lock.rs:262— crate-wide diagnostic convention istracing(the only othereprintln!incrates/are test/build-script sites). - Evidence:
crates/nexus-core/src/owner/work_artifact.rs:453—compute_reconcile_diffis also driven from the core/daemon path, not only from a terminal CLI. - Evidence:
apps/nexus42/src/cli.rs:83—is_data_output()ismatches!(… Commands::Ops { … }), i.e. the global subscriber writes to stdout for Creator commands (apps/nexus42/src/main.rs:18,:159), so the doc comment's premise atwork_chapters.rs:954-959holds only for the Creator CLI -- it says nothing about the core/daemon caller. - Impact: The helper's stated bound is "under
Creatorcommands the global subscriber's writer is stdout" and "creator works reconcile-chapters --json", yet the same library routine runs inside the core/daemon reconcile path where that bound does not apply: there the line lands as unstructured, unfilterable process stderr (no level, no target, no request/work correlation beyond the ad-hoc prefix), once per unrenderable chapter per reconcile request, and no host subscriber can route or silence it. The structured carrier for exactly this signal already exists (`Reconc…
- Evidence:
-
Location:
crates/nexus-local-db/src/work_chapters.rs:966-969 -
Category: tech-debt
-
Merge class: may-fix
🟡 Skipped-chapter report is stderr-only; every structured surface still drops skipped
-
Evidence:
BUG-01 Skipped-chapter report is stderr-only; every structured surface still drops
skipped- Evidence:
crates/nexus-local-db/src/work_chapters.rs:966-972— the newrecord_skipped_status_write_backprints the skip to stderr and pushes it intoReconcileDiff.skipped. ButReconcileSkip/ReconcileReport.skipped(work_chapters.rs:529-537,558-559with#[serde(skip_serializing_if = "Vec::is_empty")]) is the only structured carrier, and it is discarded at both projections:crates/nexus-core/src/works.rs:290-296definesWorkReconcileReportwith onlycreated/updated/resynced/preservedandworks.rs:498-503builds it from exactly those four counters, andapps/nexus42/src/commands/creator/works/mod.rs:1143-1152(reconcile_report_wire) hardcodesskipped: Vec::new()whileprint_reconcile_report(same file, human path) prints only the four counters. - Impact: For
creator works reconcile-chapters --jsonand--dry-run --json, a chapter whose status write-back was skipped (no opening---or an unclosed block) produces noskippedfield, exit 0 and a clean report; the only signal is the unstructured stderr line this helper adds, which is outside the JSON contract and unfilterable by--verbose/reversed by no flag. The daemon route surfaces the same four-field report throughCoreService::reconcile_work_chapters, so the skip list is lost there too. Net effect: the helper makes the skip visible to a human reading a terminal, while the patch's structured data channel — the one automation would use before mutating — remains blind. - Effort: S — add
skipped: Vec<ReconcileSkip>toWorkReconcileReport, populate it inreconcile_work_chapters, and project it (instead ofVec::new()) inreconcile_report_wire; render it inprint_reconcile_report. - Risk: LOW — additive field on an internal core type; the DB wire type already carries it and no TS consumer currently reads
skipped(apps/nexus-service/src/works.tshas no `…
- Evidence:
-
Location:
crates/nexus-local-db/src/work_chapters.rs:966-972 -
Category: BUG
-
Merge class: may-fix
Revalidated findings
Reassessed 4/4 prior finding(s) this round · 0 invalid-output · 0 omitted · 0 over cap · 4 recheckable · context coverage: truncated
| finding | disposition | evidence | thread |
|---|---|---|---|
| Reconcile skip loses its only operator signal: helper's tracing::warn! deleted while report.skipped is dropped at the API/CLI boundary | addressed (verified-fix) | current-code | - |
reconcile-chapters wire projection hard-codes skipped: Vec::new(), so --json can never report an unrenderable chapter |
unverifiable (conflict) | current-code | - |
Reconcile skip lost its only operator-visible signal: tracing::warn! deleted with push_reconcile_skip |
addressed (verified-fix) | current-code | - |
| Reconcile skip list is populated but no consumer surface ever receives it | unverifiable (conflict) | current-code | - |
Linked-issue AC
none — the PR declares Closes I-000405, but the review context's issues array is empty and no issue body or acceptance criteria were supplied, so no criterion can be marked met, unmet or cut without inventing it. The PR body's own stated intent ("skip is now a first-class, countable outcome") is covered by the ReconcileSkip shaping and the new skip test, but that is the PR's claim, not an issue AC.
✅ Verified
- Read record_skipped_status_write_back (crates/nexus-local-db/src/work_chapters.rs:966-980): it pushes ReconcileSkip { path, reason } into diff.skipped and emits an eprintln! line with UNRENDERABLE_FRONTMATTER_REASON.
- Read ReconcileSkip/ReconcileReport (work_chapters.rs:520-560): skipped is #[serde(skip_serializing_if = "Vec::is_empty")] and documented as per-chapter, not folded into preserved or resynced.
- Read test_reconcile_reports_unrenderable_frontmatter_as_skipped and test_reconcile_skips_status_write_back_but_mirrors_word_count (work_chapters.rs:2590-2683): both assert no ResyncFileStatus op, skipped[0].path, a reason containing "cannot be rendered", and the second asserts word_count still mirrors while DB status stays SSOT.
- Read the CLI projection (apps/nexus42/src/commands/creator/works/mod.rs:1143-1152): reconcile_report_wire hardcodes skipped: Vec::new(); print_reconcile_report destructures only the four legacy counters.
- grep in crates/nexus-local-db/src/work_chapters.rs confirms the two I-000405 test annotations near the skip tests.
- ❓ PR-reported cargo test -p nexus-local-db (691 passed), cargo clippy -p nexus-local-db --all-targets -- -D warnings, cargo fmt --check, cargo check -p nexus42, and both negative controls were not re-run — read-only seat, static review only.
- ❓ crates/nexus-core/src/owner/work_artifact.rs:453 and the daemon-side stderr handling were not opened; that half of DEBT-01 is static inference from the grep hit and the core/CLI evidence.
- ❓ crates/nexus-core/src/works.rs:290-296 / :498-503 (WorkReconcileReport four-field shape) is taken from the review document's read, not re-read here.
🗑️ Considered & rejected
- "The new reason constant breaks the existing skip tests" — rejected: both skip tests assert reason.contains("cannot be rendered"), a substring the new constant retains, and they were read directly.
- "nexus-local-db silently loses the skip entirely" — rejected: the diff pushes ReconcileSkip and apply_reconcile_diff copies it into ReconcileReport.skipped; the loss happens later, at the core/CLI projections, which is what BUG-01 records rather than a defect in this helper's data path.
- "eprintln! instead of tracing is a style violation" — rejected as inadmissible on style grounds alone; DEBT-01 is retained only because the documented justification (Creator CLI subscriber) is exceeded by the existing core/daemon caller.
- "The neighbouring pre-existing tracing::warn! for invalid frontmatter volume (work_chapters.rs ~895) hits the same stdout-writer hazard" — rejected as a finding here: it predates this diff and is called out only as a non-finding note.
- "The skip count should be folded into preserved so the four legacy counters always sum to the chapter total" — rejected: the PR documents the partition explicitly and the new test asserts created+updated+resynced+preserved+skipped == 2, so the semantics are intentional and tested.
🛠️ Plan to fix
Expand fix plan
Both open findings are the same repair: make the skip signal travel through owned report/output surfaces instead of being printed inside the DB library. Suggested order:
1. **Make `nexus-local-db` return-only.** In `crates/nexus-local-db/src/work_chapters.rs:954-970`, delete the `eprintln!` from `record_skipped_status_write_back` and rewrite its doc comment; keep `diff.skipped.push(...)` as the sole emission, and drop the now-false "stdout would be corrupted" justification. (DEBT-01)
2. **Carry `skipped` on the core report.** In `crates/nexus-core/src/works.rs:290-296`, add `skipped: Vec<ReconcileSkip>` to `WorkReconcileReport` (wire-stable: `skip_serializing_if = "Vec::is_empty"` if the service surface is serialized), and populate it from `report.skipped` in the constructor at `:498-503`; update other literals/destructures. (BUG-01)
3. **Project it at the CLI.** In `apps/nexus42/src/commands/creator/works/mod.rs`, replace `skipped: Vec::new()` in `reconcile_report_wire` (`:1143-1152`) with the report's list; that fn is `const`, and `Vec::clone` is not const-callable, so either drop `const`/take the report by value or restructure the projection. Render one line per skip (`path` + `reason`, labelled dry-run vs applied) in `print_reconcile_report`, leaving the four-counter line intact.
4. **Log on the daemon side only where a subscriber is owned.** For the core/daemon reconcile path (`crates/nexus-core/src/owner/work_artifact.rs:453` and `CoreService::reconcile_work_chapters`), emit the skip through the daemon's own `tracing` subscriber or let the caller render it after receiving the report — never from `nexus-local-db`.
5. **Tests.** Keep the two DB skip tests; add a core test asserting `WorkReconcileReport.skipped` survives `apply_reconcile_diff` → core report, and a CLI/output test (human and `--json`, `--dry-run --json`) asserting `skipped` appears only when non-empty and includes path + reason. Update any snapshot of the JSON shape.
6. **Verification gates.** `cargo test -p nexus-local-db -p nexus-core -p nexus42`; `cargo clippy -p nexus-local-db -p nexus-core -p nexus42 --all-targets -- -D warnings`; `cargo fmt -p nexus-local-db -p nexus-core -p nexus42 -- --check`; then exercise both `creator works reconcile-chapters --json` / `--dry-run --json` on a chapter with an unclosed frontmatter block and confirm the skip is in the JSON and no raw stderr line is emitted by the DB layer. Keep the scenario from the PR's negative controls (no `ResyncFileStatus`, counters partition the chapters, broken bytes unchanged).…write-back (I-000405) - Removed the reconcile `tracing::warn!` added in the previous commit: it reached stdout for `creator works reconcile-chapters` (the subscriber only routes Ops commands to stderr), corrupting `--json`; the skip is diagnosed through `diff.skipped` / `report.skipped`. - ReconcileSkip now documents exactly what was skipped: the frontmatter status write-back. Word-count mirroring for the same chapter is still emitted and applied; report/diff field docs and the reason wording say so. - Added a mixed regression test: status conflict + word_count change -> one skip entry, no ResyncFileStatus, an UpdateWordCount op, and after apply the DB word_count is mirrored while the file frontmatter status is untouched.
…r (I-000405) - The skip branch now writes one line to stderr explicitly (`record_skipped_status_write_back`); `diff.skipped` / `report.skipped` stay the structured channel. No `tracing` call, so nothing reaches the stdout writer `Creator` commands use for `--json`. - Comment at the write records why it must not be `tracing` (global subscriber writer is stdout under `Creator`); `is_data_output()` and logging init untouched. - The reason string is now cause-only, so the stderr line and the structured reason do not repeat "write-back skipped". - Existing reconcile skip tests keep asserting the structured entry (path + reason, report == diff); the stderr routing was verified out of band (`--nocapture` split: stdout 0 hits, stderr 1 hit).
Intent
Reconcile silently skipped a chapter when its frontmatter status could not be rendered: no write, no op, but the chapter still counted. The skip is now a first-class, countable outcome.
Surface
3 files, +131 −7:
crates/nexus-local-db/src/work_chapters.rs:compute_reconcile_diffemitsResyncFileStatusonly whenrender_frontmatter_statusproduced bytes; an unrenderable chapter becomesReconcileSkip { path, reason }onReconcileDiff/ReconcileReportplus atracing::warn!(target: "reconcile").apply_reconcile_diffderives the report from the diff, so counts match what was written.push_reconcile_skipkeeps the function under clippy's 100-line bound.crates/nexus-local-db/src/lib.rs: re-exportsReconcileSkip.apps/nexus42/src/commands/creator/works/mod.rs: struct-literal adaptation only (skipped: Vec::new()), with#[serde(skip_serializing_if = "Vec::is_empty")]so the JSON shape is unchanged and the fn staysconst.Verification
cargo test -p nexus-local-db-> 691 passed, 0 failed (incl. 386 lib and doc-tests).test_reconcile_reports_unrenderable_frontmatter_as_skippedasserts both halves: report has 1 skip with the path and a "cannot be rendered" reason;created+updated+resynced+preserved+skipped == 2;resynced == 0,preserved == 1;diff.opscontains noResyncFileStatus; the broken file's bytes are unchanged.cargo clippy -p nexus-local-db --all-targets -- -D warningsclean;cargo fmt -p nexus-local-db -p nexus42 -- --checkclean;cargo check -p nexus42ok.no resync op may stand for an unrenderable chapter: [ResyncFileStatus { rel_child: "Stories/ch01-broken.md", … }].one chapter cannot be rendered — left: 0 right: 1(the count side). Restored, 691 green.Residuals:
let Some(rendered) = … else { continue; }incrates/nexus-core/src/owner/work_artifact.rs:298can still skip-silently if a file becomes unrenderable between diff and write; that is nexus-core, outside this boundary — worth the same treatment.nexus-contracts::WorkReconcileReporthas no skip field (no schema change here), so CLI--json/daemon responses do not expose the detail; it is visible in the local-db report (--dry-runincluded) and the warn log.skippedis not folded intopreserved, so the four legacy counts can sum to less than the chapter total when a skip occurs (documented on the field).Closes I-000405.