-
Notifications
You must be signed in to change notification settings - Fork 1
fix(ledger): route ledger_sync deserialization warnings to wipe-and-replay recovery (#301) #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0.15.0 | ||
| 0.15.1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,8 +121,26 @@ def _classify_recovery(diagnosis) -> tuple[RecoveryPath, str]: | |
| exp = diagnosis.schema_version_expected | ||
| has_events = _events_present(diagnosis.ledger_url) | ||
|
|
||
| if rec is not None and rec > exp: | ||
| # #301 — row-level deserialization warnings outrank the schema-version | ||
| # check. Schema can read clean (`schema_meta` is a tiny row, never the | ||
| # one that breaks) while the operational tables hit | ||
| # ``Invalid revision `N` for type Value``. The probe in | ||
| # cli/_diagnose_gather.py::_probe_row_deserialization catches that; here | ||
| # we route the verdict so the agent sees recovery_path=reset_rebuild | ||
| # instead of "clean, no remediation needed". | ||
| row_warnings: list[str] = list(getattr(diagnosis, "row_probe_warnings", []) or []) | ||
| if row_warnings: | ||
| path: RecoveryPath = "reset_rebuild" if has_events else "reset_destructive" | ||
| tables = ", ".join(sorted({w.split(":", 1)[0] for w in row_warnings})) | ||
| return path, ( | ||
| f"Row-level deserialization warnings on {tables} — likely a " | ||
| "SurrealDB embedded-SDK record-format mismatch. Run " | ||
| f"`bicameral_reset(wipe_mode='ledger', replay_from_events={has_events}, " | ||
| "confirm=True)` to wipe and replay from .bicameral/events/." | ||
| ) | ||
|
Comment on lines
+136
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make When ✏️ Proposed fix path: RecoveryPath = "reset_rebuild" if has_events else "reset_destructive"
tables = ", ".join(sorted({w.split(":", 1)[0] for w in row_warnings}))
+ replay_text = (
+ "to wipe and replay from .bicameral/events/."
+ if has_events
+ else "to wipe the ledger (no replayable .bicameral/events/*.jsonl found)."
+ )
return path, (
f"Row-level deserialization warnings on {tables} — likely a "
"SurrealDB embedded-SDK record-format mismatch. Run "
f"`bicameral_reset(wipe_mode='ledger', replay_from_events={has_events}, "
- "confirm=True)` to wipe and replay from .bicameral/events/."
+ f"confirm=True)` {replay_text}"
)🧰 Tools🪛 GitHub Actions: Lint & Type Check / 0_ruff + mypy.txt[error] mypy . failed with 1 error (no-redef). Checked 134 source files. 🤖 Prompt for AI Agents |
||
|
|
||
| if rec is not None and rec > exp: | ||
| path = "reset_rebuild" if has_events else "reset_destructive" | ||
| return path, ( | ||
| f"Ledger schema v{rec} is newer than this binary (v{exp}). " | ||
| f"Upgrade `bicameral-mcp` to a version that understands v{rec}, " | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: BicameralAI/bicameral-mcp
Length of output: 245
🏁 Script executed:
Repository: BicameralAI/bicameral-mcp
Length of output: 1932
🏁 Script executed:
Repository: BicameralAI/bicameral-mcp
Length of output: 628
Resolve
pathredefinition to unblock mypy.The typed assignment on line 133 conflicts with the typed assignment on line 143 (
no-redef), causing CI failure. Both are separate conditional branches that independently define the same variable name. The proposed fix correctly renames line 133's variable towarning_pathand updates the corresponding return statement, eliminating the redefinition while preserving the distinct logic for each recovery path.🛠️ Proposed fix
🧰 Tools
🪛 GitHub Actions: Lint & Type Check / 0_ruff + mypy.txt
[error] mypy . failed with 1 error (no-redef). Checked 134 source files.
🤖 Prompt for AI Agents