session: Harness-Session-Variable schliesst die Luecke im Session-Id-Fallback (Telemetrie-Join, Iteration-Budget-Gate); SIGPIPE-Nebenbefund im Emitter behoben
Files changed: - CHANGES.md - EVALS.md - INSTALL.md - VERSION - instructions/session-setup.md - tools/CONTRACT.md - tools/chemenu/cli.py - tools/chemenu/commands/doctor.py - tools/chemenu/commands/run_budget.py - tools/chemenu/session.py - tools/chemenu/telemetry/writer.py - tools/chemenu/tests/conftest.py - tools/chemenu/tests/test_cli.py - tools/chemenu/tests/test_run_budget.py - tools/chemenu/tests/test_telemetry_emit.py
This commit is contained in:
@@ -57,7 +57,21 @@ flowchart TD
|
||||
- **Hooks enrich.** They add the tool calls the repo layer cannot see: file reads, greps,
|
||||
shell commands, prompts.
|
||||
|
||||
Everything joins on `WIKITOOL_SESSION_ID`.
|
||||
Everything joins on one session id, resolved the same way by every source that has to pick
|
||||
one - see `chemenu.session`. The chain is `WIKITOOL_SESSION_ID`, then a harness's own session
|
||||
variable where one is registered (`chemenu.session.HARNESS_ENV_VARS` - Claude Code's
|
||||
`CLAUDE_CODE_SESSION_ID` today), then the parent process id. The middle step exists because
|
||||
the last one does not survive a harness that runs every tool call in its own freshly
|
||||
initialised shell: `os.getppid()` is then a new "session" per call, and neither the join nor
|
||||
the Iteration Budget Gate below can see more than one or two calls of a real run. A harness
|
||||
only earns an entry in that chain once a live session has been observed setting the variable,
|
||||
confirmed to be the exact id its own hooks write elsewhere in a trace - a name that merely
|
||||
looks plausible would mis-key a session more quietly than the pid fallback it replaced.
|
||||
|
||||
A trace hook that only *observes* tool calls (a `PreToolUse`/`PostToolUse`-style wiring) does
|
||||
not by itself fix a harness whose events carry a different id than `wikitool`'s own emitter -
|
||||
the two still would not join. Wiring such a hook is only worth doing once this fallback chain
|
||||
already keys both sides on the same id.
|
||||
|
||||
## The trace
|
||||
|
||||
@@ -68,7 +82,7 @@ is [tools/chemenu/telemetry/schema.py](tools/chemenu/telemetry/schema.py).
|
||||
|---|---|
|
||||
| `v` | Schema version |
|
||||
| `ts` | ISO-8601 UTC, microsecond precision |
|
||||
| `session_id` | The join key. `WIKITOOL_SESSION_ID`, else the parent process id |
|
||||
| `session_id` | The join key - `chemenu.session`'s fallback chain: `WIKITOOL_SESSION_ID`, else a registered harness variable, else the parent process id |
|
||||
| `pid`, `seq` | `seq` counts **within one process**. Sort a trace by `(ts, pid, seq)` |
|
||||
| `source` | `wikitool`, `runner`, or a harness name |
|
||||
| `event` | See below |
|
||||
|
||||
Reference in New Issue
Block a user