Repository navigation
app: workstream pages render from editor JSON to markdown (pagedoc) - #2277
Merged
Merged
Conversation
The Workstreams plan, WP-6c: internal/workstream/pagedoc.Markdown renders a page's editor JSON by the page document format rules, byte for byte the same as the desktop app's renderer, so a job that reads a page sees the markdown a person sees when they export it. Pure: no I/O and no store; invalid JSON is an error, an absent document is empty, unknown nodes keep their text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…act example Every assertion of the desktop app's markdown tests as a Go table row with the identical expected string, the contract's worked example as testdata, invalid and absent documents, and edge cases that pin JavaScript's line terminators, number formatting and coercions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 3, 2026
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.
Summary
The Workstreams plan, WP-6c. Workstream pages are stored as editor (TipTap/ProseMirror) JSON. When a job reads a page, the engine renders that JSON to markdown at that moment. This adds the renderer as a pure package:
internal/workstream/pagedoc:func Markdown(doc json.RawMessage) (string, error). No I/O, no store, standard library only.liveBlockmarker lines ([live: jobs milestone=…],[live: waves],[live: job <factory>#<n>],[live: decision <id>]).pagedoc:. A nil, empty, whitespace-only ornulldocument returns"". A recover guard turns any unforeseen panic into an error.\r,\n, U+2028 and U+2029;\r\nprecedence; numbers decoded so1e400is infinity rather than a decode error; JS number formatting for list starts and job numbers (-0→0,1e21→1e+21).Validation contract
TestMarkdownParagraphsHeadingsEmptyBlocksAndTerminalNewline,TestMarkdownInlineNewlinesAndOuterWhitespace,TestMarkdownBulletAndOrderedLists,TestMarkdownCodeBlocks,TestMarkdownInlineCode,TestMarkdownLinksAndDestinations,TestMarkdownEmptyTextAndLinkRuns,TestMarkdownLiveBlocks,TestMarkdownLiveBlockAttributeValidation,TestMarkdownEscapingAndParagraphLineStarts,TestMarkdownUnknownNodesMarksAndMalformedShapestestdata/, checked against an independently built document)TestMarkdownRendersTheContractExampleTestMarkdownRefusesInvalidJSON,TestMarkdownTreatsAnAbsentDocumentAsEmpty,TestMarkdownRendersADeepDocumentWithoutPanickingTestMarkdownUnknownNodesMarksAndMalformedShapes, rows 3, 6, 7, 9 ofTestMarkdownMatchesTheReferenceOnEdgeCasesTestMarkdownMatchesTheReferenceOnEdgeCases(36 rows)The one JS fixture not ported is the
NaNjob number, which JSON cannot carry. Known, untestable divergences (documented in the code): lone UTF-16 surrogate escapes decode to U+FFFD in Go, and documents nested deep enough to exhaust the JavaScript stack render in Go (up to encoding/json's 10000-level limit, past which they are invalid JSON).Left for later
Markdownyet. It is ready for the Factory plan step that builds job briefs from pages marked "Read by jobs".page.getmarkdown option (in the store pull request, app: workstream store (schema 3, factory_job refs, all 25 methods served) #2270) has its own simpler renderer; once both land it should callpagedoc.Markdownso there is one renderer.CI
touched packagesran./internal/workstream/pagedocand passed. Build, vet, gofmt and the change entry pass. The light gate's one red is the baseline laws ratchet ininternal/session(TestNoRoadInTheTaskEngineHasMoreEndingsThanItsLedgerRow,TestNoRoadInTheMemoryEngineHasMoreEndingsThanTheCeiling), which is red the same way onworkstreams/main's own push runs and is not touched here.Contract changes
None. This implements the existing page document format.
🤖 Generated with Claude Code