Problem
_expand_macros_and_embeds_impl is a single while True loop handling block embeds, page embeds, cycle detection, and graph lookups. Each new embed type (macro, query, PDF) requires editing the core loop — Open/Closed Principle violation noted in docs/BUG_HUNT_REPORT.md §6.
Clean Architecture lens
| Aspect |
Assessment |
| Ring |
Interface Adapter (synapse.py) |
| SOLID |
OCP + SRP — one class/function per embed kind |
| Dependency rule |
Strategies depend on LogseqGraph port, not KINETIC/CLI |
Proposed Solution (incremental)
- Define a small
EmbedExpander protocol: match(text) -> span | None, expand(...) -> str
- Implement
BlockEmbedExpander, PageEmbedExpander with shared cycle context object
- Keep
_expand_macros_and_embeds as façade delegating to ordered strategies
- Fix cycle duplication (#65) inside page strategy
Mentor scope
~4–6 hours. Good follow-up after #65 tests land.
Definition of Done
- No behavior regression (
tests/test_synapse.py)
make all passes
Problem
_expand_macros_and_embeds_implis a singlewhile Trueloop handling block embeds, page embeds, cycle detection, and graph lookups. Each new embed type (macro, query, PDF) requires editing the core loop — Open/Closed Principle violation noted indocs/BUG_HUNT_REPORT.md§6.Clean Architecture lens
synapse.py)LogseqGraphport, not KINETIC/CLIProposed Solution (incremental)
EmbedExpanderprotocol:match(text) -> span | None,expand(...) -> strBlockEmbedExpander,PageEmbedExpanderwith shared cycle context object_expand_macros_and_embedsas façade delegating to ordered strategiesMentor scope
~4–6 hours. Good follow-up after #65 tests land.
Definition of Done
tests/test_synapse.py)make allpasses