WIP: Keep structured block markers outside edited text #745

Closed
kayg wants to merge 3 commits from proto/block-identity-v7c into dev
Owner

Splitting a linked fence or table could expose hidden markers, strand duplicate syntax, or give a block the wrong text. Joining a table and an empty block could absorb the following block. Outside marker corruption could silently remove human bytes, and whole-file duplicate IDs were refused.

The format module now records explicit ranges before structural split and join operations, including unlinked and empty ranges. It owns the anchors for fences, tables, list continuations, quotes and headings, and uses the existing file map when ordinary marker placement cannot preserve those ranges. Undo combines the original ranges, and export returns to ordinary marker spelling only when reopening preserves every range and ID. Outside edits are parsed afresh; an existing owner retains its ID and pasted claims pass through normal server rekeying. The design note defines newline typing, explicit split and join, and exact marker recognition.

Validation on 863b8bf1c0:

  • Workspace formatting and clippy over all targets with -D warnings pass.
  • Workspace tests pass with one test thread. An earlier parallel run hit an unrelated fsio timestamp-based temporary-directory collision; no fsio code or test was changed.
  • Verify3: 200,000 seeds, zero failing seeds, 6,651,414 admission checks, three and five devices.
  • Verify4: 300,000 seeds, zero failures, three/five/eight devices; 100,032 / 100,032 / 99,936 seeds respectively.
  • 41/41 probes, all four fixed verify4 regressions, eight additional independent contracts, and six added structured/outside tests pass.
  • Both independent oracles, scenarios and invariants are unchanged. Verify4's driver has only narrow lint annotations and comments added for workspace clippy.

Verbatim gate logs on issue #671, continuing through comments 68310–68317. Full campaigns use release mode with LTO disabled and 16 codegen units; cargo uses -j3 inside one build-slot job.

Perf measurements remain blocked because the required 10by32-01-std host does not resolve and its Netbird SSH route timed out. No local performance substitute ran. This remains an isolated prototype; production UI, accessibility and browser UTF-16 integration are outside these checks.

Supersedes draft #743. Related issue: #671. No merge or deployment.

Splitting a linked fence or table could expose hidden markers, strand duplicate syntax, or give a block the wrong text. Joining a table and an empty block could absorb the following block. Outside marker corruption could silently remove human bytes, and whole-file duplicate IDs were refused. The format module now records explicit ranges before structural split and join operations, including unlinked and empty ranges. It owns the anchors for fences, tables, list continuations, quotes and headings, and uses the existing file map when ordinary marker placement cannot preserve those ranges. Undo combines the original ranges, and export returns to ordinary marker spelling only when reopening preserves every range and ID. Outside edits are parsed afresh; an existing owner retains its ID and pasted claims pass through normal server rekeying. The design note defines newline typing, explicit split and join, and exact marker recognition. Validation on 863b8bf1c03fa4b2e31e82e6818e2feb9b137042: - Workspace formatting and clippy over all targets with -D warnings pass. - Workspace tests pass with one test thread. An earlier parallel run hit an unrelated fsio timestamp-based temporary-directory collision; no fsio code or test was changed. - Verify3: 200,000 seeds, zero failing seeds, 6,651,414 admission checks, three and five devices. - Verify4: 300,000 seeds, zero failures, three/five/eight devices; 100,032 / 100,032 / 99,936 seeds respectively. - 41/41 probes, all four fixed verify4 regressions, eight additional independent contracts, and six added structured/outside tests pass. - Both independent oracles, scenarios and invariants are unchanged. Verify4's driver has only narrow lint annotations and comments added for workspace clippy. [Verbatim gate logs on issue #671](https://git.kayg.org/kayg/calternal/issues/671#issuecomment-68309), continuing through comments 68310–68317. Full campaigns use release mode with LTO disabled and 16 codegen units; cargo uses -j3 inside one build-slot job. Perf measurements remain blocked because the required 10by32-01-std host does not resolve and its Netbird SSH route timed out. No local performance substitute ran. This remains an isolated prototype; production UI, accessibility and browser UTF-16 integration are outside these checks. Supersedes draft #743. Related issue: #671. No merge or deployment.
Prototype block IDs in one shared text per note
Some checks failed
CI / server (pull_request) Successful in 1m0s
CI / rust (pull_request) Failing after 6m26s
CI / web (pull_request) Has been cancelled
c7d5a6cdc5
Fix native block ownership and recoverable history
Some checks failed
CI / server (pull_request) Successful in 1m14s
CI / rust (pull_request) Successful in 20m49s
CI / web (pull_request) Has been cancelled
2c3083949d
Keep structured block markers outside native split and join edits
Some checks failed
CI / server (pull_request) Successful in 1m2s
CI / rust (pull_request) Failing after 5m19s
CI / web (pull_request) Has been cancelled
863b8bf1c0
Author
Owner

