Skip to content

memory: threading code follows Albahari + Toub + Fowler human lineage — never gut-instinct (Aaron 2026-04-28)#669

Merged
AceHack merged 1 commit intomainfrom
memory/threading-lineage-albahari-toub-fowler-2026-04-28
Apr 28, 2026
Merged

memory: threading code follows Albahari + Toub + Fowler human lineage — never gut-instinct (Aaron 2026-04-28)#669
AceHack merged 1 commit intomainfrom
memory/threading-lineage-albahari-toub-fowler-2026-04-28

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented Apr 28, 2026

Aaron's binding directive 2026-04-28T16:48Z: any Zeta threading / TPL / async / parallel code MUST cite Joseph Albahari (patterns), Stephen Toub (Microsoft .NET perf), or David Fowler (System.Threading.Channels). High-perf, low-alloc, thread-safe, prefer wait/lock-free. "make sure future you's know this too."

Three landings:

  1. New memory file with full rule + 3-source breakdown + operational discipline.
  2. MEMORY.md index entry (loads at session bootstrap).
  3. CURRENT-aaron.md §29 distillation; refresh marker bumped to 26-29.

Composes with: speculation-rule (don't assert from gut), Otto-247 (version-currency / WebSearch first), Otto-347 (cross-CLI verify), future Zeta operator-algebra parallelization work.

🤖 Generated with Claude Code

…stinct on threading (Aaron 2026-04-28)

Aaron's binding directive 2026-04-28T16:48Z + 16:48Z follow-up:

> "please follow this guidance around threading unless you find
> something better from stephen toub from Microsoft, don't go based
> on gut instanct for any threading code it's very hard.  this is
> our human lineage to threading best proacties joseph and setephen.
> ...  Oh and David Fowler, he wrote channels in dotnet, these hare
> our high performance low allocation thread safe prefer wait/lock
> free guides."
> "make sure future you's know this too"

The three-source human lineage for any Zeta threading / TPL / async
/ parallel code:

1. Joseph Albahari — "Threading in C#" (free ebook) + "C# in a
   Nutshell" concurrency chapters. Foundational patterns + idioms.
2. Stephen Toub (Microsoft) — yearly "Performance Improvements in
   .NET" + async/parallel deep dives on devblogs.microsoft.com.
3. David Fowler (Microsoft) — authored System.Threading.Channels;
   high-perf low-alloc producer/consumer + backpressure patterns.

Lands in three places:

1. memory/feedback_threading_human_lineage_albahari_toub_fowler_no_gut_instinct_aaron_2026_04_28.md
   — full rule + the three-source breakdown + what's excluded
   (hand-rolled lock-free, gut-instinct async, custom queues when
   Channels exists) + operational discipline (cite specific
   reference in commit/comment, default to wait/lock-free, verify
   currency, cross-CLI verify for non-trivial code) + Zeta-specific
   relevance (Z-set operator pipeline parallelization).
2. memory/MEMORY.md — index entry near top so future-Otto loads it
   at session bootstrap.
3. memory/CURRENT-aaron.md §29 — distillation in the canonical
   maintainer-projection file. Refresh-marker bumped to 26-29.

Aaron's framing "make sure future you's know this too" — the
durability requirement is binding. This memory is now load-bearing
for any threading work going forward.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 28, 2026 16:53
@AceHack AceHack enabled auto-merge (squash) April 28, 2026 16:53
@AceHack AceHack merged commit 6a8d0bd into main Apr 28, 2026
27 checks passed
@AceHack AceHack deleted the memory/threading-lineage-albahari-toub-fowler-2026-04-28 branch April 28, 2026 16:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new durable “threading lineage” memory so future threading/TPL/async work is grounded in established .NET guidance (Albahari/Toub/Fowler) rather than ad-hoc intuition, and surfaces it in the main memory index + current Aaron distillation.

Changes:

  • Added a new memory/feedback_*.md rule capturing the threading/TPL lineage + operational discipline.
  • Added a new top-of-index entry in memory/MEMORY.md for bootstrap visibility.
  • Added §29 to memory/CURRENT-aaron.md and bumped the refresh marker to include sections 26–29.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
memory/feedback_threading_human_lineage_albahari_toub_fowler_no_gut_instinct_aaron_2026_04_28.md New memory file documenting the threading/TPL “human lineage” rule and how to apply it.
memory/MEMORY.md Adds the index entry so the rule is discoverable at session bootstrap.
memory/CURRENT-aaron.md Distills the new rule into the current “in force” projection as §29 and updates refresh metadata.

Comment thread memory/MEMORY.md
Comment thread memory/MEMORY.md
AceHack added a commit that referenced this pull request Apr 28, 2026
… — Copilot P1 on PR #669 (#670)

* fix(memory-index): refresh Fast-path marker + tighten threading entry — Copilot P1 on PR #669

Two valid Copilot findings on PR #669 (post-merge):

1. The "Fast path" header still cited "CURRENT-aaron.md refreshed
   2026-04-25 (sections 18-22)" but PR #669 added §29 (and §§26-28
   were added earlier today). Updated to "refreshed 2026-04-28
   sections 26-29 — speculation rule + EVIDENCE-BASED labeling +
   JVM preference + dependency honesty + threading lineage."

