2.0 KiB
TASK synced-block-target: Resolve stable block IDs and replace source content
Runs through OpenCode (specs/agents/opencode-runbook.md attached automatically). Task 1 of specs/plugins-parity/synced-blocks/tasks.md.
OWNS
crates/blocks/src/transclusion.rs (new, first write), crates/blocks/src/lib.rs (module, exports and error variants), unit tests in new module
FILES TO OPEN
spec.md D1, crates/blocks/src/ids.rs, crates/blocks/src/parse.rs, crates/markdown/src/scanning/scan.rs, crates/blocks/src/lib.rs, crates/ui-egui/src/views/note_view/blocks/embed_data.rs
GOAL / API
Write FIRST OWNS file in SECOND tool call (compiling stub plus one failing behavior test first).
resolve_by_id(source,id) -> Result<BlockTarget> with block/content/marker ranges; replace_by_id(source,id,expected_block,replacement) -> Result<Edited>. Parse real markdown IDs and blocks, preserve ID/structure/CRLF, reject ambiguity and changed target, enforce 1 MiB replacement cap.
Follow specs/plugins-parity/synced-blocks/spec.md limits, error semantics and acceptance criteria exactly. New modules need rustdoc and parent declaration/re-exports; no IO.
TESTS
Paragraph Unicode/CRLF; list/quote and standalone table ID; ID-like code not target; duplicate/missing ID; unrelated offset shift; stale expected block; marker injection; unsupported structural replacement; over-cap refusal; unrelated bytes unchanged.
VERIFY
export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-blocks
cargo clippy -p notescraft-blocks --all-targets -- -D warnings
# rustfmt --edition 2024 followed by the owned Rust paths only
Confirm new tests appear in test output. No cargo execution during specification authoring.
DO NOT
Do IO, register commands or implement own wikilink path resolver. No dependency additions, Git mutations, Cargo edits, UI work or files outside OWNS. Reject hostile input with errors; never clamp/truncate or panic. Root Cargo.toml / xtask/src/layers.rs registration is unnecessary because this task extends existing crate.