Skip to content

#1729 Request correlation's causal scope works without the profiler - #1734

Merged
nockawa merged 2 commits into
mainfrom
feature/correlation-scope
Dec 2, 2026
Merged

nockawa merged 2 commits into
mainfrom
feature/correlation-scope

Conversation

@nockawa

@nockawa nockawa commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Closes #1729.

Request correlation's causal scope no longer needs the profiler. An application (NockWorld's shard, for its logs, journal and audit) turns on one switch and reads CausalScope.Current on the tick.

Two gates from one switch, now Typhon:Correlation:Enabled (moved out of Typhon:Profiler):

  • CorrelationScopeActive (CausalScope.IsActive): the switch alone. Gates CausalScope.Capture/Enter (so the InTick/WriteInTick hand-off), client-command scoping, and the ASP.NET Core listener (a request gets a trace id).
  • ProfilerCorrelationActive: profiler AND the switch. Gates the records (ExternalRequest, kinds 236-240), span stamping, and the ASP.NET recording middleware.
  • Both are static readonly: with the switch off, the JIT removes every branch.

Catalog: a node may now carry "key" to override its path-derived config key. The generators, the reference docs and the shell's typhon telemetry file model honour it. The shell writes the flag beside Profiler and ignores a value left at the old spot.

Tests:

  • New gated pass X in shard.py (profiler off, correlation on):
    • an InTick item runs under its caller's cause, and the next item does not inherit it;
    • a command loop scopes each command's id, break keeps the last id, and the end-of-system clear empties the scope;
    • CausalScope itself.
  • A mutation check confirmed it: putting the old gate back fails these tests.
  • ASP.NET: the profiler-off registration is tested in-process. The handler captures the request's trace id, and no recording middleware is registered.
  • Shell: Correlation round-trips at its own key.
  • pre-push.sh: all gate-equivalent checks pass. The engine suite ran 11 054 tests across the gate shards plus the T, C and X passes, with 0 failed.

Docs: claude/design/Profiler/13-request-correlation.md § 2.2 and overview 09 (Typhon-Claude branch feature/correlation-scope), the in-depth overview, PACKAGE.md, and the regenerated flag reference.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UCUestf7LdQ9JAKiYLAD6v

The correlation switch (Typhon:Profiler:Correlation:Enabled) alone now carries a request's or client command's causal id onto the tick: CausalScope.Capture/Enter, the InTick/WriteInTick hand-off, client-command scoping and the ASP.NET Core listener are gated on CorrelationScopeActive (the switch's own field, renamed from ProfilerCorrelationEnabled). An application reads CausalScope.Current, or CausalScope.IsActive, to stamp its own logs and audit.

The profiler's records (ExternalRequest, kinds 236-240, span stamping, the ASP.NET recording middleware) stay on ProfilerCorrelationActive, the profiler master AND the switch.

New gated test pass X (profiler off, correlation on) runs the tests that need that configuration: the InTick hand-off, command scoping with break and the end-of-system clear, and CausalScope itself.
…side the profiler

It no longer needs the profiler, so its key no longer says it does. The flag catalog gains an optional per-node "key" that overrides the path-derived one; the generators, the reference docs and the shell's telemetry file honour it (the shell writes and reads the flag beside Profiler and ignores a value left at the old spot). Env var: TYPHON__CORRELATION__ENABLED.

AddTyphonRequestCorrelation's registration is split so the profiler-off branch is tested in this suite's process: a request's trace id is captured by CausalScope.Capture after an await, and no recording middleware is registered.
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.

Request correlation (CausalScope) usable without turning the profiler on

1 participant