Skip to content

backlog: file #1062, check reads env values from cwd after validating them under --project-root - #236

Closed
wshallwshall wants to merge 1 commit into
mainfrom
claude/check-env-anchor
Closed

backlog: file #1062, check reads env values from cwd after validating them under --project-root#236
wshallwshall wants to merge 1 commit into
mainfrom
claude/check-env-anchor

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Files BACKLOG #1062. Docs-only, one file, +37. No fix, no code change.

THE DEFECT. messagefoundry check accepts an explicit --project-root, validates that
<root>/<env_dir>/<env>.toml EXISTS under it, and then DROPS the root. _check_build
re-derives the value anchor from Path.cwd(). So build-check verifies the file under the
supplied root and READS THE VALUES from wherever the shell happens to be standing.

CHAIN, read end to end rather than inferred from the symptom:

  • the root is dropped at main.py:853
  • run_checks takes no root parameter
  • checks.py:1304 re-derives from Path.cwd()
  • resolve_values_base_dir returns cwd when base_dir is empty -- which is the SHIPPED DEFAULT

serve does it correctly in the same file (:1086), writing the project root into
environments.base_dir before load_settings, with a comment saying why. The comment
directly above the defect claims parity with serve, and the missing step is exactly that
parity.

WHY IT IS FILED SEPARATELY. This is the fourth instance of one premise: THAT WHERE A
COMMAND RUNS IS WHERE THE CALLER IS. The other three are #1057 (occupancy places sessions
by cwd, so it cannot see a session writing by absolute path from elsewhere -- the script
puts that at 29% of writes on this repo), #1059 (the worktree gate resolves paths against
the session cwd, so a shell variable defeats it), and #1060 (alloc.ps1 takes the owning
worktree from git rev-parse --show-toplevel). All four fail SILENTLY and in the
benign-looking direction.

This one is the most significant of the four because it is on the ENGINE surface rather
than the coordination scripts, which is where nobody was looking. No theme item was filed
for the pattern -- "four mechanisms share a premise" has no fix and no closing condition,
and the premise is already recorded as prose in docs/WORKTREES.md (#1060) where it
outlives any single item.

Claims to violate ADR 0050 AC-6 with an untested acceptance criterion.

VERIFICATION. Based on 0a994e0, merge-tree CLEAN against current main. Headings
139 -> 140, exactly one added and nothing lost. Number allocated atomically from the
committing worktree.

… them under --project-root

`messagefoundry check --project-root R` anchors --config under R and HARD-FAILS
if R/<env_dir>/<env>.toml is absent -- then drops R. run_checks takes no project
root, so the build check re-derives the value anchor from Path.cwd(). The gate
verifies the file under the root you supplied and reads the values from wherever
the shell happens to be.

Verified by reading the chain end to end rather than inferring from a grep:
    __main__.py:832    root = resolve_project_root(args.project_root, cwd)
    __main__.py:848-52 hard-fail if <root>/<env_dir>/<env>.toml is absent
    __main__.py:853    return config_dir, service_config      <- root DROPPED
    __main__.py:4263+  run_checks(...)                        <- no root parameter
    checks.py:1304     resolve_values_base_dir(..., cwd=Path.cwd())
    environments.py:79 `if not base_dir: return cwd`          <- unset by default

SERVE GETS IT RIGHT ONE SCREEN AWAY: __main__.py:1086 writes args.project_root
into cli["environments"]["base_dir"] before load_settings, and :1095 records
that this is exactly why. check never sets it.

THE COMMENT ABOVE THE DEFECT CLAIMS THE PARITY THAT IS MISSING, which is the
sharpest evidence it is an oversight and not a decision. checks.py:1300-1302
says "Resolve env() against the active environment the same way serve does".
Serve's way IS the base_dir assignment. The comment states the goal and the code
omits the step that achieves it.

Consequence in the conditional per section 0: build-check is a required blocking
check for the ADR 0092 posture-keyed insecure-hop refusal, whose hosts and
schemes are env()-supplied. From a cwd holding a different environments/<env>.toml
the refusal is decided against the WRONG values while the operator was told the
root was validated, and no diagnostic names the directory read -- the AC-4
cwd-differs-from-root warning is serve-only.

Reachability stated honestly: nothing in this repo passes --project-root to
check, so it is supported-but-not-exercised-here, which is also why no test
caught it. That is not the same as unreachable -- it is the documented consumer /
config-repo invocation, ratified by ADR 0050 AC-6.

Held as RELAYED-NOT-CONFIRMED from a sweep since 2026-08-05 and filed only after
the chain was read. A subagent's severity ranking is not evidence.

Number allocated atomically from the committing worktree. Headings +1;
parse_items reports every item declaring exactly one status.
@wshallwshall
wshallwshall enabled auto-merge (squash) August 6, 2026 09:45
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Superseded by a fresh cut off current main. #1063 (PR #237) merged first, leaving this branch's base squash-merged away, so rebasing it would hit the pre-squash-base trap and a force-push would rewrite a branch whose ledger entitlement belongs to another worktree. The item is re-filed unchanged from the allocating worktree; see the replacement PR. No content is lost -- f9bea40 remains readable in the shared object store.

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.

1 participant