refactor(core,wasm): migrate parsers + base32 dedup + WASM exports (Plan B Phases 7, 8) #5
Reference in New Issue
Block a user
Delete Branch "feature/cli-tail-stream-c-core-wasm-seam"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
parse_month_year,base32_decode_lenient,guess_mimemigrated from CLI torelicario-core(MonthYear::parse, newbase32module withencode_rfc4648/decode_rfc4648_lenient, newmime::guess_for_extension). Base32 dedup foldscrates/relicario-core/src/item.rs:255-275(base32_encode) andimport_lastpass.rs:202-220(decode_base32_totp) into the new shared module. Steam alphabet atitem_types/totp.rs:13left alone with a [crate::base32] neighbour comment.#[wasm_bindgen]exports for the three migrated parsers;extension/src/wasm.d.tsmirror updated in the same commit; snake_case JS naming consistent with existing exports.parse.rsis a thin re-export shim — existing callsites incommands/{add,edit,attach}.rsneed no import changes;RelicarioErrorauto-converts toanyhow::Errorat `?` boundaries.Spec / coordination
docs/superpowers/specs/2026-05-04-cli-restructure-design.mdPhases 7 and 8.docs/superpowers/coordination/2026-05-09-cli-tail-coordinator.mdfor cycle-2 partition.Spec-vs-reality decision
Plan B Phase 7 said `pub(crate) mod base32` — but the CLI shim and the new Phase 8 WASM exports both need to reach `decode_rfc4648_lenient` from outside `relicario-core`. Promoted to `pub mod base32`. PM ack'd in directive 2026-05-09T15:13Z.
Test plan
Out of scope (deferred)
🤖 Generated with Claude Code
Phase 1 added impl Drop for SessionHandle on the Rust side so .free() now actually removes the SESSIONS registry entry. The JS-side try { current.free() } catch { /* already freed */ } swallow was hiding the fact that .free() wasn't doing the cleanup at all; post-Phase-1 it has to go so failures surface instead of being lost. .free() callsite audit: exactly one match under extension/src/ — the SW session.ts line this commit edits. Lifecycle audit: clearCurrent() is reached via (a) popup lock → router popup-only.ts and (b) session-timer expiry → service-worker/index.ts. Refs: docs/superpowers/specs/2026-05-04-security-polish-design.md (Phase 2) Refs: docs/superpowers/reviews/2026-05-04-architecture-review.md (P1.1, DEV-C P2 service-worker) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>Plan B Phase 7 sub-step 2 — moves the bodies of parse_month_year, base32_decode_lenient, guess_mime from crates/relicario-cli/src/parse.rs to relicario-core. The CLI's parse.rs becomes a 19-line shim re-exporting the new core API. New core surface: - time::MonthYear::parse (Result<_, RelicarioError>) - mime::guess_for_extension (new mime module) - item_types::TotpConfig::parse_secret — Zeroizing<Vec<u8>> wrapper over base32::decode_rfc4648_lenient base32 module promoted from pub(crate) to pub so non-core consumers (CLI shim, future Phase 8 WASM exports) can reach it. New RelicarioError::InvalidMonthYear(String) for the parse error path (mirrors sub-step 1's InvalidBase32). MonthYear::new keeps its &'static str error type — bringing it to RelicarioError is DEV-A's P3. CLI callsites unchanged (commands/{add,edit,attach}.rs); RelicarioError auto-converts to anyhow::Error at ? boundaries. cargo test --workspace: green (core 143, +7 from new tests) cargo clippy --workspace: silent Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>Plan B Phase 8 — three #[wasm_bindgen] exports for the parsers migrated in Phase 7, mirrored in extension/src/wasm.d.ts under "Pure parsers (no session needed)". snake_case JS naming consistent with every existing export; SessionHandle not required. - parse_month_year(s) → { month, year } via js_value_for - base32_decode_lenient(s) → Uint8Array - guess_mime(filename) → string Tests in session_tests mod cover the OK paths; error-path / JsValue serialization can't be tested natively (JsError construction panics off-wasm) and is covered in core (time::tests + base32::tests). Plan C will wire SW message handlers consuming these exports in a future round; this commit delivers only the seam. Includes simplify-feedback fixes: - relicario-core lib.rs module-list mentions base32 and mime - item_types/totp.rs neighbour comment unified to ///-style block cargo test --workspace: green cargo clippy --workspace: silent cargo build -p relicario-wasm --target wasm32-unknown-unknown: clean cd extension && npm run test: 17 pre-existing failures only (baseline) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.