Repository navigation
Round-trip: import an externally edited ADT bundle back into ADT Studio #724
elasticsounds
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Import an externally edited ADT back into ADT Studio
Motivation
A workflow we keep seeing: users export the ADT web package, drop it into a coding agent (Codex, Claude Code, etc.) to make edits — text fixes, layout tweaks, translation corrections — and then want to bring those edits back into ADT Studio. Today there is no path back: the ADT bundle is a one-way export artifact, so external edits are orphaned and get wiped the next time the book is repackaged.
This issue proposes the design for a round-trip: export → edit externally (with a validation loop) → import back into the existing project as new entity versions.
Options considered
Option A — ship the whole project (sqlite + ADT) to the agent ❌
Package the project zip (
.db+.pdf+ media) together with the web bundle; the agent edits the web package and keeps the sqlite/JSONs in sync; we re-import everything.Rejected because it asks an external LLM to uphold invariants only Studio's code knows:
node_dataversioning is append-only (MAX(version)+1inputNodeData); an agent editing sqlite via CLI will overwrite rows and silently destroy the rollback guarantee (core principle: entity-level versioning).saveStoryboardNodeclearing stale downstream entities) would have to be reimplemented as prompt instructions.SCHEMA_VERSIONbump breaks instructions living in other people's agent sessions.The same applies, worse, to pointing an agent directly at a live
books/<label>/folder: the renderedadt/dir is a build output whose edits are silently reverted on the next repackage (.build-hashis computed from entities, not fromadt/contents), WAL-mode sqlite plus an external writer risks corruption while Studio is open, and there is no transaction/review boundary around an editing session.Option B — new-project-from-ADT ❌ (as the primary path)
Edit only the ADT bundle, then have Studio build a fresh project (new sqlite) from the bundle.
The editing model is right, but the import target is wrong: the bundle only contains outputs (rendered HTML, text catalog, glossary, TOC, audio). It has no source PDF, no
page-sectioningtree, nopositioned-text, no image bounds, no LLM cache. A project reconstructed from it can view and export but can't re-run anything — no re-render, no quiz regen, no re-translate. Some content is genuinely one-way (quiz pages are rendered from structuredquiz-generationdata; LaTeX→MathML doesn't invert). Keep this as a possible future recovery mode for "the original project is lost," not the main flow.Option C — storyboard-only editable export ❌
Export just sectioning + storyboard as an editable HTML package and regenerate everything downstream on import.
The underlying instinct is correct (see "tiered import" below), but a separate format is the wrong vehicle:
✅ Recommended design: one surface, merge-back import, tiered semantics
Keep the whole ADT bundle as the editing surface. Import is a merge back into the existing project (same shape as the part split/merge workflow): Studio diffs the edited bundle against the exported baseline and writes only what changed, as new entity versions in the existing
<label>.db. The project directory remains the single source of truth and never travels to the LLM.The bundle is nearly a reversible projection already: every
data-idin the HTML is a content-node entity id;texts.jsonmaps totext-catalog/text-catalog-translation;glossary.json/toc.jsonmap to their entities; and each page's section body is theweb-renderingentity'shtmlstored verbatim (modulo image-URL rewrite and the page shell) — so importing edited page HTML is the same operation the storyboard editor already performs viaPUT /pages/:pageId/rendering, just with a new entry point.1. Export additions
adt/manifest.json(machine-readable): book label, format version,.build-hashbaseline, per-node entity versions, file → sectionId map, and a classification of every file into the three tiers below. (.build-hashexists but is opaque; the manifest makes re-import baseline-aware.)validate-adt.mjsshipped in the bundle (dep-free Node script, same pattern as the runtime assets):texts.json↔audios.jsoncross-check per language, no duplicates, no orphanspages.jsonhrefs resolve; section ids match filenames/meta tagsdata-*attributes well-formed--fixmode that re-syncstexts.json[source]from the HTMLAGENTS.md(already shipped) updated to state the tier rules and instruct agents to run the validator after every change.2. Tiered import semantics
glossary.json,toc.jsonweb-rendering/glossary/toc-generationversions → text-catalog rebuild → stale translations/TTS regenerated for changed ids only (LLM cache + per-text-id mp3s keep this cheap)texts.jsonentriestext-catalog-translationversions → re-TTS just those entries. Preview flags conflicts: "source changed and translation hand-edited for the same id"audios.json, timecodes,offline-preloader.js,scorm.js,.build-hash, quiz HTML structure, structural changes (add/remove/reorder section files)Authority rule for the known duplication trap: the same string exists inline in page HTML and in
texts.json[source]. The HTML is authoritative for source-language text; the validator enforces the match.3. Import endpoints + UI
POST /books/:label/import-adt+ a preview endpoint, mirroring the part-merge pattern (preview-merge/mergewith hash-gate warnings):Scoping
Key implementation touchpoints
packages/pipeline/src/packaging/web.ts—packageAdtWeb,renderPageHtml,computePackagingInputHash,AGENTS.mdrendering (assets/AGENTS.md.liquid)packages/pipeline/src/text-catalog.ts— data-id harvesting (the join key for the whole design)packages/storage/src/book-storage.ts—putNodeDataappend-only versioningapps/api/src/services/{export-service,import-service,part-service}.ts— existing export/import/merge patterns to mirrorapps/api/src/routes/pages.ts—saveStoryboardNode+ cascade clears (the existing write path edited HTML flows into)packages/types/src/part.ts—PartManifestas prior art for the newmanifest.jsonschemaOrganizing principle
Give the external LLM a document plus a validator it can run in a loop, and keep every database write inside Studio's own import code. Any design that asks the agent to maintain a derived invariant (sqlite consistency, translation freshness, build hashes) is fragile no matter how good the prompts are.
All reactions