Skip to content

Deepen architecture: data seam, project corpus, score evaluator, run-lifecycle#1

Merged
michael-borck merged 5 commits into
mainfrom
refactor/architecture-deepening
May 23, 2026
Merged

Deepen architecture: data seam, project corpus, score evaluator, run-lifecycle#1
michael-borck merged 5 commits into
mainfrom
refactor/architecture-deepening

Conversation

@michael-borck

Copy link
Copy Markdown
Owner

Implements the four deepening opportunities from the architecture review, in dependency order. Goal: testability and AI-navigability — turn shallow/duplicated modules into deep ones.

What changed

#2 — Data seam (keystone)

  • Extract electron/schema.ts (pure DDL + version); database.ts keeps the Electron lifecycle.
  • Swappable DbDriver behind db.ts — IPC in prod, an in-memory node:sqlite adapter running the real Query Registry in tests. The 20 analysis services are unchanged but now reachable from node tests.

#4 — Project Corpus

  • loadProjectCorpus() unifies the load-and-count prelude; coverage, track, compare, coverage-2d, gap refactored onto it so their numbers reconcile by construction.

#1 — Score evaluator

  • Pure _shared/wedding-cake.ts core + a Rule Evaluator Registry + evaluateScore returning a generic Evaluation Trace. Collapses the triplicated Wedding-Cake math from Track, Compare and the Score page; Score renders the trace as the "Why this score" panel.

#3 — Run-lifecycle

  • useAnalysis hook (cancel-safe via run-id, auto-deps, progress), PolaritySelector (standardised on both), MLCaveatBanner (per-session dismiss).
  • Adopted across all 9 workflow pages. Fixes a real latent bug: Read's concordance auto-run had no cancel guard. Pages with rich progress (Audit, Discover) keep their own progress state while the hook owns running/error/result.

Verification

  • 44 tests pass (was 12, all pure helpers) — first real domain tests: scoring math, corpus counting, cross-workflow reconciliation (Coverage = ΣTrack = ΣCompare), the cancel-safe hook, and the DB seam.
  • typecheck, lint, and build:vite clean locally. SQL stays in the electron bundle only (threat model preserved).
  • Adds CONTEXT.md (domain + architecture vocabulary) and the implementation plan.

Note: I have not run the packaged app / full electron-builder — relying on CI here.

🤖 Generated with Claude Code

Michael Borck and others added 5 commits May 23, 2026 11:02
…un-lifecycle

Implements the four deepening opportunities from the architecture review.

#2 Data seam (keystone): extract electron/schema.ts (pure DDL); add a
   swappable DbDriver behind db.ts — IPC in prod, an in-memory node:sqlite
   adapter running the real Query Registry in tests — so the 20 analysis
   services become a reachable test surface. Services unchanged.

#4 Project Corpus: loadProjectCorpus unifies the load-and-count prelude;
   coverage, track, compare, coverage-2d and gap refactored onto it so their
   numbers reconcile by construction (proven by reconciliation.test).

#1 Score evaluator: pure wedding-cake core + a Rule Evaluator Registry +
   evaluateScore returning a generic Evaluation Trace. Collapses the
   triplicated Wedding-Cake math + mode decision from Track, Compare and the
   Score page; Score renders the trace as the "Why this score" panel.

#3 Run-lifecycle: useAnalysis hook (cancel-safe via run-id, auto-deps,
   progress), PolaritySelector (standardised on `both`), MLCaveatBanner
   (per-session dismiss). Adopted in Coverage and Gap; jsdom test infra added.

44 tests pass (was 12, all pure helpers); typecheck, lint and build clean.
SQL stays in the electron bundle only. Adds CONTEXT.md and the plan doc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ages

Migrates the remaining seven pages onto the Phase #3 modules so the
run/error/empty/caveat scaffolding lives once:

- useAnalysis: Read (concordance auto-run — fixes a real missing cancel
  guard), Track, Compare, Score, Audit, Map, Discover (both sub-tabs).
  Pages with rich progress objects (Audit, Discover synonyms) keep their
  own progress state while the hook owns running/error/result; success/
  failure toasts preserved.
- PolaritySelector: Read and Audit (migrating their `all` → `both`), Map
  (mode-dependent options).
- MLCaveatBanner: Audit anomalies, Discover synonyms, and a new IA-specified
  semantic-similarity caveat on Map's two-axis matrix.

44 tests pass; typecheck, lint and build clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
electron-builder skips code signing on pull-request builds, leaving the
.app unsigned. The afterSign notarize hook then failed in @electron/
notarize's checkSignatures step ("Failed to display codesign info … code 1"),
breaking PR CI — surfaced by the repo's first-ever PR (releases ship via
signed tag builds, which are unaffected).

Guard the hook with a `codesign -dv` precheck: if the app isn't signed,
skip notarization instead of failing. PR builds still validate the full
compile + packaging across all three platforms.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…only)

The macOS PR build attempted code signing (CSC_* secrets are available on
same-repo PRs) and failed: electron-builder's pull-request signing path is
inconsistent across the x64/arm64 pair, and notarization shouldn't run on
every PR anyway.

On pull_request events, blank the CSC_*/NOTARIZE_* env and set
CSC_IDENTITY_AUTO_DISCOVERY=false so electron-builder builds an unsigned
app; scripts/notarize.js then skips via its codesign precheck. Tag (v*)
release builds are unchanged — they still sign, notarize and publish.

PR CI now validates compile + packaging across macOS, Linux and Windows
without touching signing secrets.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
macOS has hardenedRuntime enabled, so electron-builder forces an arm64
codesign even when signing is "skipped" — which fails on PR builds that
have no usable signing identity. Rather than chase electron-builder's
PR-signing internals, build macOS only on v* tag releases (where signing,
notarization and publishing already work).

PRs now validate Linux + Windows via a dynamic matrix. The JS build steps
(typecheck, vite build) are identical across platforms, so PR signal is
effectively unchanged; macOS packaging/signing is exercised at release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@michael-borck michael-borck merged commit 3d86b43 into main May 23, 2026
4 checks passed
@michael-borck michael-borck deleted the refactor/architecture-deepening branch May 23, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant