wip(docx): Phase-3 N0 token-map spike — DRAFT, does not compile#120
Draft
bobzhang wants to merge 1 commit into
Draft
wip(docx): Phase-3 N0 token-map spike — DRAFT, does not compile#120bobzhang wants to merge 1 commit into
bobzhang wants to merge 1 commit into
Conversation
…OT COMPILE) Draft checkpoint for the Phase-3 N0 spike (docs/docx-agent-roadmap.md). Contains ONLY the data model and walk-state scaffolding; the walker that consumes them is unwritten, so `moon check` fails with 3 unused-function errors (start/barrier/in_paragraph/resolve/inside/ innermost_wt). This is an intentional WIP handoff, not a mergeable state — see the draft PR body for the resume plan. Done: - Five-class inline model as enums (TokenContext, AtomKind, RestrictionReason, BarrierKind) + ProjToken/ProjAtom/RestrictedSpan/ BarrierPoint/ParagraphTokenMap/StoryTokenMap. - ParagraphBuild accumulator; TmFrame/FieldFrame/TokenWalk walk state with resolve/inside/innermost_wt accessors. Not done (resume here): - build_story_token_map: the byte-walker loop (model the annotation scanner's scan_story in annotation_scan.mbt), w:t content tokenizer (entity/charref/CDATA context kinds, scalar-only boundaries), five-class classifier driven by the reader's ACTUAL projection (docx_reader.mbt is the contract), story-wide field stack, logical- paragraph enumeration (tracked-deleted marks merge forward). - The N0 oracle tests: projection equality vs reader, classification pins, PERMITTED-pair splice trials byte-identical outside the edit union, REFUSAL trials with exact errors. Then record GO/NO-GO in the roadmap. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
DRAFT / WIP — DO NOT MERGE. This branch does not compile. It is a
checkpoint of the Phase-3 N0 token-map spike, parked mid-implementation
when the session switched models. CI is expected red (3 unused-function
errors). Resume plan below.
What N0 is
N0 is the GO/NO-GO gate for Phase 3 (targeted edits). It builds the
projection-to-source token map: for each physical
w:p, a map from thereader's text projection (
docx text) back to exact byte spans, preciseenough to cut and splice inside
w:tcontent. Full spec: the# Phase 3section of
docs/docx-agent-roadmap.md(merged in #118), sub-section"N0 — token-map spike" and "Locked design decisions".
State in this PR (commit ab2aab1)
Done —
docx2html/docx/token_map.mbt, data model + walk scaffolding only:TokenContext(RawText/EntityRef/CharRef/CdataText),
AtomKind,RestrictionReason,BarrierKind; plusProjToken,ProjAtom,RestrictedSpan,BarrierPoint,ParagraphTokenMap,StoryTokenMap.ParagraphBuildaccumulator;TmFrame/FieldFrame/TokenWalkwalk-state structs with
resolve/inside/innermost_wtaccessors.Not done — resume exactly here:
build_story_token_map(part : Bytes) -> StoryTokenMap— the byte-walkerloop. Model it on
scan_storyinannotation_scan.mbt(same<-dispatch, namespace stack, comment/CDATA/PI skipping,scan_tagreuse). This walker is the piece that got overwritten and must be
re-authored.
w:tcontent tokenizer: split content intoProjTokens withcontext kinds (raw /
&entity / numeric char-ref / CDATA), decodingto match the reader (see
decode_xml_entitiesinxml/xml.mbt) whilerecording scalar-only byte boundaries. CDATA-context tokens are
mutation-refused (v1).
docx_reader.mbtis the contract:w:t,w:tab→\t,w:noBreakHyphen→U+2011,w:softHyphen→U+00AD, supportedw:sym(seeread_symbol);w:del,mc:Choice, movewrappers, checkbox-suppressed text (see
read_structured_document_tag);w:inscontent, non-checkboxw:sdt,mc:Fallback, textbox/pict;end / unclosed-at-EOF / double separate — see
read_paragraph_childrenfor the reader's per-paragraph version to mirror and extend to
story-wide).
content forward into the next
w:p(seeread_children+read_paragraph_elements_with_prefix); such logical paragraphs areTrackedRegion-restricted in v1.token_map_test.mbt, new): on the hostile matrix inthe roadmap — (a) projection equals the reader's, (b) classification
pins, (c) permitted-pair splice trials byte-identical outside the
declared edit union with valid re-parse, (d) refusal trials with
exact declared errors (CDATA / non-scalar / barrier-spanning /
restricted / suppressed / merged-paragraph / malformed-field).
docs/docx-agent-roadmap.md(like L0).Reviewer note
No review is requested on this draft — it is a resume point, not a
proposal. When implementation is complete it goes through the standard gate
(self-adversarial → subal xhigh → green CI) and this description is replaced.
🤖 Generated with Claude Code