refactor: quick-win cleanup — panic stubs, SaveToFile, dead code, error handling, syncWriter#287
Conversation
AI Code ReviewCritical IssuesNone found. Moderate IssuesNone found. Minor Issues
What Looks Good
RecommendationApprove - The PR consists of high-quality cleanup changes that fix actual bugs (panics, SQL injection, race conditions), improve error handling, remove dead code, and follow best practices without breaking changes. The catalog race solution is particularly well-implemented. All changes are independently safe and backward-compatible, preparing the codebase for the WASM extraction track as intended. Minor logging improvements are negligible and don't block approval. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
This PR is a “quick-win” refactor/cleanup focused on reducing panics, improving error handling, removing dead code, and making background catalog refresh safer by preventing stale background results from overwriting newer catalog state.
Changes:
- Propagate previously-discarded errors (notably MPR transaction ID updates, widget inserts, and several executor commands) and replace panic stubs with real serialization implementations.
- Remove unused hashing helpers/tests and minor formatting/dead-code cleanup.
- Add catalog background refresh synchronization primitives (
SyncCatalog,catalogMu,catalogGen,syncWriter) and attempt to prevent stale background catalog overwrites.
Reviewed changes
Copilot reviewed 17 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/mpr/writer_units.go | updateTransactionID() now returns errors; callers now fail fast when transaction ID update fails. |
| sdk/mpr/utils.go | Removes unused Hash helper. |
| sdk/microflows/microflows_actions.go | Minor formatting/alignment change only. |
| mdl/types/id_test.go | Removes tests for deleted Hash. |
| mdl/types/id.go | Removes dead Hash implementation. |
| mdl/executor/hierarchy.go | Removes trailing blank lines. |
| mdl/executor/executor_dispatch.go | Adds catalogMu/catalogGen sync + SyncCatalog callback to support background catalog delivery. |
| mdl/executor/executor.go | Adds catalog mutex/gen fields; makes Catalog() accessor lock-protected. |
| mdl/executor/exec_context.go | Adds SyncCatalog callback; unexports EnsureSqlMgr to ensureSqlMgr. |
| mdl/executor/cmd_sql.go | Updates SQL manager accessor to renamed ensureSqlMgr. |
| mdl/executor/cmd_pages_builder_v3.go | Stops discarding an entity lookup error; logs warning instead. |
| mdl/executor/cmd_page_wireframe.go | Stops discarding describePage error; logs warning instead. |
| mdl/executor/cmd_microflows_builder_calls.go | Stops discarding Java action lookup error; logs warning instead. |
| mdl/executor/cmd_microflows_builder.go | Formatting/alignment changes in struct fields. |
| mdl/executor/cmd_catalog.go | Adds syncWriter; attempts to propagate background-built catalog via SyncCatalog; stops discarding writeResult error. |
| mdl/catalog/catalog.go | Hardens SaveToFile VACUUM path quoting; removes unused destination DB open. |
| mdl/catalog/builder_pages.go | Stops discarding widget insert errors; returns contextualized error. |
| mdl/catalog/builder_microflows_test.go | Import ordering tweak. |
| mdl/catalog/builder.go | Minor formatting/alignment change. |
| mdl/backend/mpr/backend.go | Replaces panic serialization stubs with delegation to mpr.Serialize* helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…or handling, syncWriter
|
Re: Nemotron review — thanks for the thorough review. The minor suggestions about adding more context to warning logs are already addressed: each |
AI Code ReviewCritical Issues
Moderate Issues
Minor Issues
What Looks Good
RecommendationApprove. The PR provides valuable cleanup that reduces panic risks, fixes data races, improves error handling, and removes dead code—all independently safe and backward-compatible. While the PR bundles multiple unrelated changes (violating strict scoping principles), each change is low-risk, well-tested, and prepares the codebase for future WASM extraction work. The maintainer should consider splitting such cleanups in future PRs, but this specific set is acceptable for merging. Post-merge note: Encourage author to file separate issues for future cleanups to maintain atomic PRs. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
|
Re: second Nemotron review — Scope & atomicity (moderate): Acknowledged. This PR intentionally bundles related cleanup tasks from the WASM extraction prep track (all zero-feature-change, same design doc section). Future PRs in the series (2–7) are scoped to single concerns. builder.go indentation: This is builder_microflows_test.go import reorder: Standard No changes needed. |
Summary
SerializeWidget/SerializeDataSource/SerializeDataSourceToOpaquestubs inbackend/mpr/backend.goto existingmpr.Serialize*free functionsSaveToFile— escape single quotes in VACUUM INTO path, remove unuseddestDBopentypes.Hash+mpr.Hash(zero callers confirmed via grep)syncWriter(mutex-wrappedio.Writer) for background catalog goroutine output race incmd_catalog.gocatalogGenmonotonic counter to prevent stale background catalog from overwriting newer foreground catalogcmd_microflows_builder_calls.go,cmd_page_wireframe.go,cmd_pages_builder_v3.goEnsureSqlMgr→ensureSqlMgrWhy
These are zero-feature-change cleanups that reduce panic risk, fix data races, and improve error observability. Each fix is independently safe and backward-compatible. Preparing the codebase for the WASM extraction track.
Testing
make build && make test && make lint-gopass