PRD + inventor design: submission generator v2 — sectioned composition, swappable base templates, in-app editing, building blocks #141
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
Why
m (2026-05-26 18:26): "We still dont have user choice for our submission generator? Bro... we should do our own prd for the submission generator with an inventor. I want to have different sections, selectable 'base templates', editability of content, building blocks etc."
Current state is too thin:
submission_vars.go.What m wants — a v2 spec authored by an inventor before any code work starts:
Headline requirements (m's words mapped to design surface)
paliad.submission_drafts) and feed back into the rendered .docx.Open design surface for the inventor to resolve
submission_drafts.sections[](jsonb)? A separatesubmission_sectionstable? How do building blocks relate to sections (FK / copy-on-insert / live-reference)?mWorkRepoper-base directories? asubmission_basestable?)? How is the base swapped after content is authored — do edits survive a base change?{{party.*}}/{{court.*}}/{{lawyers.*}}(latter from #139) — do they stay placeholder-based or get bound at compose time per section?submission_drafts(7 live rows on prod) — how do they transition? Per-code default sections to seed v2 drafts?submission_drafts.updated_at.Inventor deliverables
docs/design-submission-generator-v2-2026-05-26.mdwith the full PRD: scope, data model, slice plan (A → ... → Z), risk assessment, migration path.Hard rules
mai instruct headfor real ambiguity. Open design questions go into the doc as 'recommended default + alternatives' for m to pick.{{rule.X}}placeholder alias contract (never break Word templates already in mWorkRepo).Acceptance for this issue
Slice A shipped on
mai/cronus/coder-composer-slice-a@e2969fcSubmission generator v2 (Composer) Slice A per the design at
docs/design-submission-generator-v2-2026-05-26.md§12.What landed:
submission_basescatalog +submission_drafts.base_id+composer_metacolumns +submission_sectionsper-draft rows. Seed rows forhlc-letterheadandneutralbases with 10-section defaults each.GET /api/submission-basescatalog endpoint; PATCH endpoints acceptbase_id.submissionDraftViewgainsbase_id,composer_meta,sections.TestFamilyOfCode,TestBaseSectionSpec_*) + live integration (TestComposerSeedFlow, TEST_DATABASE_URL-gated) covering the seed flow end-to-end.Hard constraints honoured:
base_id IS NULL OR no sections rows).{{rule.X}}aliases preserved (unchanged from v1).Build hygiene: go build/vet/test -short clean; bun run build clean (2900 i18n keys, data-i18n scan clean).
Migration slot coordination: Live DB at v106; main has migs through 145. Claimed 146/147/148. Dry-run dependent-failure for 146-148 matches the existing 130/131 pattern (those also depend on 119's
submission_draftswhich the live DB hasn't applied yet). Cumulative apply at Dokploy boot resolves it.Status: SLICE A COMPLETE — ready for merge. Inventor parked, head dispatches Slice B.
Slice B shipped on
mai/cronus/coder-composer-slice-b@f963b0dThe "Composer actually works" milestone — editable prose sections + anchor-spliced render + MD→OOXML walker for paragraphs.
Backend (~1200 LoC + tests):
submission_md.go— Markdown → OOXML walker (paragraphs + B/I + nested formatting + CRLF + XML escape). 12 unit tests.submission_compose.go— anchor-spliced render pipeline. ConvertDotmToDocx pre-pass → extract document.xml → render each section's content_md → splice via{{#section:KEY}}/{{/section:KEY}}anchors → strip excluded → append unanchored before sectPr → repack → v1 placeholder pass. 6 unit tests covering anchor mode, append mode, excluded drop, placeholder resolution, lang column pick, order_index ASC.submission_section_service.go—SectionPatch+Updatemethod, 6 optional fields (content_md_de/en,included,label_de/en,order_index).submission_sections.go—PATCH /api/submission-drafts/{draft_id}/sections/{section_id}. Owner-scoped via SubmissionDraftService.Get; section-belongs-to-draft cross-check.submission_drafts.go—exportSubmissionDraftbranches on draft.BaseID. Composer pipeline when set + base + bytes + sections all resolve; else v1 fallback. Audit metadata gainscomposer: true+base_id.files.go—fetchComposerBaseBytes+composerBaseSlugMapreuse the existing Gitea proxy cache.Frontend (~400 LoC + ~80 LoC CSS):
domToMarkdownwalks the contentEditable's DOM tree back to Markdown source-of-truth.state.view.sectionsin-place; full repaint only on structural changes.Templates regenerated on Gitea (mAi-uploaded):
_skeleton.docx— anchor-only body. New blob:ac0cdeaf…_firm-skeleton.docx— anchor-only body, sectPr preserved (firm header/footer rIds intact). New blob:f1e9a9fb…gen-skeleton-submission-templategains-anchorsflag (default true) for future regens.Build hygiene: go build/vet/test -short ./internal/... ./cmd/... all clean; bun run build clean (2900 i18n keys).
Hard rules honoured:
{{rule.X}}aliases preserved (v1 renderer pass unchanged inside composer).Status: SLICE B COMPLETE — ready for merge. Head dispatches Slice C (building blocks).
Slice C shipped on
mai/cronus/coder-composer-slice-c@ee98db9Building blocks library + section picker per design §8 / §4.4 and Q2/Q9 ratifications.
Schema (mig 149):
submission_building_blocks— library catalog (slug, firm, section_key, proceeding_family, title/desc/content_md per lang, author, visibility, is_published, soft-delete). RLS coarse-grained SELECT; tier predicate applied in Go.submission_building_block_admin_versions— append-only history (retention=20); admin-side only, NOT referenced from sections per Q2.Backend:
BuildingBlockService(~510 LoC) —ListVisible(tier predicate),ListAllForAdmin,Create/Update/SoftDelete/RestoreVersion(all transactional w/ retention-20 GC),InsertIntoSection(Q2's plain-text paste — no lineage stamped).GET /api/submission-building-blocks,POST .../insert-into/{section_id}) + admin editor under/api/admin/submission-building-blocks/*and/admin/submission-building-blockspage.Frontend:
/admin/submission-building-blocksadmin shell + ~370 LoC client (3-pane: list / form / version log).+ Bausteinbutton on the Composer editor toolbar opens a modal with 200ms-debounced search; click a hit → POST insert-into → section content updated in place.Tests: 3 pure-unit tests covering visibility constants + paste-content append behaviour.
Build hygiene: go build/vet/test -short clean; bun run build clean (2906 i18n keys).
Hard rules honoured:
{{rule.X}}aliases preserved (block content flows through v1 placeholder pass on export).Status: SLICE C COMPLETE — ready for merge. Head dispatches Slice D (rich-prose extensions to MD→OOXML walker).
Slice D shipped on
mai/cronus/coder-composer-slice-d@6778497Rich-prose features: headings 1-3, bullet + numbered lists, blockquote, inline hyperlinks. No new migrations.
MD walker (+320 LoC):
RenderMarkdownToOOXMLWithStylesentry point;RenderMarkdownToOOXMLis back-compat wrapper.splitMarkdownBlocksclassifies lines (heading/list/quote/paragraph); 3-space indent tolerance; "N. " and "N) " numbered markers.[label](url)routes through optionalHyperlinkAllocator; emits<w:hyperlink r:id="…">with "Hyperlink" char style on label runs.Composer (+130 LoC):
composerLinkAllocatordedupes URLs to rIds outside the base's namespace (rIdComposer1..N).patchDocumentXMLRelsappends matching<Relationship Type="…/hyperlink" Target="URL" TargetMode="External"/>rows toword/_rels/document.xml.rels. Idempotent on existing rIds. Returns the patched parts slice (caller overwrites — append may grow the backing array).Frontend:
domToMarkdownserializes<h1-3>,<ul>/<ol>with ordinal counter for numbered,<blockquote>line-prefix,<a href>→[label](url).Tests:
Build hygiene: go build/vet/test + bun run build all clean.
Trade-offs documented:
<w:numPr>markup. Honours stylemap entry without needing numbering.xml mutations; lawyer can apply real Word list style post-export.textContent = mdso toolbar-applied formatting reverts to literal MD after autosave. Acceptable Slice D trade; MD→DOM paint is a future polish.Hard rules honoured:
{{rule.X}}aliases preserved (walker passes placeholders verbatim).Status: SLICE D COMPLETE — ready for merge. Head dispatches Slice E (specialist bases) next.
Slice E shipped on
mai/cronus/coder-composer-slice-e@94310baSpecialist base templates + base-swap content survival + generic generator.
Mig 150 seeds two new firm-agnostic
submission_basesrows:lg-duesseldorf(proceeding_familyde.inf.lg) — Times New Roman 11pt, plain headingsupc-formal(proceeding_familyupc.inf.cfi) — Calibri 11pt, UPC-blue (#1F3864) headings, Cambria italic blockquoteBoth share the same 10-section spec.defaults shape; stylemaps target LG-Body / UPC-Body and family-prefixed Heading1-3 / ListBullet / ListNumber / Quote styles.
scripts/gen-submission-base/main.go(NEW, ~240 LoC) — generic generator with-presetflag (lg-duesseldorf | upc-formal). Each preset hard-codes typography; output is byte-reproducible. Emits minimal Composer-mode .docx (Content_Types + rels + styles.xml + anchor-only document.xml + empty rels envelope for Slice D hyperlink rels patch to splice into).Gitea uploads (via mAi):
6 - material/Templates/Word/Paliad/Composer/lg-duesseldorf.docx→ 82f57b3c6 - material/Templates/Word/Paliad/Composer/upc-formal.docx→ 41b9a388Backend wiring: two new
fileRegistryslugs +composerBaseSlugMaprows sofetchComposerBaseBytesroutes the new catalog rows to the new Gitea objects.Test:
TestComposer_BaseSwapPreservesContentpins Q10's contract — same draft composed against HLC vs LG stylemap → content survives both ways, stylemap diff visible in OOXML, no cross-leakage.Build hygiene: go build/vet/test + bun run build all clean.
Hard rules honoured:
Status: SLICE E COMPLETE — ready for merge. Head dispatches Slice F (reorder / hide / add-custom-section) next + final.
Slice F — FINAL — shipped on
mai/cronus/coder-composer-slice-f@bd7896eReorder / delete / add custom section. Closes Composer A→F.
Backend:
SectionService.Create(slug + labels + kind validation; auto-assigns order_index when 0; UNIQUE collision → ErrInvalidInput)SectionService.DeleteSectionService.Reorder(transactional; rewrites order_index to (1..N)×10)Frontend:
⋮⋮per-section handle (scoped so contentEditable selections inside the editor still work). Drop-target highlight + cleanup on dragend/drop/cancel.Tests: TEST_DATABASE_URL-gated live integration test exercising Create (with collision check) + Delete (with second-delete-returns-not-found) + Reorder (reverses 10 seeded sections + checks ascending order_index).
Build hygiene: go build/vet/test + bun run build all clean.
Hard rules honoured:
{{rule.X}}aliases preserved.Composer A→F complete
The full feature set ratified by m on 2026-05-26 is in place:
lg-duesseldorf+upc-formal(mig 150)All 5 migrations cumulative-apply at Dokploy boot. All four
.docxfiles (_skeleton.docx,_firm-skeleton.docx,lg-duesseldorf.docx,upc-formal.docx) are in Gitea Composer-mode (anchor-only bodies). 4 ratification-deviations from the original design held throughout: Q2 plain-text BB paste (no lineage), Q6 auto-upgrade rule (NOT in this slice train — explicitly deferred by head), Q10 fully-editable seeded sections, Q12 dissolved by Q2.Status: SLICE F COMPLETE — Composer A→F ready for merge.
Sweep verdict (2026-07-29): ALREADY DONE.
Every named component shipped: sectioned composition and building blocks (
paliad.submission_building_blocks,internal/services/submission_building_block_service.go, the/adminblock editor), swappable base templates (internal/services/submission_base_service.go,paliad.submission_bases), and in-app editing (frontend/src/lib/docforge-editor/).Full sweep:
docs/findings-issue-sweep-2026-07-29.md(commit4c39886).