refactor(egress): write routes.yaml as actual YAML, not JSON-in-yml
`egress_render_routes` now emits hand-rolled YAML in the same style
as `pipelock_render_yaml`. The egress addon parses it via
`yaml_subset.parse_yaml_subset` — the same parser the manifest
loader + pipelock_apply use.
Why bother: routes.yaml is bind-mounted into the egress sidecar
AND surfaced to operators through `routes edit` (PRD 0019). JSON-
in-yml renders ugly in $EDITOR and signals "this is data" rather
than "this is config you can read at a glance". Real YAML reads
cleanly.
Mechanics:
- `yaml_subset.py` drops its `claude_bottle.log` dependency.
Errors now raise `YamlSubsetError` (a `ValueError`); the
manifest loader + pipelock_apply catch it at the boundary
and forward to `die` / `PipelockApplyError` so callers see
the same behavior they did before.
- `Dockerfile.egress` adds one COPY line for `yaml_subset.py`
so it sits flat in `/app/` next to the addon. The addon
uses an absolute-import-with-fallback shim so the same file
works inside the container AND from the host's unit tests.
- `egress_apply._merge_single_route` round-trips current
routes.yaml through `parse_yaml_subset` + a new
`_render_routes_payload` helper instead of `json.loads` +
`json.dumps`.
End-to-end: rebuilt the egress image, ran `./cli.py start` to a
full bring-up, confirmed the addon's boot log shows `egress:
loaded 9 route(s)` — i.e., the YAML parses inside the container.
453 unit + 3 integration tests pass.
This commit is contained in:
@@ -45,7 +45,7 @@ from pathlib import Path
|
||||
from typing import Mapping, cast
|
||||
|
||||
from .log import die, warn
|
||||
from .yaml_subset import parse_frontmatter
|
||||
from .yaml_subset import YamlSubsetError, parse_frontmatter
|
||||
|
||||
|
||||
def _empty_str_dict() -> dict[str, str]:
|
||||
@@ -832,6 +832,8 @@ def _load_bottles_from_dir(bottles_dir: Path) -> dict[str, Bottle]:
|
||||
fm, _body = parse_frontmatter(path.read_text())
|
||||
except OSError as e:
|
||||
die(f"could not read {path}: {e}")
|
||||
except YamlSubsetError as e:
|
||||
die(f"{path}: {e}")
|
||||
unknown = set(fm.keys()) - _BOTTLE_KEYS
|
||||
if unknown:
|
||||
allowed = ", ".join(sorted(_BOTTLE_KEYS))
|
||||
@@ -867,6 +869,8 @@ def _load_agents_from_dir(
|
||||
fm, body = parse_frontmatter(path.read_text())
|
||||
except OSError as e:
|
||||
die(f"could not read {path}: {e}")
|
||||
except YamlSubsetError as e:
|
||||
die(f"{path}: {e}")
|
||||
unknown = set(fm.keys()) - _AGENT_KEYS
|
||||
if unknown:
|
||||
allowed = ", ".join(sorted(_AGENT_KEYS))
|
||||
|
||||
Reference in New Issue
Block a user