The four delegation scripts become a real package. Their old paths stay as
shims because those paths are a wire contract: agent instructions, the bash
wrapper, SKILL.md, BOOTSTRAP.md, deploy/install.sh and three test modules all
call them literally.
The shim binds the lib_py.delegation *package* to the tree beside it, once per
process, and never touches sys.path. Two cheaper designs were rejected with
evidence (the context matrix now lives in the test suite):
* inserting the sibling skills dir at sys.path[0] makes the first sandbox
copy imported under pytest shadow lib_py.agents/layout/state for the whole
session, and the identity assertion cannot see it -- `is` proves same
object, not same tree.
* loading only the named module by file path leaves a module that imports
siblings pulling them from whichever tree is on the path, so a frozen
publish_event ran against live dependencies and lost half of B-13.
Binding the package fixes both: one tree for all delegation modules, the parent
lib_py untouched, and a sys.path append only when no lib_py exists anywhere
(true standalone). Bind-once rather than nearest-wins, because rebinding would
split existing references and break monkeypatching.
Also moves the env-file load off import (_load_dotenv -> ensure_env_loaded,
called by each process entry point including reconcile.sh's embedded
subscriber), so importing the library no longer mutates os.environ.
Verified: PV-1 identity+provenance, PV-4's ten import scenarios plus K1/K3/K6
in fresh interpreters, PV-5 shim byte-identity, an AST check that the package
imports no sibling lib_py module, and --help output diffed against the
pre-move capture.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UrDNJkHmm18uu7n7JwV5Qd
19 lines
892 B
Python
19 lines
892 B
Python
"""Delegation backplane: job registry, MQTT publish/subscribe, and the
|
|
subscriber daemon.
|
|
|
|
The implementation moved here from
|
|
``multi-agent-mux-delegate-job/scripts/*.py`` in issue #5 phase 1. Those script
|
|
paths are a wire contract (agent instructions, the bash wrapper, SKILL.md,
|
|
BOOTSTRAP.md, deploy/install.sh and three test modules call them by literal
|
|
path), so they remain as shims that bind *this package* to the tree next to
|
|
themselves, once per process, without touching ``sys.path``.
|
|
|
|
Package rules, enforced by tests:
|
|
* modules here import each other as ``from lib_py.delegation import x`` --
|
|
never by top-level name, which would collide with ``lib_py.agents.registry``.
|
|
* nothing here imports another ``lib_py`` module. Under a frozen loop the
|
|
parent ``lib_py`` may resolve to a different tree than this package, so a
|
|
sibling import would silently mix trees.
|
|
"""
|
|
|