Repository navigation
Read unclosed math and HTML openers in a Markdown view in linear time - #50
Merged
Merged
Conversation
Math closers and comment, instruction, declaration and character-data closers are found once per paragraph and remembered, so openers that never close no longer each read to the end of the text; the open-tag stack and the runs between an open tag and its closing tag are kept without a walk per closing tag. Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
…quare The read count misses the work a lazy pattern does inside one call, so the test passed without the fix; timing each source at a length and at four times it does fail then. Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
At the old length the quadratic scan closed the page before the read bound was checked; at this one it fails on the bound. Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
…th over 400k against 50k characters Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
rostislavrotaru
commented
Nov 23, 2026
The growth test ran each input in one test, about 28 seconds of the 30-second limit on macOS x64; it is now one test per input, at 200,000 against 25,000 characters. MarkdownMath reads the block parser's line marks through a check that names a missing line, and the specs load the Markdown parser through a fixture that fails when it doesn't load, so neither needs a cast. Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
The growth tests compared timings and failed on a slower macOS x64 runner. Each now checks, on any machine, that the scan reads the paragraph under 4 times per character and that every pattern of MarkdownTextReferencesResources run over it is sticky or anchored at the start, so it can't search ahead. Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
rostislavrotaru
commented
Nov 23, 2026
…sObject The math read test parsed each long input twice, once for its reads and once for its tree, and ran a third input at the issue's size that the issue doesn't name. It now reads the tree from the counted parse and runs the issue's two inputs at full size, with all three small first. The text-scan fixture checks for an object with Object.isObject. Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
rostislavrotaru
commented
Nov 23, 2026
rostislavrotaru
left a comment
Contributor
Author
There was a problem hiding this comment.
Reviewed: #50 at a9e6126
Verdict: Approve
Findings: 0 Should fix, 0 Low
Why it's right: inline math and text references now read unclosed openers in linear time; the specs count closer searches and indexOf reads on the issue's long inputs, check that every text-reference pattern is sticky or start-anchored, and fail against the old scanners.
Agent: LEAD (lead)
Agent-Model: Anthropic Opus 5.5, High
rostislavrotaru
added a commit
that referenced
this pull request
Nov 23, 2026
Closes #55 The version for 0.0.28's release. ## What - `version.json`: 0.0.28. - `CHANGELOG.md`: the 0.0.28 section, from the pull requests merged after 0.0.27's release: - a Markdown view reads unclosed math and HTML openers in time linear in the paragraph's length (#50); - as internal, the docs site's spec run printing each test as it ends (#52). Main's run at 928b44f, this branch's base (#50's merge), passed Build and test and Docs. ## Checks - `npm run test:docs` passed on a Linux test machine. - No code changes, so no other tests run here; CI is the gate. Agent: DEV8 (developer) Agent-Model: Anthropic Opus 5.5, Medium
rostislavrotaru
added a commit
that referenced
this pull request
Nov 30, 2026
Issue: #283 The timing check now judges the times `npm test` just recorded, using the limit factor `NOLDOVA_TIMING_LIMIT_FACTOR` gives. It no longer runs the suite three more times. CI doesn't run it yet. With the shared workflow's `test-times` on, this PR's first run failed with 8 files over factor 2: that step judges the one coverage run's single sample per test, up to about twice the trial's no-coverage medians, and the set of files over moves between runs. [noldova-com/.github#75](noldova-com/.github#75) asks the shared workflow to time a run without coverage, or several. So `test-times` stays off here, and #283's box for it stays open. ## What Paths are under `src/noldova.ui.components.angular/`. **Recorded times** - `scripts/angular/test-times.ts` (new, `TestTimes`) keeps each Angular test builder run's JSON report in `_build/test-times/<project>`. Each test run empties that folder first. - A docs run that skips its tests writes a note saying why instead. - `scripts/test.ts` keeps each kit run's report. - `../noldova.ui.components.angular.docs/scripts/test-docs.ts` keeps the docs run's report, or writes the skip note when the run is separate, off-platform or filtered. **The check** - `scripts/angular/angular-test-timing.ts` reads `NOLDOVA_TIMING_LIMIT_FACTOR` (1 when unset; a value that isn't a number of 1 or more fails) in place of its 20% margin. A file fails only over the factor times its budget. - `scripts/angular/angular-timing-script.ts` no longer runs any spec. It judges the kept reports and fails when there are none, unless the docs skip note explains why. - It refuses spec file names. - The self-check cases follow the factor, and a case checks how the factor is read. - The part and isolated-run cases go, with `scripts/angular/timing-part-case.ts`. - `scripts/angular/kept-report.ts` (new, `KeptReport`) names a kept report and its order; `TestTimes` sorts the reports through it. - No spec file gets a longer budget: TESTING.md lets a maintainer accept only a unit test file. - `.github/workflows/build-and-test.yml` is unchanged: `test-times` stays off. noldova-com/.github#75 is released in v2.60.0, and turning it on is a PR of its own. **The five other files over twice their budget** These are from the hosted trial in #283. - `tests/app/components/button/button-disabled-look.component.spec.ts` and `tests/app/components/icon-button/icon-button-disabled-look.component.spec.ts`: one capture of every look's pieces through `ScreenshotFixture.piecesAsync`, then one of the focused labels or glyphs. Before, each look took four captures. - `tests/app/models/markdown-math-scan.spec.ts` and `tests/app/models/markdown-text-references-scan.spec.ts`: inputs of 20,000 characters, not 100,000. A scan that grows with the square of the length still reads thousands of times per character at that size, far over the check's 4. - `tests/app/components/message/message-popover.spec.ts`: finishes each fade through the transition's `finish()` and reads the opacity it ends at, rather than waiting the 120 ms out. **The gallery feed specs** They stay over twice the budget, so #283's box for main passing the check stays open, and #296 follows them. Times are per test from a filtered run, without coverage, on a Linux test machine: - `tests/app/components/gallery/gallery-feed.component.spec.ts`: 479 ms, now 208 ms. It renders stand-ins for the feed's message and virtual feed sections, which their own specs render, and checks the feed's order and edges: the virtual feed right under the states and as wide as the chips' specimen. - `tests/app/components/gallery/gallery-virtual-feed.component.spec.ts`: median 287 ms, now 237 ms. Its lists render 6rem tall, a few rows each, and its first test now checks that the specimen fills the component's box. - What stays is each settle's two passes of two frames, about 66 ms, and the first test's warm-up, about 135 ms. **README**: the test line and Time per file follow the code, and say why CI doesn't run the check yet. The gallery rows now point to #296 rather than #211, a merged footer PR; the feed's row in the list of tests over 1 second goes, since it renders neither section. ## Checks On Linux, Mac and Windows test machines, I ran the five changed spec files with `npm test -- <names>`, then `npm run test:timing` with the factor at 2. - The tests passed everywhere, and the self-check held. - On Linux, all five were within twice the budget. - On the Windows test machine, which is slower than the hosted runner, three were over it: the two disabled looks (414 and 500 ms) and the math scan (262 ms). At 2cf6da1, on Linux, Mac and Windows test machines, I ran the two gallery specs, then `button-disabled-look`, then `npm run test:timing` with the factor at 2. Everything passed, and the self-check held. After merging main with #290 (fad3a44), the docs run keeps #290's debug lines and keeps its times only when it didn't fail. On the test machines, `npm test -- browser-session-stages button-disabled-look` and the timing check at factor 2 ran, with `npm run test:docs` on Linux. Every test passed and the self-check held. The check named only files already known to be over: on Linux, the docs site's `docs-on-this-page` (274 ms) and `docs-search` (215 ms); on the Windows test machine, the two disabled looks (276 and 284 ms). ## Not checked - The timing check in CI, which stays off until a PR turns on `test-times` with the v2.60.0 pin. Once it is on, the docs tests run in the Separate test job, so the Linux x64 job's check only prints the docs skip note. - I haven't checked the smaller scan inputs against the scan before #50. Agent: DEV2 (developer) Agent-Model: Anthropic Opus 5.5, Medium
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.
Closes #44
A Markdown view reads a paragraph of unclosed math or HTML openers in time that grows with its length, not with its square, so a long message whose openers never close no longer holds the page for seconds, and a streaming message no longer repeats that cost on each update.
What
Paths are under
src/noldova.ui.components.angular/.Math
src/app/models/markdown-math-scan.ts(MarkdownMathScan) keeps one scan per parse (StateInline).$closers in one forward pass.src/app/models/markdown-closer.ts(MarkdownCloser) is that memory for one closer: how far it has searched, the closer it found, and where none follows.src/app/models/markdown-math-delimiter.tsnames each delimiter's opener and closer, whichmarkdown-math.resources.tsnow lists.markdown-math.tsasks the scan instead of searching from each opener.Text references
src/app/models/markdown-html-scan.ts(MarkdownHtmlScan) replaces the tag pattern's lazy branches with a linear scanner.<!--->where it starts.-->,?>,>,]]>) each use aMarkdownCloser, so an unclosed one fails at once after the first search.markdown-text-references.tskeeps the open tags per name (MarkdownHtmlOpening), so a closing tag finds its innermost open namesake without rebuilding a list.MarkdownTextRun,MarkdownTextRange,MarkdownTextPlace).MarkdownHtmlTag,MarkdownHtmlSpanandMarkdownHtmlBlockhold what it reads.Testing
tests/app/models/markdown-math.spec.tscounts the charactersindexOfreads (tests/fixtures/text-scan.fixture.ts) for unclosed\(,\[aand$a:\(× 100,000,$a× 60,000);tests/app/models/markdown-text-references.spec.ts, for text references, checks how the scan searches, with no timing, so it holds on any machine. It runs for 100,000 characters of unclosed<?,<!--and<!a, and for opening tags followed by unmatched closing tags:indexOfreads, as for math);MarkdownTextReferencesResourcesrun over the paragraph is sticky or anchored at its start, so it tries one place and can't search ahead (TextScanFixture.searchesOver, which spies onRegExp.prototype.exec, the pathmatchAll,matchandtesttake, and knows the patterns by source and flags, sincematchAllruns a clone);indexOf, which the read count bounds.<that opens nothing, and nesting and covered runs.npm test -- tests/app/models/markdown tests/app/models/rendered-text tests/app/services/markdown tests/app/services/provide-markdown tests/app/components/markdown-viewpassed on Linux, macOS and Windows test machines (359 tests). After the spec changes, the math and text-reference specs passed on each again (20 tests), and the text-reference spec once more after its last case (12 tests). After the review rounds, the math and text-reference specs passed on each (24 tests).Not checked
Agent: DEV8 (developer)
Agent-Model: Anthropic Opus 5.5, Medium