oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# Markdown streaming follow-up
2
3Branch `native/markdown-streaming`, based on main at `3589c220`. This report
4includes the follow-up to Fable's review of `b533757b`.
5
6## Message lifetime and large replies
7
8A session owns a `MarkdownTranscript`, keyed by message identity. Each message
9has one background parsing worker. Appended deltas replace the pending request
10without cancelling the in-flight parse. Every finished prefix publishes before
11the worker parses the latest pending revision. Intermediate revisions do not
12queue. Small replies still render synchronously; cached revisions include the
13account origin, message ID, exact text and draft/completed state.
14
15SwiftUI hosts borrow the message's renderer. Disappearance, scrolling and
16re-hosting do not stop it. Removing a message from the feed or a snapshot stops
17its worker, as does leaving the session. Cancellation and a generation check
18reject late results. A completed message settles its final parse, then the
19worker exits. Replacing a message's source starts fresh.
20
21The original 64 KiB test streams 67 updates at 5 ms intervals. The old
22cancel-on-delta implementation showed only one distinct height before the
23stream ended. The regression requires at least six. A delayed-parser test checks
24that prefixes publish, only one parse runs, appends cause no cancellations and
25the final completed tree is exact. A deterministic held-parse test sends 67
26pending revisions plus completion and requires exactly two parses: the first
27prefix and the latest completed revision.
28
29## Mac transcript rows
30
31`LiveTranscript` retains each row and reply host. A row revision includes its
32feed item, width, task details, answer/aside feedback and stopping state.
33Unchanged revisions receive no content update or intrinsic-size measurement.
34Changed replies update their existing host in place; new and removed IDs alone
35attach or detach rows. Ordering changes sort existing views without re-hosting.
36Height callbacks resize the changed reply and move later rows without rebuilding
37their contents. A width change resizes the existing rows.
38
39Fable's reproduction is covered two ways: a SwiftUI host is repeatedly detached
40and reattached across 67 large deltas, and the actual `EquipoMac.LiveTranscript`
41runs 49 historical replies plus one 17–25 KB streaming reply. The first test
42failed at one height before the fix. The actual transcript now grows throughout
43the stream; a focused run saw 10 growing heights (64 with other layout tests
44running concurrently). Completion keeps the same row, and removal cancels its
45message parser.
46
47The performance test uses the production Mac transcript inside an `NSWindow`,
48with 50 realistic replies. Before the fix, its median update was 723 ms. After
49the fix, a debug run measured 3.44 ms median and 5.50 ms maximum. The 50 ms median
50budget allows debug/CI variation while rejecting the original full rebuild by
51more than an order of magnitude. Timing is paired with deterministic assertions:
52exactly one content revision per changed reply, the same row and host identities,
53and no window detach/attach notifications. Removal, reinsertion, ordering and
54width changes are checked too.
55
56The Release test (`swift test --package-path native/apple -c release --filter
57MacTranscriptTests`) passed: 2.71 ms median, 4.83 ms maximum for the 50-reply
58update; the large reply showed 29 growing heights during 67 deltas. This
59uses the real transcript class and window layout, with in-memory test accounts;
60it is not a signed-in production-app timing session. No personal Keychain or
61signing settings were accessed for the harness.
62
63## Open code spans
64
65The first follow-up matched Goldmark's merging of unmatched emphasis delimiters
66into watched fallback backtick text, including adjacent closers. This revision
67also ends that watched text at a link/image opener. Bracket labels remain
68visible while the code span and destination are still open.
69
70Every streaming cut of the supplied underscore/asterisk examples and
71`[text](url)` / `![alt](src)` inside backticks is checked. The fixed-seed grammar
72adds links and images inside open code spans, with quote/list prefixes, optional
73closers, destinations and random cuts. The expansion found 322 mismatches before
74the bracket fix. There are now 3,586 checked-in cases and 32,000 unique generated
75inputs: 35,586 comparisons with zero mismatches. Go Render/RenderDraft output
76is unchanged.
77
78## Verification
79
80Tests preceded the fixes. Focused checks use:
81
82```sh
83EQUIPO_MARKDOWN_DIFFERENTIAL="$PWD/native/build/markdown-differential.json" \
84 swift test --package-path native/apple \
85 --filter 'MacTranscriptTests|MarkdownParsingStreamTests|MarkdownLayoutTests|ChatMarkdownTests'
86native/scripts/check-native.sh
87```
88
89The earlier commit's nine guards were broken and restored in eleven mutation
90runs. All ten re-review guards were also broken and caught: detaching existing
91rows, ignoring row revisions, replacing reply hosts, stopping on disappearance,
92losing owner identity, omitting cancellation for removed messages, omitting
93session-departure cancellation, hiding open-code link labels, omitting snapshot
94removal cleanup and omitting feed removal cleanup. Each focused regression
95failed, then the guard was restored; none failed to compile or timed out.
96
97The revision-guard mutation initially stayed within the broad performance
98budget; adding the exact content-update count made that unnecessary work
99observable independently of machine speed.
100
101`native/scripts/check-native.sh` passed: fixture freshness and the generated
102corpus, strings/parity, reference scan, 167 Swift tests in 20 suites, Mac build
103and unsigned iOS Simulator build. The suite retains the existing known Oficina
104ID session issue; no new known issue was introduced. The full-suite Mac stream
105also grew through 64 sampled heights during 67 deltas.
106
107Go tests, vet, staticcheck v0.7.0 for `internal/chatmarkdown`, `make fmt-check` and
108`go mod tidy -diff` passed with `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`, with that
109toolchain on PATH. Local evidence is under `native/build/logs/streaming-review-*`.
110
111## Remaining scope
112
113Fable's random-token finished-reply cases involving lone CR, reference
114definitions and nested `<` in angle destinations remain deferred. The current
115corpus matches, which does not claim those independent counterexamples match.
116No product strings or dependency pins changed. Projects awaits its brief.
117