Verdict: UNSOUND for prototype head 863b8bf1c0 (PR #745).

Independent verifier 5 completed 300,000 seeded sessions, seeds 0–299999: exactly 100,000 sessions each with 3, 5 and 8 real Device replicas and the real Server/Yrs implementation. 202,840 sessions failed at least one model or round-trip assertion. The two suites recorded 169,044 model first failures and 80,310 grammar/interop first failures, including 235 native UTF-8 panics. A session can fail both suites; these are session/assertion counts, not independent bug counts.

Devices Sessions Failing sessions
3 100,000 62,900
5 100,000 77,040
8 100,000 62,900

The checklist was written from origin/dev ADR 0056 B1–B5 and ADR 0018, at dev head d83e54dbe5, before reading earlier reviewer conclusions. Neither earlier generator nor oracle was read or reused. The reference model is a plain list of blocks, text, ownership and links, updated in admission order and checked after every sync. Markdown source bytes come from independently constructed grammar cases, composed inside lists and quotes, with Unicode and line-ending variants. Export/re-import and whole-file normalization use the original constructed human bytes as the oracle. Each suite stops at its first violation in a session, then the other suite and later seeds continue. Excluding additional CR-only and footnote-like grammar cases still leaves 192,097 failing sessions. Safe refusals count as failed requested round trips and are distinguished from corruption; the verdict also follows from the model failures alone.

Eight small failing reproductions are in the harness:

  • An offline edit admitted before deletion survives as Xsecond in the next block. The reverse admission-order control passes. This violates B2.
  • Moving first to another note, then receiving its offline append, makes its original link target Xsecond instead of firstX.
  • Cached Unicode typing writes into a neighboring block even before sync.
  • Linking a quoted fenced block exposes the marker in the visible projection.
  • A linked ASCII setext heading exports successfully but re-imports with an empty visible target.
  • A related emoji setext import panics at text.rs:101 on a non-scalar byte boundary.
  • CR line endings cause literal code text ^literal to be stripped. This is additional CommonMark coverage.
  • Normalizing an exported setext map from CRLF to LF is safely refused as a stale map. This is an interoperability failure, not evidence of silent data loss.

Nine small controls pass, including ordinary/task copies, join primary/alias behavior, splits, offline collision rekeying, invalid proposal rekeying, legacy note-local IDs, outside duplicate preservation, retirement/undo and ASCII typing. The prototype is not wired to the app UI; visible-projection checks do not certify rendered source editing, search, clipboard or accessibility.

Keystroke p95: BLOCKED / UNMEASURED. origin/dev p95 = unavailable; prototype p95 = unavailable; added p95 = unavailable. The requested perf-test-03.vpn.kayg.org does not resolve and is absent from the peer list. NetBird SSH and ordinary SSH to the permitted 10by32-01-std fallback at 10.69.69.73 time out. Retries had the same result. The 10,000-line / 500-linked-block benchmark could not run; the <=1 ms gate is not passed. No local or production timing was substituted. Source inspection separately shows that ^, backtick, ~, | and Enter bypass the cache and eagerly copy/parse the full note per block, so ordinary-letter-only timing would miss that path.

Harness pushed to test/ids-verify5, head fcf99a0a48779a1eba49d82229c567fa47441296. The commit contains only five test source files; no evidence or artifacts were committed.

Checklist and findings, complete gate output, raw per-seed reports, summary and runner. Evidence archive SHA256: 0042bf23a490ed4cf16dd82cc57280586e7031ec529f06f62906fa1e23232b06.

Gate output, verbatim:

build_exit=0
regressions_exit=101
clippy_exit=0
shard0_exit=101
VERIFY5 runs=100000 seed_start=0 devices=3,5,8 failed_runs=67619 model_failures=56361 grammar_failures=26770 categories={"grammar:invalid": 704, "grammar:link-text": 16985, "grammar:literal-projection": 1365, "grammar:outside-bytes": 585, "grammar:outside-normalize": 1170, "grammar:panic": 79, "grammar:reimport-owner": 312, "grammar:stale": 5570, "model:model-text": 56361}
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1288.62s
shard1_exit=101
VERIFY5 runs=100000 seed_start=100000 devices=3,5,8 failed_runs=67616 model_failures=56345 grammar_failures=26770 categories={"grammar:invalid": 705, "grammar:link-text": 16985, "grammar:literal-projection": 1365, "grammar:outside-bytes": 585, "grammar:outside-normalize": 1170, "grammar:panic": 78, "grammar:reimport-owner": 312, "grammar:stale": 5570, "model:model-text": 56345}
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1287.19s
shard2_exit=101
VERIFY5 runs=100000 seed_start=200000 devices=3,5,8 failed_runs=67605 model_failures=56338 grammar_failures=26770 categories={"grammar:invalid": 705, "grammar:link-text": 16985, "grammar:literal-projection": 1365, "grammar:outside-bytes": 585, "grammar:outside-normalize": 1170, "grammar:panic": 78, "grammar:reimport-owner": 312, "grammar:stale": 5570, "model:model-text": 56338}
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1295.37s
build_exit=0
regressions_exit=101
clippy_exit=0
contracts_exit=101
contracts_clippy_exit=0
fmt_exit=0
test result: FAILED. 5 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Reproduce a seed on the harness branch:

source /etc/calternal/env.sh
/usr/local/bin/build-slot.sh env VERIFY5_SEED=1 VERIFY5_RUNS=1 cargo test -p calternal-block-ids --release -j3 --test verify5 -- --nocapture
Verdict: UNSOUND for prototype head 863b8bf1c03fa4b2e31e82e6818e2feb9b137042 (PR #745). Independent verifier 5 completed 300,000 seeded sessions, seeds 0–299999: exactly 100,000 sessions each with 3, 5 and 8 real Device replicas and the real Server/Yrs implementation. 202,840 sessions failed at least one model or round-trip assertion. The two suites recorded 169,044 model first failures and 80,310 grammar/interop first failures, including 235 native UTF-8 panics. A session can fail both suites; these are session/assertion counts, not independent bug counts. | Devices | Sessions | Failing sessions | | --- | ---: | ---: | | 3 | 100,000 | 62,900 | | 5 | 100,000 | 77,040 | | 8 | 100,000 | 62,900 | The checklist was written from origin/dev ADR 0056 B1–B5 and ADR 0018, at dev head d83e54dbe571b625504001a8b6add90d44ca6161, before reading earlier reviewer conclusions. Neither earlier generator nor oracle was read or reused. The reference model is a plain list of blocks, text, ownership and links, updated in admission order and checked after every sync. Markdown source bytes come from independently constructed grammar cases, composed inside lists and quotes, with Unicode and line-ending variants. Export/re-import and whole-file normalization use the original constructed human bytes as the oracle. Each suite stops at its first violation in a session, then the other suite and later seeds continue. Excluding additional CR-only and footnote-like grammar cases still leaves 192,097 failing sessions. Safe refusals count as failed requested round trips and are distinguished from corruption; the verdict also follows from the model failures alone. Eight small failing reproductions are in the harness: - An offline edit admitted before deletion survives as `Xsecond` in the next block. The reverse admission-order control passes. This violates B2. - Moving `first` to another note, then receiving its offline append, makes its original link target `Xsecond` instead of `firstX`. - Cached Unicode typing writes into a neighboring block even before sync. - Linking a quoted fenced block exposes the marker in the visible projection. - A linked ASCII setext heading exports successfully but re-imports with an empty visible target. - A related emoji setext import panics at text.rs:101 on a non-scalar byte boundary. - CR line endings cause literal code text ` ^literal` to be stripped. This is additional CommonMark coverage. - Normalizing an exported setext map from CRLF to LF is safely refused as a stale map. This is an interoperability failure, not evidence of silent data loss. Nine small controls pass, including ordinary/task copies, join primary/alias behavior, splits, offline collision rekeying, invalid proposal rekeying, legacy note-local IDs, outside duplicate preservation, retirement/undo and ASCII typing. The prototype is not wired to the app UI; visible-projection checks do not certify rendered source editing, search, clipboard or accessibility. Keystroke p95: BLOCKED / UNMEASURED. origin/dev p95 = unavailable; prototype p95 = unavailable; added p95 = unavailable. The requested perf-test-03.vpn.kayg.org does not resolve and is absent from the peer list. NetBird SSH and ordinary SSH to the permitted 10by32-01-std fallback at 10.69.69.73 time out. Retries had the same result. The 10,000-line / 500-linked-block benchmark could not run; the <=1 ms gate is not passed. No local or production timing was substituted. Source inspection separately shows that `^`, backtick, `~`, `|` and Enter bypass the cache and eagerly copy/parse the full note per block, so ordinary-letter-only timing would miss that path. Harness pushed to test/ids-verify5, head [fcf99a0a48779a1eba49d82229c567fa47441296](https://git.kayg.org/kayg/calternal/commit/fcf99a0a48779a1eba49d82229c567fa47441296). The commit contains only five test source files; no evidence or artifacts were committed. [Checklist and findings](https://git.kayg.org/attachments/6fb7ffa9-0437-4372-bde7-90f9ffd79c80), [complete gate output](https://git.kayg.org/attachments/646cb140-0964-4469-b6b1-1371743cf7c9), [raw per-seed reports, summary and runner](https://git.kayg.org/attachments/5c41bd4e-8046-41f7-b350-4e10f7cacb3f). Evidence archive SHA256: `0042bf23a490ed4cf16dd82cc57280586e7031ec529f06f62906fa1e23232b06`. Gate output, verbatim: ```text build_exit=0 regressions_exit=101 clippy_exit=0 shard0_exit=101 VERIFY5 runs=100000 seed_start=0 devices=3,5,8 failed_runs=67619 model_failures=56361 grammar_failures=26770 categories={"grammar:invalid": 704, "grammar:link-text": 16985, "grammar:literal-projection": 1365, "grammar:outside-bytes": 585, "grammar:outside-normalize": 1170, "grammar:panic": 79, "grammar:reimport-owner": 312, "grammar:stale": 5570, "model:model-text": 56361} test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1288.62s shard1_exit=101 VERIFY5 runs=100000 seed_start=100000 devices=3,5,8 failed_runs=67616 model_failures=56345 grammar_failures=26770 categories={"grammar:invalid": 705, "grammar:link-text": 16985, "grammar:literal-projection": 1365, "grammar:outside-bytes": 585, "grammar:outside-normalize": 1170, "grammar:panic": 78, "grammar:reimport-owner": 312, "grammar:stale": 5570, "model:model-text": 56345} test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1287.19s shard2_exit=101 VERIFY5 runs=100000 seed_start=200000 devices=3,5,8 failed_runs=67605 model_failures=56338 grammar_failures=26770 categories={"grammar:invalid": 705, "grammar:link-text": 16985, "grammar:literal-projection": 1365, "grammar:outside-bytes": 585, "grammar:outside-normalize": 1170, "grammar:panic": 78, "grammar:reimport-owner": 312, "grammar:stale": 5570, "model:model-text": 56338} test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1295.37s build_exit=0 regressions_exit=101 clippy_exit=0 contracts_exit=101 contracts_clippy_exit=0 fmt_exit=0 test result: FAILED. 5 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ``` Reproduce a seed on the harness branch: ```sh source /etc/calternal/env.sh /usr/local/bin/build-slot.sh env VERIFY5_SEED=1 VERIFY5_RUNS=1 cargo test -p calternal-block-ids --release -j3 --test verify5 -- --nocapture ```
Author
Owner

Closing: superseded by #758 (named in the PR body or comments). Branch kept.

Closing: superseded by #758 (named in the PR body or comments). Branch kept.
kayg closed this pull request 2026-11-04 13:04:35 +00:00
Some checks failed
CI / server (pull_request) Successful in 1m2s
CI / rust (pull_request) Failing after 5m19s
CI / web (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!745
No description provided.