2. Threading entry was verbose. Tightened from ~330 chars to ~250
   chars while preserving the load-bearing summary (3-source lineage
   + wait/lock-free preference) per `memory/README.md` cap.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(memory-index): match canonical 'wait-free / lock-free' phrasing — Copilot P2 on PR #670

Pedantic-but-valid: index entry used 'wait/lock-free' shorthand, the
linked memory body uses 'wait-free / lock-free'. Aligned for consistency.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
AceHack added a commit that referenced this pull request Apr 28, 2026
… + C# 14 (#672)

* research: absorb Gemini Pro Deep Research threading guide for .NET 10 + C# 14

Aaron deposited Gemini Pro Deep Research's modernization of Joseph
Albahari's classic "Threading in C#" book against the .NET 10 +
C# 14 release window — landed as both .docx and .md in drop/ at
2026-04-28T17:11Z.

Absorbed per drop/README.md protocol:
1. .md content lands at docs/research/2026-04-28-gemini-pro-deep-
   research-threading-net10-csharp14-modernization.md with §33
   archive header (Scope / Attribution / Operational status:
   research-grade / Non-fusion disclaimer).
2. drop/Updating Threading Guide for .NET.{docx,md} deleted
   (gitignored anyway; tracked artifact is the permanent record).
3. memory/feedback_threading_human_lineage_albahari_toub_fowler_*
   (PR #669) gets a new "Modern .NET 10 + C# 14 update" section
   pointing at the absorbed research note + summarizing the key
   updates that supersede / extend Albahari's classic patterns.

Key modernizations Gemini surfaces (full detail in the research
note):

- System.Threading.Lock (C# 13/14) replaces Monitor-based
  lock(object) — EnterScope() returns a stack-allocated ref struct,
  zero GC overhead. Compiler warns if you cast to object (degrades
  to Monitor).
- Thread Pool segregation (Worker threads vs I/O Completion
  threads); never spawn raw Thread per request.
- JIT deabstraction + delegate stack allocation in .NET 10 — escape
  analysis can stack-allocate closures + delegates.
- CancellationToken replaces Thread.Abort (cooperative shutdown).
- SemaphoreSlim(1,1) replaces ReaderWriterLockSlim for async-safe
  locking (RWLockSlim is thread-affine; throws across await).
- System.Threading.Channels (Fowler's primitive) replaces
  Monitor.Wait/Pulse for producer/consumer pipelines.

Read the full research note for deep-dives on async state machine
mechanics, ValueTask/IAsyncEnumerable, hardware-accelerated
parallel processing, and modern memory model semantics.

Future-Otto: verify currency on each pattern when adopting
(Otto-247) — .NET evolves recommended patterns each release;
Toub's yearly "Performance Improvements in .NET N" posts are the
canonical empirical record.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(memory-index): paired-edit — add Gemini absorb pointer to threading entry

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(threading-memory): SemaphoreSlim caveat + tighten Lock wording — Codex/Copilot P2 on PR #672

Two wording issues caught by Codex + Copilot post-merge review:

1. SemaphoreSlim(1,1) is NOT a 1:1 RWLockSlim replacement —
   it's a single-entry mutex, loses RWLockSlim's reader/writer
   concurrency. Added caveat: use for cross-await serialization
   regardless of read/write; for high-read async-safe RWLock
   semantics use immutable snapshots, channel-bounded mutation,
   or copy-on-write.

2. Lock entry wording was too sweeping ('replaces Monitor-based
   lock(object)' read as universal). Tightened to 'prefer for new
   code; existing lock(object) patterns continue via Monitor.'
   Also clarified the cast-to-object warning is at compile time +
   silently degrades.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
AceHack added a commit that referenced this pull request Apr 28, 2026
…as primary source + Lock worked example (Aaron 2026-04-28)

Four-source canonical reference (was three-source per yesterday's
PR #669 substrate landing):

1. **Microsoft Learn — Advanced .NET programming hub**
   (https://learn.microsoft.com/en-us/dotnet/navigate/advanced-programming/)
   — first place to look. .NET-10-current canonical reference.
   Replaces some older Albahari chapter content.
2. **Joseph Albahari — Threading in C#** (2011, foundational, "still
   very good but old" per Aaron). Use for foundational understanding;
   cross-check against MS Learn before applying to .NET 10 / C# 13+ code.
3. **Stephen Toub** (Microsoft .NET runtime team) — perf + async deep
   dives.
4. **David Fowler** (Microsoft, Channels) — high-perf low-allocation
   patterns.

Aaron's input (verbatim):

- 17:43Z: "offical reference documentation for advanced dotnet from
  Microsoft the creators of dotnet [URL] ... replaces some guidance
  from J[oseph]" + "Joseph with newer guidance for .NET 10  Joseph
  is from 2011 but still very good but old"
- 17:46Z: "Like I know there is a real Lock object now instead of
  just a regular object, the monitor changed in .NET 10 i think"
- 17:51Z: "that document you pull from drop from gemini try to
  create modern guidance that is still in line with albamari"

## Worked example: System.Threading.Lock

Adds a primary-source-verified worked example showing the exact
shape of "Albahari old vs MS-Learn current":

- System.Threading.Lock landed in **.NET 9 / C# 13** (Aaron recalled
  .NET 10 — the type IS available throughout .NET 10 since it's the
  current LTS). Verified via `microsoft_docs_search` 17:48Z citing:
  - whats-new/csharp-13#new-lock-object
  - language-reference/statements/lock
  - code-analysis/style-rules/ide0330 (analyzer enforces this)
  - csharp-13.0/lock-object (proposal/spec)
- The C# `lock` statement specializes on `Lock`: `lock (x) { ... }`
  lowers to `using (x.EnterScope()) { ... }` (ref struct Dispose
  pattern) instead of `Monitor.Enter/Exit`. Monitor remains the
  fallback for plain reference-type targets.
- IDE0330 analyzer (default true) flags `private object _gate = new
  object();` and offers `private Lock _gate = new Lock();` as fix.
- CS9216 warns on cast-to-other-type (loses specialization).
- CS9217 errors on `lock (Lock)` inside `async` methods (await can't
  cross a Lock scope).

Aaron's 2011 Albahari guidance (lock-on-private-object) is still
correct in pre-.NET-9 codebases but is **no longer** the .NET-10
recommendation for new code. This worked example is the canonical
shape of the lineage-update pattern.

## Gemini absorb pointer

Adds a pointer to docs/research/2026-04-28-gemini-pro-deep-research-
threading-net10-csharp14-modernization.md (absorbed via PR #672)
as a worked example of "modern .NET 10 / C# 14 guidance still in
line with Albahari" — Gemini's doc walks Albahari's topic-set and
updates each to current idiom while preserving his pattern-orientation.

Updates CURRENT-aaron.md §29 to match the 4-source lineage with
the same MS Learn precedence.

Composes with:
- feedback_speculation_leads_investigation_not_defines_root_cause_aaron_2026_04_28.md
  (primary-source-first; the .NET-10 vs .NET-9 detail Aaron recalled
  was speculation; verified 30s via microsoft_docs_search)
- Otto-247 version-currency (training-data is stale; always WebSearch
  / docs-search before asserting versions)
- PR #672 (Gemini absorb document)

EVIDENCE-BASED labels:
- System.Threading.Lock first-shipped version: VERIFIED via
  microsoft_docs_search 17:48Z. Result: .NET 9 / C# 13. Aaron's
  recollection of .NET 10 was directionally right (type available
  in current LTS) but version-imprecise (introduced earlier).
- IDE0330 analyzer rule: VERIFIED via doc URL.
- CS9216 / CS9217 diagnostics: VERIFIED via compiler-messages docs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
AceHack added a commit that referenced this pull request Apr 28, 2026
…source + Lock worked example (Aaron 2026-04-28) (#673)

* substrate(threading-lineage): add Microsoft Learn advanced .NET docs as primary source + Lock worked example (Aaron 2026-04-28)

Four-source canonical reference (was three-source per yesterday's
PR #669 substrate landing):

1. **Microsoft Learn — Advanced .NET programming hub**
   (https://learn.microsoft.com/en-us/dotnet/navigate/advanced-programming/)
   — first place to look. .NET-10-current canonical reference.
   Replaces some older Albahari chapter content.
2. **Joseph Albahari — Threading in C#** (2011, foundational, "still
   very good but old" per Aaron). Use for foundational understanding;
   cross-check against MS Learn before applying to .NET 10 / C# 13+ code.
3. **Stephen Toub** (Microsoft .NET runtime team) — perf + async deep
   dives.
4. **David Fowler** (Microsoft, Channels) — high-perf low-allocation
   patterns.

Aaron's input (verbatim):

- 17:43Z: "offical reference documentation for advanced dotnet from
  Microsoft the creators of dotnet [URL] ... replaces some guidance
  from J[oseph]" + "Joseph with newer guidance for .NET 10  Joseph
  is from 2011 but still very good but old"
- 17:46Z: "Like I know there is a real Lock object now instead of
  just a regular object, the monitor changed in .NET 10 i think"
- 17:51Z: "that document you pull from drop from gemini try to
  create modern guidance that is still in line with albamari"

## Worked example: System.Threading.Lock

Adds a primary-source-verified worked example showing the exact
shape of "Albahari old vs MS-Learn current":

- System.Threading.Lock landed in **.NET 9 / C# 13** (Aaron recalled
  .NET 10 — the type IS available throughout .NET 10 since it's the
  current LTS). Verified via `microsoft_docs_search` 17:48Z citing:
  - whats-new/csharp-13#new-lock-object
  - language-reference/statements/lock
  - code-analysis/style-rules/ide0330 (analyzer enforces this)
  - csharp-13.0/lock-object (proposal/spec)
- The C# `lock` statement specializes on `Lock`: `lock (x) { ... }`
  lowers to `using (x.EnterScope()) { ... }` (ref struct Dispose
  pattern) instead of `Monitor.Enter/Exit`. Monitor remains the
  fallback for plain reference-type targets.
- IDE0330 analyzer (default true) flags `private object _gate = new
  object();` and offers `private Lock _gate = new Lock();` as fix.
- CS9216 warns on cast-to-other-type (loses specialization).
- CS9217 errors on `lock (Lock)` inside `async` methods (await can't
  cross a Lock scope).

Aaron's 2011 Albahari guidance (lock-on-private-object) is still
correct in pre-.NET-9 codebases but is **no longer** the .NET-10
recommendation for new code. This worked example is the canonical
shape of the lineage-update pattern.

## Gemini absorb pointer

Adds a pointer to docs/research/2026-04-28-gemini-pro-deep-research-
threading-net10-csharp14-modernization.md (absorbed via PR #672)
as a worked example of "modern .NET 10 / C# 14 guidance still in
line with Albahari" — Gemini's doc walks Albahari's topic-set and
updates each to current idiom while preserving his pattern-orientation.

Updates CURRENT-aaron.md §29 to match the 4-source lineage with
the same MS Learn precedence.

Composes with:
- feedback_speculation_leads_investigation_not_defines_root_cause_aaron_2026_04_28.md
  (primary-source-first; the .NET-10 vs .NET-9 detail Aaron recalled
  was speculation; verified 30s via microsoft_docs_search)
- Otto-247 version-currency (training-data is stale; always WebSearch
  / docs-search before asserting versions)
- PR #672 (Gemini absorb document)

EVIDENCE-BASED labels:
- System.Threading.Lock first-shipped version: VERIFIED via
  microsoft_docs_search 17:48Z. Result: .NET 9 / C# 13. Aaron's
  recollection of .NET 10 was directionally right (type available
  in current LTS) but version-imprecise (introduced earlier).
- IDE0330 analyzer rule: VERIFIED via doc URL.
- CS9216 / CS9217 diagnostics: VERIFIED via compiler-messages docs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* memory(index): pair MEMORY.md edit with threading-lineage substrate update (Codex P1)

Codex P1 thread on PR #673: the substrate-update touched two memory
files (feedback_threading_*.md + CURRENT-aaron.md) without updating
the MEMORY.md index entry, violating .github/workflows/memory-index-
integrity.yml (paired-edit rule).

Real fix: bump the MEMORY.md threading-lineage line to match the
four-source upgrade. Old text said three-source (Albahari + Toub +
Fowler); new text reflects MS Learn promotion to position #1 +
Albahari demotion to #2 (foundational but old, 2011) + the
System.Threading.Lock worked example.

EVIDENCE-BASED: paired-edit rule VERIFIED via .github/workflows/memory-
index-integrity.yml + audit-memory-paired-edit.sh.

Note on the docs/research dead-link concern (Codex P2 + Copilot):
the link target docs/research/2026-04-28-gemini-pro-deep-research-
threading-net10-csharp14-modernization.md exists in PR #672 (Gemini
absorb) but not yet on main. PR #672's threads are all resolved and
auto-merge is armed; once #672 lands and #673 rebases, the link
becomes valid. The reference-existence lint only checks MEMORY.md
(per audit-memory-references.sh), not arbitrary memory/*.md files,
so this isn't CI-blocking. Resolving via PR-chain rebase order.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

2 participants