Skip to content

Delete the #if TELEMETRY lock-history, add the LOG-02 gate, fix doc/ drift - #598

Merged
nockawa merged 3 commits into
mainfrom
doc-update
Jul 29, 2026
Merged

nockawa merged 3 commits into
mainfrom
doc-update

Conversation

@nockawa

@nockawa nockawa commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Code-side half of the doc-integrity initiative. Pairs with Log2n-io/Typhon-Claude#63.

60417e2 — delete the #if TELEMETRY lock-history

AccessControl.Telemetry.cs and AccessOperation.cs recorded a per-latch operation history: 18-byte packed records, six to a 128-byte block, chained per lock, with a ToDebugString dump for post-mortem. The purpose was real — troubleshooting and deadlock forensics.

Three findings say delete, not "convert it to the static readonly bool gate pattern":

  1. It never compiled, in any configuration. TELEMETRY is defined in zero csproj, props and slnx files. And it referenced OperationsBlockIdMask / OperationsBlockIdShift, which have no definition anywhere in src/ — the lock word documents 13 Reserved (bits 49-61) where they were meant to live, and those bits were never allocated. It would not compile even with the symbol on. Never-compiled code is unverified, not dormant.
  2. It was orphaned. The file declared internal static partial class AccessControlImpl. That identifier has zero other occurrences; the real type is internal partial struct AccessControl. The partial had no other half.
  3. The purpose already shipped, in the very change that deleted its predecessor. Tracing Instrumentation Phase 2 — Concurrency tracing #280 Phase 2 landed 27 event kinds (90–116) across AccessControl, AccessControlSmall, ResourceAccessControl, Epoch, AdaptiveWaiter, OlcLatch — per-leaf gates, JIT-folded when off, config-driven, in the capture file, decoded by the Workbench. Nine of the ten old OperationType values have coverage there.

Converting would mean rewriting, and would run a second recording mechanism for operations the global per-thread ring already captures — with worse correlation (no spans, systems, ticks), no viewer, and an unconditional ~8 MB static allocator.

What's genuinely missing is one field, and the code says so: TraceEventKind.cs notes that restoring per-resource contention metrics needs "a per-lock id field added to the wire format". Filed as #594 → #595/#596/#597.

Also here: the three dead // AddWaitOperation(...) comments; DurabilityOverride (a public enum whose only repo-wide occurrence was its own declaration); and DagScheduler's class comment, which claimed workers use a three-phase Sleep/Yield/Spin wait — they block on a ManualResetEventSlim(spinCount: 0). That comment contradicted itself two paragraphs apart, and overview/13-runtime.md had inherited the error from it, so fixing only the doc would have left the source that re-infects the next writer.

Suite green: 4054 passed, 0 failed, 51 skipped.

