fix(issue-5): address phase 1 cross-review findings (R1, R2, F-1)
Three reviewers examined fc0bd96..8def235. Codex and Claude each reproduced a defect; all three findings were re-verified here before being accepted, and none were rebutted. R1 (codex) — the shell helpers ran `python -m lib_py.delegation.cli`. For -m, sys.path[0] is the working directory, which therefore beats PYTHONPATH: with cwd inside a tree containing lib_py, the live package won even with the frozen path listed first. The documented B-13 guarantee for this path did not hold. Reproduced, then replaced with an explicit bootstrap that inserts SKILL_DIR itself. cwd is left alone, because the registry and audit-log paths are relative to it. The file-based shim path was never affected. R2 (codex) — the persistent connection was reused on host and port alone. Two jobs sharing an endpoint but carrying different credentials or TLS settings silently published over the first connection. Reproduced (the client factory ran once, under the first account, with TLS off). The guard now compares an immutable snapshot of the whole connection identity and names only the differing field, never its value. F-1 (claude) — paho queues a publish issued while disconnected and raises RuntimeError from wait_for_publish. RuntimeError is deliberately outside the retry tuple, so the one state a persistent connection exists to survive, the gap between a drop and paho's reconnect, failed on the first attempt. Confirmed against paho 2.1.0. That single condition is now translated into a retryable error; the tuple is unchanged, so genuine programming errors are still not retried. Two fixtures were hiding these: FakeInfo had no rc and never raised. It now mirrors paho's contract, which is what makes the new tests meaningful. Also folds in the duplication both Claude (O-1) and I had flagged: the CLI path kept its own copy of connect-publish-disconnect plus its own timeout constants. _publish_once now delegates to OneShotPublisher.publish_raw, so a transport fix lands once. Having two copies is exactly why these bugs existed in one of them. Documentation corrected rather than defended: the benchmark's rationale for keeping three forks was imprecise (the || true already guarantees rc 0; the lookup buys quietness and legacy parity), SKILL.md no longer claims PYTHONPATH decides the frozen path, and the daemon's directory creation is recorded as a deliberate difference. Trailing whitespace inherited by the relocated file is stripped, so the commit range is now clean too. Verified: each regression fails against the pre-fix code and passes after (R1 1, R2 4, F-1 1). 66 phase-1 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UrDNJkHmm18uu7n7JwV5Qd
This commit is contained in:
1 parent
8def235dc7
commit
95f3e9a427
9 files changed
+344
-66
No files matched your search
@@ -84,14 +84,25 @@ Which tree wins, by execution context:
|
||||
|
||||
| Context | Resolved by | Tree that wins |
|
||||
|---|---|---|
|
||||
| Loop process and its children (frozen `lib.sh` sourced) | `PYTHONPATH` | the frozen snapshot |
|
||||
| Loop process and its children (frozen `lib.sh` sourced) | the helper's explicit bootstrap from `SKILL_DIR` | the frozen snapshot |
|
||||
| Agent session running a **frozen** script path while `PYTHONPATH` still points live | the shim, from its own location | the frozen snapshot (B-13 preserved) |
|
||||
| Live helpers (create/stop/resume/reconcile) | `PYTHONPATH` or the shim (same tree) | the live tree |
|
||||
| Standalone, no `PYTHONPATH` | the shim's fallback append | the shim's own tree |
|
||||
|
||||
`lib.sh` calls the package through `python -m lib_py.delegation.cli`. Setting
|
||||
`MAM_DELEGATION_PY=0` switches the shell helpers back to their preserved legacy
|
||||
bodies with no redeploy.
|
||||
`lib.sh` calls the package through `_delegation_py`, which inserts its own
|
||||
`SKILL_DIR` at the front of the import path. It deliberately does **not** use
|
||||
`python -m`: for `-m` the current directory precedes `PYTHONPATH`, so a frozen
|
||||
loop whose working directory happened to contain a `lib_py` package would have
|
||||
silently executed live code. The working directory is left untouched, because
|
||||
the registry and audit-log paths are relative to it.
|
||||
|
||||
Setting `MAM_DELEGATION_PY=0` switches the shell helpers back to their preserved
|
||||
legacy bodies with no redeploy.
|
||||
|
||||
One in-process caveat: the package binds once per process and is never rebound,
|
||||
so do not import a frozen shim after a live `lib_py.delegation` is already bound
|
||||
inside the same interpreter. Production never does this — each delegated job is
|
||||
a fresh interpreter — but a test harness could.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user