One.
\nTwo.
",
+ ),
+ // A tag in a paragraph begins with that paragraph.
+ (
+ "## A\n\nSkipped.\n\nKept. Kept.
\nAfter.
",
+ ),
+ // `following` counts blocks, headings included.
+ (
+ "Start. Start.
",
+ ),
+ (
+ "Start. Start.
\nAfter.
",
+ ),
+ // `following` is clamped at the end of the document.
+ (
+ "Start. Start.
\nEnd.
",
+ ),
+ // A raw HTML heading bounds a section; one in a block quote doesn't.
+ (
+ "## A Start inside.
",
+ ),
+ // A tag alone on its line, closed or not, isn't a block: it begins
+ // with the next block.
+ (
+ "\n\nNext.\n\nEnd.\n",
+ "Next.
",
+ ),
+ (
+ "\n\nNext.\n\nEnd.\n",
+ "Next.
",
+ ),
+ // A tag with no block after it encloses nothing, without an error.
+ ("Text.\n\n\n", ""),
+ // Other fragments' backlinks, ids, and comments between blocks are
+ // cleaned as for a source file.
+ (
+ "A
\n\n\n\nText. \n",
+ "A
\n\nText.
",
+ ),
+ ] {
+ assert_eq!(
+ markdown_fragment_content(markdown, "f").as_deref(),
+ Some(content),
+ "{markdown}"
+ );
+ }
+}
+
+// Verify the examples in the cache spec's "Fragments in Markdown documents"
+// literally.
+#[test]
+fn test_markdown_fragment_spec_examples() {
+ let install = "Intro text. \n\n## Install\n\n\n\nRun `./bt install`. \n\n### Windows\n\n* Install `pwsh` first. \n* Then rerun the command.\n\n## Run\n";
+ let list =
+ "\n- Install
pwsh first. \n- Then rerun the command.
\n
";
+ let run = "Run ./bt install.
";
+ let design = "## Design \n\nRationale.\n\nNotes
\n";
+ let parsing = "### Parsing \n\n> #### Note\n>\n> Quoted text.\n\n#### Tokens\n\n## Output\n";
+ for (markdown, id, content) in [
+ (install, "intro", "Intro text.
".to_string()),
+ (install, "install", format!("{run}\nWindows
\n{list}")),
+ (install, "bt", run.to_string()),
+ (install, "win", list.to_string()),
+ (
+ design,
+ "design",
+ "a fragment may not contain a gather element"
+ .to_string(),
+ ),
+ (
+ &design.replace("id=\"design\">", "id=\"design\" following=\"1\">"),
+ "design",
+ "Design
\nRationale.
".to_string(),
+ ),
+ (
+ parsing,
+ "parsing",
+ "Parsing
\n\nNote
\nQuoted text.
\n
\nTokens
".to_string(),
+ ),
+ ] {
+ assert_eq!(
+ markdown_fragment_content(markdown, id).as_deref(),
+ Some(content.as_str()),
+ "{id}"
+ );
+ }
+}
+
+// Verify that a fragment tag in code defines no fragment, and that an invalid
+// id or `following` value is an error, as in a source file.
+#[test]
+fn test_markdown_fragment_errors() {
assert_eq!(
- source_to_codechat_for_web(
- "",
- Path::new("foo.md"),
- 0.0,
- false,
- None
+ markdown_fragment_content("``\n", "f"),
+ None
+ );
+ assert_eq!(
+ markdown_fragment_content("```\n\n```\n", "f"),
+ None
+ );
+ assert_eq!(
+ markdown_fragment_content("Text \n", "1f"),
+ None
+ );
+ assert_eq!(
+ markdown_fragment_content("Text \n", "f")
+ .as_deref(),
+ Some(
+ "the \"following\" attribute (\"x\") must be a whole number"
+ )
+ );
+}
+
+// Verify that a gather element among the enclosed blocks, even a nested one,
+// makes the fragment's content an error, and that a `following` which stops
+// before it avoids the error.
+#[test]
+fn test_markdown_fragment_gather() {
+ let error = "a fragment may not contain a gather element";
+ for (markdown, content) in [
+ (
+ "## A \n\nText.\n\nG
\n",
+ error,
),
- Ok(build_codechat_for_web(
- MARKDOWN_MODE,
- "fragments are not allowed in Markdown documents",
- vec![]
- ))
+ (
+ "## A \n\n> G\n",
+ error,
+ ),
+ (
+ "## A \n\nText.\n\n
G
\n",
+ "A
\nText.
",
+ ),
+ // A gather element in the anchor block can't be excluded.
+ (
+ "Text G \n",
+ error,
+ ),
+ ] {
+ assert_eq!(
+ markdown_fragment_content(markdown, "f").as_deref(),
+ Some(content),
+ "{markdown}"
+ );
+ }
+}
+
+// Verify that a gather element in one Markdown document lists a fragment from
+// another, which renders a backlink to it, and that adding a block to the
+// fragment's section outdates the gathering file.
+#[test]
+fn test_markdown_fragment_gathered() {
+ let cache = Arc::new(Mutex::new(Cache::default()));
+ let translate = |source: &str, path: &str| {
+ let translation =
+ source_to_codechat_for_web(source, Path::new(path), 0.0, false, Some(cache.clone()))
+ .unwrap();
+ let CodeMirrorDiffable::Plain(code_mirror) = translation.source else {
+ panic!("No diff!");
+ };
+ code_mirror.doc
+ };
+ let gathering = "Gathered
\n";
+ let fragment = "## A \n\nOne.\n";
+ translate(fragment, "b.md");
+ assert_eq!(
+ translate(gathering, "a.md"),
+ "Gathered
"
+ );
+ assert_eq!(
+ translate(fragment, "b.md"),
+ "One."
+ );
+ translate(
+ "## A \n\nOne.\n\nTwo.\n",
+ "b.md",
+ );
+ assert_eq!(
+ cache.lock().unwrap().files[Path::new("a.md")].status,
+ FileStatus::Outdated
);
}
+// Verify that saving a Markdown document keeps each fragment tag in its block,
+// including a tag alone in its own paragraph or left unclosed, so that
+// reopening it reproduces the same extent. (Level 1 and 2 headings are saved as setext headings.)
+#[test]
+fn test_markdown_fragment_round_trip() {
+ for (source, saved) in [
+ (
+ "## A \n\nOne.\n\n## B\n",
+ "A \n------------------------------\n\nOne.\n\nB\n-\n",
+ ),
+ (
+ "Before.\n\n\n\nAfter.\n\nEnd.\n",
+ "Before.\n\n\n\nAfter.\n\nEnd.\n",
+ ),
+ (
+ "* First.\n* Second \n\nAfter.\n",
+ "* First.\n* Second \n\nAfter.\n",
+ ),
+ // Saving closes an unclosed tag alone on its line; the extent is kept.
+ (
+ "\n\nNext.\n\nEnd.\n",
+ "\n\nNext.\n\nEnd.\n",
+ ),
+ ] {
+ let save = |source: &str| {
+ codechat_for_web_to_source(
+ &source_to_codechat_for_web(source, Path::new("foo.md"), 0.0, false, None).unwrap(),
+ )
+ .unwrap()
+ };
+ assert_eq!(save(source), saved, "{source}");
+ assert_eq!(save(saved), saved, "{saved}");
+ assert_eq!(
+ markdown_fragment_content(saved, "f"),
+ markdown_fragment_content(source, "f"),
+ "{source}"
+ );
+ }
+}
+
// Verify that a fragment without an id -- whether its `id` attribute is missing
// or empty -- hydrates to an error message requesting the id. Dehydration
// removes the message, so saving the hydrated result writes back a bare
diff --git a/submission.md b/submission.md
new file mode 100644
index 00000000..dc2fdb43
--- /dev/null
+++ b/submission.md
@@ -0,0 +1,354 @@
+Project 2 submission
+====================
+
+Repeat the following block for each team member.
+
+Team member: Arsen Zhexenbiyev (GitHub: Arsen-kbtu)
+---------------------------------------------------
+
+### Contribution (5 points)
+
+Reviewed and revised the team's earlier "Inline inclusion of fragments" section
+of `server/src/processing/cache-spec.md` (commits `3061a13` and `8808984`),
+which the team later replaced with "Fragments in Markdown documents", and
+verified that the project builds and runs on Windows.
+
+### Build and run check (5 points)
+
+Prompt: "Verify that you can build and run the project in the current git repo."
+
+Summary of the LLM's output (Claude Opus 5.5, Windows 10, Rust/cargo 1.100.0,
+Node.js 20.11.1):
+
+* `./bt install` installed pnpm and the Client and VSCode extension npm
+ packages, and fetched all crates. It then failed at installing cargo-binstall,
+ since that step requires `pwsh` (PowerShell 7), which isn't installed.
+ `cargo-nextest`, which the build requires, was installed instead with `cargo
+ install cargo-nextest --locked`; the other tools (cargo-dist, cargo-audit, and
+ so on) aren't needed to build.
+* `./bt build` built the Rust workspace (server and standalone binary; one
+ `unreachable_code` warning and two unused-dependency warnings), passed the 13
+ `export_bindings` tests, and bundled the Client with esbuild. It then failed
+ at `node HashReader.js`: Node 20 can't read `package.json5`, so it didn't
+ treat the ES module as one. Rerunning with
+ `NODE_OPTIONS=--experimental-detect-module` built the Client and passed `tsc
+ -noEmit`.
+* The VSCode extension build (`npx napi build`) still failed: `@inquirer/core`
+ imports `util.styleText`, which Node 20.11 lacks. CI uses Node 26; upgrading
+ Node is required to build the extension.
+* Running `target/debug/codechat-editor-standalone --port 8080 serve` started
+ the server: `/ping` returned `pong`, `/` redirected to the file browser
+ `/fw/fsb/`, and opening `README.md` through it returned the Client page (HTTP
+ 200). The standalone server and Client build and run; the VSCode extension
+ does not build with Node 20.
+
+### Review rounds (10 points)
+
+The section reviewed is "Inline inclusion of fragments" in
+`server/src/processing/cache-spec.md`, as of commit `8808984`. The team later
+replaced that section with "Fragments in Markdown documents", so neither it nor
+this review's `review.md` is in the current branch; both are in `8808984`.
+
+| Round | Findings | Main changes made |
+| ----- | -------- | ----------------- |
+| 1 | 10 (4 major, 2 medium, 3 minor, 1 nit); see `review.md`. Major: the hydrated form lost `ref`; block inclusion was unreachable and produced a `div` inside a `p`; ``s in included content linked from the wrong file; Markdown support was left open. | Kept `` in every hydrated form and defined dehydration for each; redefined block inclusion as a top-level `` replaced by a `div`; required `` re-hydration as in gather lists; allowed `` in Markdown documents; added TinyMCE and sanitizer requirements; completed the flattening rules; fixed the example; added layer 6 and `` to the cache-design section. |
+
+### Last review (10 points)
+
+Prompting Claude Opus 5.5 (Claude Code), high effort, with `Review the spec
+and make the changes` (the original prompt was in Russian: "сделай ревью
+спеки и внеси изменения") produced the following findings, saved in
+`review.md` at commit `8808984`, for the section "Inline inclusion of fragments" in
+`server/src/processing/cache-spec.md`; strikethrough indicates LLM output
+that I deemed incorrect or irrelevant.
+
+1. **Major: the hydrated form loses `ref`.** The example hydrates `` to a bare ``, and dehydration
+ is said to leave ``. With the ``
+ element gone, dehydration has no way to recover the `ref`; the first save
+ would erase the include. `` avoids this by keeping its element in the
+ hydrated form.
+
+2. **Major: block inclusion (case 2) can never occur, and its output is invalid
+ HTML.** Doc blocks and Markdown documents are Markdown, so an ``
+ alone on a line parses as `
` (see
+ `test_hydrate_fragment_in_markdown` for ``). The include is never
+ "the only content of its doc block"; its host is always a ``. Inserting
+ the proposed `
` inside that `
` is invalid, and the HTML parser would
+ split the paragraph.
+
+3. **Major: cross-references in included content link from the wrong file.**
+ `Fragment::content` hydrates each `` relative to the fragment's file.
+ A gather list re-hydrates them from `data-content` (layer 5); the include
+ section doesn't, so relative links break whenever the including file is in
+ a different directory.
+
+4. **Major: Markdown is left as an open question.** The branch is "
+ for Markdown", yet whether `` works in Markdown documents is left
+ open. Markdown documents can't define fragments, so including fragments
+ from source files is the main way a Markdown document can use them. The
+ spec should allow it and describe the round trip through the
+ HTML-to-Markdown conversion.
+
+5. **Medium: the Client and sanitizer requirements are missing.** `include` is
+ in neither the TinyMCE `custom_elements` and `extended_valid_elements` lists
+ nor the Server's Ammonia allowlist (`AMMONIA_OPTIONS`), so the element would
+ be stripped before hydration or dropped by the Client.
+
+6. **Medium: the flattening rules (case 1) are incomplete.**
+ * They say nothing about elements that are neither block wrappers nor the
+ listed inline formatting (diagrams, `iframe`, images, display math).
+ * They don't cover an `` inside a link, which would produce nested
+ `` elements.
+ * They don't cover an `` inside `` optional content.
+ * Empty blocks aren't dropped. In the spec's own example, the fragment's
+ doc block also holds the `` tag, whose paragraph is empty after
+ cleaning. Without trimming, this adds a stray space.
+
+7. **Minor: the example is ambiguous.** A fragment includes the *following*
+ code/doc block by default. The example doesn't say what follows the ``,
+ so if a doc block follows, its text would be included too. Use
+ `following="0"` or say that a code block follows.
+
+8. **Minor: the rest of the spec isn't updated.**
+ * The cache-design layer list stops at 5, even though this section
+ introduces "layer 6".
+ * The definition of `IdEntry::dependents` lists only `` and
+ `data-gather` as ways to depend on an id.
+ * The fragments section still says only that fragments aren't allowed in
+ Markdown.
+ * The new `h2` has no `id`, unlike the other `h2`s, so it can't be
+ cross-referenced.
+
+9. **Minor: same-file ordering is asserted, not explained.** "Including a
+ fragment from the same file needs no special case" holds only if include
+ hydration runs after the file's own fragments are committed, as gather-list
+ hydration does. The case of a fragment including itself isn't mentioned.
+
+10. **Nit: the error rules don't match the fragment rules.** A `ref` that is
+ empty should be treated like a missing one, matching the rule for a
+ fragment's `id`.
+
+
+Team member: Aruzhan Matzhan (GitHub: ar_matzhan)
+-------------------------------------------------
+
+### Contribution (5 points)
+
+Wrote and revised the "Fragments in Markdown documents" section of
+`server/src/processing/cache-spec.md`, implemented it in
+`server/src/processing.rs` with Markdown fragment tests, and ran its two review
+rounds.
+
+### Build and run check (5 points)
+
+Prompt: "Verify that you can build and run the project in the current git repo."
+
+Summary of the LLM's output (Claude Opus 5.5, macOS 26.4 on Apple Silicon,
+Rust/cargo 1.99.1, Node.js 26.4.0, npm 11.17.0; dependencies were already
+installed by an earlier `./bt install`):
+
+* `./bt build` succeeded with exit code 0. It built the Rust workspace and
+ passed the 13 `export_bindings` tests on both runs (199 skipped). It bundled
+ the Client with esbuild and passed `tsc -noEmit`. It also built the VSCode
+ extension's native module with napi
+ (`codechat-editor-client.darwin-arm64.node`), bundled `extension.js`, and
+ passed `tsc -noEmit` there. The only warnings were cargo's notes that it
+ ignores the `min-publish-age` settings.
+* `cargo nextest run --lib` in `server/`: 161 tests passed, 1 skipped,
+ including the new Markdown fragment tests.
+* `target/debug/codechat-editor-standalone --port 8085 serve` started the
+ server. `/ping` returned `pong`, `/` redirected (307) to the file browser
+ `/fw/fsb/`, and opening `README.md` through it returned the CodeChat Editor
+ page (HTTP 200). `stop` shut the server down cleanly.
+
+### Review rounds (10 points)
+
+The section reviewed is "Fragments in Markdown documents" (`cc-JzLRfBr83U`) in
+`server/src/processing/cache-spec.md`, checked against the rest of the spec and
+`server/src/processing.rs`. All rounds used Claude Opus 5.5. These rounds are
+numbered separately from Dustin's rounds 1-3 below. They review the section
+after it was rewritten and implemented on this branch.
+
+| Round | Findings | Main changes made |
+| ----- | -------- | ----------------- |
+| 1 | 9 (0 major, 3 medium, 4 minor, 2 nit); see `review.md`. Medium: the opening contradicted the details; it didn't say when blocks are counted relative to hydration; top-level non-element nodes and an unclosed `` were undefined. | Named the source-file rules the section replaces and excluded Markdown in source-file doc blocks; computed boundaries before cache hydration; defined top-level text, unclosed tags, and comments; marked the intro and fragments section as source-file only; mentioned table cells; made the section an `h2`; wrote examples with full tags. |
+| 2 | 7 necessary (0 major, 1 medium, 4 minor, 2 nit), 5 optional; see below. Medium: saving an unclosed top-level `` closes it, which may move a `following="0"` extent on reopening (unverified, no test). | Fixed finding 1 with option (a): a paragraph holding only `` tags isn't a block. Corrected the phase order (after `` and backlink hydration, before gather lists); added the fragment-content cleaning rules to "HTML cleaning"; replaced "contributes nothing" and "verbatim"; defined a tag with no block after it; rewrote the Tests subsection. Also adopted the optional suggestions: updated stale comments, "ASCII whitespace", examples as separate documents, straight quotes. |
+| 3 | 5 necessary (0 major, 1 medium, 3 minor, 1 nit), 5 optional; see "Last review". All five checked and confirmed; findings 1 and 3 with a test. | Applied all five: a tag must be alone in its own paragraph (separated by blank lines), and a tag on a line next to paragraph text joins that paragraph; the no-heading fallback now says "at or before" and ends at the next heading; "as is" became "after cleaning", and the `contenteditable` cleaning rule is limited to `` and ``; the Tests subsection describes what the tests cover instead of requiring a test per rule; the "Errors" wording now says a Markdown fragment is valid and an empty one shows only its "From …:" link. |
+
+### Last review (10 points)
+
+Model: Claude Opus 5.5, run read-only. Effort: default (no separate effort
+setting was chosen). Input: the working-tree
+`server/src/processing/cache-spec.md`, `processing.rs`, and
+`processing/tests.rs`, after the round 2 fixes.
+
+Exact prompt:
+
+```text
+Review only the section "Fragments in Markdown documents" (``, from that heading up to "Search (future work)") in `server/src/processing/cache-spec.md` (repo root: /Users/kaspi/kbtu/project/CodeChat_Editor), and its direct interactions with the rest of that spec: the "Fragments and gather elements" section (`cc-gKXTXIZnFm`), "Cache design" layers (`cc-P-g5o100jN`), "Gather elements: the reverse edge", and "HTML cleaning" (`cc-2dkkF9YJnL`).
+
+Also check the section against the implementation in `server/src/processing.rs`: `hydrate_html`, `hydrate_dom`, `store_fragment_contents`, `render_markdown_fragment_content`, `holds_only_fragments`, `markdown_fragment_extent`, `heading_level`, `top_level_index`, `hydrate_gathers`, `CLEAN_FRAGMENT_HTML`, and the Markdown fragment tests in `server/src/processing/tests.rs` (search for "test_markdown_fragment"). You may run read-only commands (grep, reading files, `git diff`). Do NOT edit any file, do not build, and do not run tests; do not claim test results.
+
+Strictly read-only: do not modify, create, or delete any file.
+
+Return, in English Markdown:
+1. Necessary findings, numbered, each with a severity (major / medium / minor / nit), the spec line numbers, what is wrong, and a concrete suggested fix. A finding is necessary only if the spec is wrong, self-contradictory, ambiguous in a way that changes behavior, or disagrees with the implementation.
+2. Optional suggestions, separately.
+3. A short "Verified as correct" list (what you checked and found consistent, including code references).
+4. Counts: "Necessary findings: N (x major, y medium, z minor, w nit). Optional: M."
+5. One table row summary: | Round | Findings | Main changes recommended |
+```
+
+Output, condensed (necessary findings, optional suggestions, and counts; the
+"Verified as correct" list is omitted). The reviewer numbered its summary row
+"1" because it didn't see the earlier rounds; it is round 3 here. I checked
+every finding: findings 1 and 3 were confirmed by running the cases through
+`markdown_fragment_content`; none is struck through.
+
+1. **Medium: "alone on its line" doesn't match how Markdown splits paragraphs**
+ (spec lines 253-259, 288-289, 360-363). An HTML line can't interrupt a
+ paragraph in CommonMark, and a following line continues it. So
+ `Before.\n\n\nNext.` is one paragraph, which
+ becomes the anchor and encloses `Before.`, not `Next.`; likewise
+ `\nNext.` joins `Next.` into the tag's paragraph.
+ `holds_only_fragments` and `markdown_fragment_extent` work on the parsed
+ paragraph, not on source lines. Fix: say "alone in its own paragraph,
+ separated from neighbouring text by blank lines", and add that a tag on a
+ line directly before or after paragraph text belongs to that paragraph.
+2. **Minor: the no-heading fallback conflicts with the main rule when the anchor
+ is a heading** (lines 277-281). The main rule uses "the nearest heading at
+ or before the anchor block", but the fallback says "if no heading precedes
+ the anchor block, the extent ends just before the document's first
+ heading". If the anchor is itself the first heading, a literal reading gives
+ an empty extent. The code uses "at or before" (`processing.rs:2216`;
+ `tests.rs:2934`). Fix: "If no heading is at or before the anchor block, the
+ extent ends just before the next heading of any level."
+3. **Minor: "as is" overstates what a gather element shows** (lines 294-295,
+ 626-628). `CLEAN_FRAGMENT_HTML` is an Ammonia allowlist: a raw-HTML block
+ counts as a block but may partly disappear (elements outside the allowlist,
+ most classes and attributes). `contenteditable` is kept only on `span` and
+ `xref` (`processing.rs:1338`, `1345`), not on any element as line 627-628
+ implies. Fix: say "the document's own HTML after cleaning", and limit the
+ `contenteditable` rule to `` and ``.
+4. **Minor: the Tests section requires a test for every rule, and several
+ rules have none** (lines 445-455): a top-level non-whitespace text node as a
+ block; comments before the first or after the last enclosed block; a
+ missing or duplicate `id` in a Markdown document; a gather element in the
+ same document listing a Markdown fragment. `_gathered` and `_round_trip`
+ don't compare the stored content. Fix: add these tests, or change "Each
+ rule above needs a unit test" to describe what the tests cover.
+5. **Nit: two wording problems in "Errors"** (lines 344-349). "No longer an
+ error" describes the spec's history; say "a fragment in a Markdown document
+ is valid". The comparison with "an empty doc block in a source file" is
+ wrong: such a doc block still renders its wrapper and line number. Fix:
+ "its stored content is empty; the gather list shows only its 'From …:'
+ link".
+
+Optional suggestions: give the "Gather elements: the reverse edge" heading an
+`id` and refer to it with ``; state that an empty `` also isn't a
+block; say "a cross-reference in the document (in particular, inside the
+extent)"; state that whitespace around `following` is allowed; note that a
+`` holding only fragments inside the extent range still triggers
+the gather error.
+
+Necessary findings: 5 (0 major, 1 medium, 3 minor, 1 nit). Optional: 5.
+
+| Round | Findings | Main changes recommended |
+| ----- | -------- | ------------------------ |
+| 1 | 5 necessary (0 major, 1 medium, 3 minor, 1 nit), 5 optional | Say "alone in its own paragraph" instead of "alone on its line"; make the no-heading fallback say "at or before"; replace "as is" with "after cleaning" and limit the `contenteditable` cleaning rule to ``/``; add the missing tests or relax "each rule needs a test"; fix the "Errors" wording. |
+
+
+Team member: Dustin Johnson (GitHub: drj228)
+------------------------------------------
+
+### Contribution (5 points)
+
+Fixed and verified the Windows build and standalone editor, and used Claude reviews to correct the specification to define Markdown fragments, address boundary and consistency findings, and reach zero necessary corrections.
+
+### Build and run check (5 points)
+
+ChatGPT assisted with troubleshooting and reviewed the terminal output and screenshots; Dustin executed the commands on Windows.
+
+Environment: Rust 1.99.1, Cargo 1.99.1, Node.js v26.14.0, npm 11.21.3.
+
+The initial installation was blocked at the cargo-binstall bootstrap by antivirus protection. Installed cargo-nextest directly using `cargo install cargo-nextest --locked`.
+
+The build then failed when npx invoked the NAPI launcher. Switching the build helper to `pnpm exec napi build` resolved the failure (commit `65a38bf`).
+
+`cargo run --manifest-path .\builder\Cargo.toml -- build` completed successfully, including the Rust workspace, client bundles, VS Code native extension, and TypeScript checks. All 13 export_bindings tests passed on both invocations; the other 196 tests were filtered out.
+
+Started `.\target\debug\codechat-editor-standalone.exe --port 8080 serve` and verified that the browser displayed the file browser and rendered README.md in the CodeChat editor. The full test suite was not run.
+
+### Review rounds (10 points)
+
+Reviewed with Claude Opus 5.5, Medium effort, in a separate browser session.
+
+| Round | Findings | Main changes made |
+| ----- | -------- | ----------------- |
+| 1 | 7 necessary (3 major, 2 medium, 2 minor); 5 optional | Defined Markdown fragments: section and block-count boundaries, gather interactions, layout, save/reopen rules, and examples; removed the Markdown-fragment ban. |
+| 2 | 3 necessary (1 medium, 2 minor); 4 optional | Defined boundaries on HTML before hydration, explicitly listed the source-file rules being replaced, and corrected the formatted example and overlap statement. |
+| 3 | 0 necessary; 6 optional (4 carried over, 2 new) | Confirmed N1-N3 were resolved; made no further changes and left the optional suggestions unadopted. |
+
+ChatGPT prepared the targeted patch for the round 2 corrections; Dustin applied
+it locally before requesting round 3. These were specification reviews, not
+implementation verification of the proposed Markdown fragment feature.
+
+### Last review (10 points)
+
+Model: Claude Opus 5.5. Effort: Medium. Tool: Claude in a separate browser
+session. Input: the corrected `server/src/processing/cache-spec.md`.
+
+Exact prompt:
+
+```text
+Review only the corrected "Fragments in Markdown documents" section and its direct interactions with existing rules. Do not edit anything.
+
+Confirm whether N1, N2, and N3 are resolved. Report any remaining necessary corrections together. Keep optional suggestions separate and do not expand the scope.
+
+Do not claim implementation or test results. Finish with finding counts and a concise review-table summary.
+```
+
+Exact response (the reviewer numbers the rounds from 2, so its "round 3" and
+"round 4" are rounds 2 and 3 here):
+
+> N1, N2 and N3 are all resolved, and I found no new necessary corrections. This is a review only: I didn't edit anything and made no claims about implementation or tests.
+>
+> ### Status of the previous findings
+>
+> | Finding | Status | Where |
+> | -------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+> | **N1:** blocks and headings were defined partly on the Markdown and partly on the HTML | Resolved | Lines 234–243 now compute boundaries on the HTML translated from the Markdown, before cache hydration. Blocks are the root's element children, whitespace between them is ignored, and a heading is any top-level ``–``. That settles `following` counts and HTML gather headings. It also matches "depends only on the document's own source" (line 266) and "recomputed from the saved Markdown" (line 294). |
+> | **N2:** the section didn't list every existing rule it replaces | Resolved | Lines 227–230 name all five: extent, what `following` counts, what `following="0"` contains, clamping, and gather-list layout. |
+> | **N3:** two statements were wrong | Resolved | The `bt` example keeps its code formatting (line 333). The overlap statement now applies only to fragments without `following` (lines 280–281). |
+>
+> I rechecked the examples under the new HTML-based definition and they still hold:
+>
+> - A tag written alone on its own line stays a paragraph.
+> - `` is a top-level heading, so `design` contains a gather element.
+> - `following="1"` gives the heading plus `Rationale.`.
+> - `win` anchors to the whole list.
+>
+> ### Remaining necessary corrections
+>
+> None.
+>
+> ### Optional suggestions
+>
+> These four from the last review haven't been adopted and are still optional:
+>
+> - **O1:** End a default section just before a gather element as well. This avoids errors in the common layout of a section with a nested "Implementation of …" gather heading.
+> - **O2:** Add one sentence on why "text inside the tag" and "an end tag" weren't chosen.
+> - **O3:** Pin down the line number shown in a gather list (line 264) as the source line where the extent begins, even if that block is empty after cleaning.
+> - **O4:** Add an example showing that a nested heading such as `> ## Note` doesn't end a section.
+>
+> Two new ones:
+>
+> - **O5:** Line 237 covers whitespace-only text at the top level but not other stray text. A raw HTML block such as `
a
tail` leaves the text "tail" directly under the root, outside any block. One clause would close the gap, for example: "non-whitespace top-level text belongs to the preceding block."
+> - **O6:** Line 333 uses curly quotes (“…”). The rest of the spec uses straight quotes or backticks.
+>
+> **Necessary findings: 0. Optional findings: 6 (4 carried over, 2 new).**
+>
+> | Round | Findings | Main changes recommended |
+> | ----- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+> | 4 | N1–N3 from round 3 resolved; 0 necessary and 6 optional (4 carried over, 2 new). | No necessary changes. Optional: end sections before gather elements; explain why the other options weren't chosen; pin down the line number; add a nested-heading example; cover stray top-level text; use straight quotes. |