c17f5f4 — the LOG-02 grep gate (#593)

Docs claimed RecordCodec exclusivity was "grep-gated". No such check existed in any of the 12 workflows.

The real invariant isn't greppable — you can't pattern-match "writes bytes". But anyone hand-rolling a record needs the byte offsets, and those live in one type, so referencing RecordFormat outside Durability/internals/ is a necessary precondition of the violation. A cheap proxy that's green beats an exact check nobody writes. Verified green before adding — this locks in a property that holds rather than announcing an aspiration.

Deliberately self-contained: no secret, no cross-repo checkout, so it works on fork PRs. An earlier revision also ran the claude/ doc-drift lint here, which needed a PAT for the private knowledge base — GitHub withholds secrets from fork-originated pull_request runs, so that would have red-lit every outside contribution (this repo has 18 forks and has taken one fork PR), and a PAT in a public repo's CI is a capability anyone with push access could use. That check now runs the other way round, in the private repo pulling this public one, needing no credential.

6f08c06 — doc/ drift + the thread-ID standard [no-ut] [no-doc]

Two in-depth-overview pages described AccessControl.Telemetry.cs as a "mid-migration partial still using #if TELEMETRY" — deleted in this PR.

CLAUDE.md said thread IDs "must use exactly 16 bits (max 65,535)". The field is 16 bits in all three primitives; the usable range is not — AccessControlSmall packs the id into bits 16-31 of a signed int, so 32,768+ sets the sign bit and LockedByThreadId sign-extends. AccessControlSmall.cs:22-29 documents this as a deliberate bound. The code was right and reasoned; the standard's wording was wrong. Now states the 32,767 simultaneously-live-thread ceiling and why the compact variant binds tightest.

Review order

60417e2 is the only commit that can break the build, and it's the smallest — two deletions and three comment fixes. The other two are YAML and markdown.

@nockawa nockawa closed this Jul 29, 2026
@nockawa nockawa reopened this Jul 29, 2026
nockawa and others added 2 commits July 29, 2026 02:51
…guration

AccessControl.Telemetry.cs and AccessOperation.cs recorded a per-latch operation history — 18-byte packed records (lock-word snapshot, timestamp, operation type, thread id), six to a 128-byte block, chained per lock, with a ToDebugString dump for post-mortem. The purpose was real: troubleshooting and deadlock forensics.

Three findings say delete rather than convert:

The TELEMETRY symbol is defined in zero csproj, props and slnx files, so this never compiled in any configuration. It also referenced OperationsBlockIdMask and OperationsBlockIdShift, which have no definition anywhere in src/ — the lock word documents "13 Reserved (bits 49-61)" where they were meant to live, and those bits were never allocated. It could not have compiled even with the symbol on. Never-compiled code is unverified, not dormant.

The file declared "internal static partial class AccessControlImpl". That identifier has zero other occurrences in the codebase; the real type is "internal partial struct AccessControl". The partial had no other half. This is an abandoned mid-refactor sketch.

The purpose already shipped, in the very change that deleted its predecessor. #280 Phase 2 landed 27 concurrency event kinds (90-116) across AccessControl, AccessControlSmall, ResourceAccessControl, Epoch, AdaptiveWaiter and OlcLatch — gated per-leaf, JIT-folded to nothing when off, config-driven with no separate build, written to the capture file, and decoded and named by the Workbench. Nine of the ten old OperationType values have coverage there.

Converting the old code to the static-readonly-bool pattern would mean rewriting it, not un-#if-ing it, and would run a second recording mechanism for operations the global per-thread ring already records — with worse correlation (no spans, systems or ticks) and no viewer. It would also reintroduce an unconditional ~8 MB static ChainedBlockAllocator.

What is genuinely missing is one field, and the code already says so: TraceEventKind.cs notes that restoring per-resource contention metrics needs "a per-lock id field added to the wire format". Without it the events cannot answer which latch, which is why no Workbench lock-contention view exists — there is nothing to group by. Also missing: no timeout/cancel event is emitted (AccessControl.LockData.cs:256 still carries the commented-out call), and the sticky WasContended bit is read by nothing in production code. Those are follow-ups against the shipped pipeline, not reasons to revive this file.

Also removed here: the three dead "// AddWaitOperation(OperationType....)" call-site comments left behind in AccessControl.LockData.cs, and DurabilityOverride — a public enum whose only occurrence repo-wide was its own declaration.

DagScheduler's class comment claimed workers use a three-phase Sleep/Yield/Spin wait referencing _nextTickTimestamp. They block on _tickStartSignal, a ManualResetEventSlim(false, spinCount: 0), in a _tickGeneration loop with a 50 ms shutdown-liveness timeout. _nextTickTimestamp is metronome state read by GetNextTick, never by a worker. The comment contradicted itself two paragraphs apart — its first paragraph correctly attributes the three-phase wait to HighResolutionTimerServiceBase. overview/13-runtime.md had inherited the error from this comment, so fixing the doc alone would have left the source that re-infects the next writer.

TelemetryToggleBenchmark's comments no longer reference a symbol that does not exist. The benchmark itself stays — it is the evidence behind ADR-019 and still measures the gate mechanisms in use.

Full suite green: 4054 passed, 0 failed, 51 skipped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013naUkUcmNUnouqP75WLjR6
…ility/internals/

overview/06-durability.md and rule LOG-02 both claimed RecordCodec exclusivity was "grep-gated". Verified 2026-07-28: no such check existed in any of the 12 workflows. Only §7.1 of the design — storage-layer identifier names — was ever built; §7.2, confining record byte access to Durability/internals/, was not. A documented enforcement that does not exist is worse than an acknowledged convention, because it stops people checking.

The real invariant ("WAL record bytes are written only by RecordCodec") is not greppable — you cannot pattern-match "writes bytes". But anyone hand-rolling a record needs the byte offsets, and those live in exactly one type, so referencing RecordFormat outside Durability/internals/ is a necessary precondition of the violation. A cheap proxy that is green beats an exact check nobody writes.

Verified green before adding: this locks in a property that currently holds rather than announcing an aspiration.

Free ubuntu runner, does not consume the c6id. Wired into the aggregate gate's needs and verdict. Deliberately self-contained — no secret, no cross-repo checkout, nothing but this repo's own source, so it works on fork PRs. An earlier revision of this job also ran the claude/ doc-drift lint here, which needed a PAT for the private knowledge base; GitHub withholds secrets from fork-originated pull_request runs, so that would have red-lit every outside contribution, and a PAT in a public repo's CI is a capability anyone with push access could use. That check now runs the other way round, in the private repo pulling this public one, needing no credential.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013naUkUcmNUnouqP75WLjR6
@nockawa
nockawa force-pushed the doc-update branch 2 times, most recently from aeca2c0 to 5351858 Compare July 29, 2026 00:55
…ead-ID standard [no-doc]

doc/ corrections from the same audit that produced the claude/ work:

in-depth-overview/01-foundation.md and 12-observability.md both described AccessControl.Telemetry.cs as a mid-migration partial "still using #if TELEMETRY". That file is deleted in this batch — the symbol was defined in no build configuration, so it never compiled, and it referenced two constants with no definition anywhere in src/. Both references removed; what remains is the TyphonEvent.Emit* pattern every concurrency primitive actually uses.

The CLAUDE.md thread-ID standard said IDs "must use exactly 16 bits (max 65,535)" for consistency across AccessControl, AccessControlSmall and ResourceAccessControl. The field width is 16 bits in all three, but the usable range is not: AccessControlSmall packs the id into bits 16-31 of a signed int, so 32,768+ sets the sign bit and LockedByThreadId sign-extends. AccessControlSmall.cs:22-29 documents this as a deliberate accepted bound. The code was right and reasoned; the standard's wording was wrong. Now states the 32,767 simultaneously-live-thread ceiling and why the compact variant binds tightest. Also recorded as rule CX-05 in the knowledge base.

Skip token: no-doc only - this commit fixes drift the audit already flagged. The unit-test skip token is deliberately absent: it is read from the PR HEAD commit, so tagging a docs-only commit skips the engine suite for the WHOLE PR, and this PR deletes engine code. Note the detector greps the entire message, so even naming that token in prose trips it - which is how the first two attempts here silently skipped the suite. Brackets omitted above for the same reason.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013naUkUcmNUnouqP75WLjR6
@nockawa
nockawa merged commit 81e2a46 into main Jul 29, 2026
11 checks passed
nockawa added a commit that referenced this pull request Jul 29, 2026
…ped, files issues [no-doc] [no-ut]

Loïc's argument, which I initially pushed back on and was wrong to:

  1. Nothing required the check and nothing blocked on it, so a PR could merge while the review was still running. The findings then landed on a closed PR nobody revisits - the per-PR TIMING bought nothing anyone could act on.
  2. Reconciling docs is a different job from writing the feature, and the author is the worst reviewer of prose they wrote ten minutes ago and believe.

My earlier objection - "post-merge it degrades into a corpus audit, which Layer 3 already does" - was only true of a WHOLE-CORPUS post-merge run. Scoped to yesterday's merges it keeps the diff-to-page association that is the only thing making Layer 2 worth more than an audit. That is the mistake; this commit fixes it.

What changed:

- doc-accuracy-review.yml is now nightly (05:00 UTC, an hour before the Monday Layer-3 audit so the weekly sweep dedups against whatever the nightly just filed). It lists the PRs merged in the last 25 h, resolves each one's affected doc pages, reviews them, and FILES [doc-drift] ISSUES rather than commenting on a merged PR. Every issue must carry "Introduced by: #N" - that attribution is precisely what a whole-corpus sweep cannot produce.
- Fork PRs are no longer a special case. The old per-PR job had to skip them (no secrets, injection surface); a scheduled job cannot receive one, so fork-introduced drift is now covered like everything else instead of being deferred to Layer 3.
- CONTRIB.md: [no-doc] is retired. It existed to break the fix -> re-review -> fix loop, which was a workaround for a cadence that was wrong to begin with. Harmless if anyone still writes it.

Two things testing found before this could ship, both real:

- Unioning the PRs' file lists resolved to 227 affected pages against a 329-file corpus - a whole-corpus sweep wearing a scoped costume, i.e. exactly what I had just argued against. Now resolved PER PR (measured on the same night: #598 -> 86 pages, #586 -> 226, #570 -> 0), which also keeps the "Introduced by" attribution honest since each page list has one PR behind it.
- One big PR can alone resolve to ~230 pages, so a ten-PR night would exhaust the turn budget and produce a shallow skim of everything instead of a real review of something. Capped at the 5 most recent, with a ::warning:: and a line in the prompt naming the overflow - a silently truncated sweep reads exactly like a clean one, which is the failure mode this layer exists to avoid. The remainder falls to Layer 3.

Also rejected, and recorded in the workflow header so it is not re-proposed: an opt-in [doc-review] token, and reviewing only when a draft PR is marked ready. Both fail UNSAFE when someone forgets - no review at all, or only commit 1 reviewed. Loïc made this argument against [doc-review] and it applies equally to the draft-based design I had already written. This one has nothing to remember.

The scope step was extracted from the YAML and executed against the live repo end to end (PR listing, per-PR diff, docs-affected resolution, output gating) - heredoc-inside-block-scalar is where this class of workflow usually breaks.

Layer 1 (scripts/check-doc-links.py, blocking, ~0.5 s) still runs on every push. Layer 3 (weekly whole-corpus) is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs
@nockawa
nockawa deleted the doc-update branch July 31, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant