beads/internal
ecuthiell 79631656c0
fix(config): pin role writes to a fresh common-config context (#6454)
* fix(exec): match Windows environment key identity (#5618)

Centralize os/exec-compatible environment-key comparison and use it for credential, metrics, Git-hook, trace, and repro subprocess filters. Preserve exact Unix semantics and Unicode near-collisions.

Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of Ewen Cuthiell
Signed-off-by: Ewen Cuthiell <ewencuthiell@gmail.com>

* fix(worktree): scrub inherited Git routing state

Establish CWD as the worktree repository boundary before discovery can consume inherited Git routing. Fence the startup config probe, clear routing in-process before root pre-run discovery, and retain command-owned subprocess scrubbing as defense in depth without changing PID or signal semantics.

Fixes #5531

Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of Ewen Cuthiell

* refactor(worktree): explain owned filtering and remove an unused shim

Document why filtering the fresh routing slice in place is safe and call
the shared routing-key classifier directly from tests. Retain the two
forwarders used by production worktree subprocess/removal paths.

Review: https://github.com/gastownhall/beads/pull/5623#pullrequestreview-5098421671
Bead: saa-cgh.23
Agent-Signature: unknown-model/unknown-reasoning

* fix(config): isolate identity and tracked-file Git probes from routing

Reuse the worktree routing owner for GetIdentity and isGitTracked so
explicit cwd/path selection is not displaced by inherited repository,
index or injected config state. Preserve identity precedence and the
tracked-secret refusal contract, with real target/decoy regressions.

Follow-up: https://github.com/gastownhall/beads/issues/6222
Dependency: https://github.com/gastownhall/beads/pull/5623
Reported-by: bee-ghosttrack
Bead: saa-cgh.93
Agent-Signature: unknown-model/unknown-reasoning

* test(execenv): exercise every environment operation under both host rules

Thread the host choice through narrow private helpers behind the existing
exported functions. Keep one normalization owner and retain native wrapper
tests; the additional table covers both host branches for equality, prefix
matching, last-wins lookup, filtering and input preservation.

Review: https://github.com/gastownhall/beads/pull/5672#pullrequestreview-5096948965
Bead: saa-cgh.78
Agent-Signature: unknown-model/unknown-reasoning

* docs(worktree): explain startup Git environment scope (saa-cgh.23)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* test(execenv): exercise exported host policy wiring (saa-cgh.78)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(config): share subprocess key identity for Git routing (saa-cgh.93)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(hooks): isolate tracked-file guard from Git routing (saa-cgh.98)

Follow-up to bee-ghosttrack's review of gastownhall/beads#6322; refs #6356.

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(config): isolate role commands from Git routing (saa-cgh.99)

Follow-up to bee-ghosttrack's review of gastownhall/beads#6322; refs #6357.

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* test(env): exercise shared key helpers on native Windows (saa-cgh.78)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* refactor(gitenv): share key parsing and normalize routing membership once (saa-cgh.93)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* docs(config): explain role command routing policy (saa-cgh.99)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(hooks): retain legitimate inherited tracking context (saa-cgh.98)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* test(hooks): isolate trusted global configuration fixture (saa-cgh.98)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(hooks): isolate role cleanup in the selected repository (saa-cgh.109.4)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(hooks): reset only common local role configuration (saa-cgh.109.10)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(hooks): scope hooks-path cleanup to selected common config (saa-cgh.109.11)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* test(hooks): make worktree role preservation independent (saa-cgh.120)

Agent-Signature: Codex-unknown-model-unknown-reasoning on behalf of Ewen Cuthiell

* Report selected config read failures during hook reset (saa-cgh.120)

Agent-Signature: Codex-unknown-model-unknown-reasoning on behalf of Ewen Cuthiell

* fix(hooks): keep successful config stdout separate from diagnostics (saa-cgh.120)

Agent-Signature: Codex-unknown-model-unknown-reasoning on behalf of Ewen Cuthiell

* fix(config): pin role writes to fresh common context (GH#6384) (saa-cgh.120.3)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(config): retain Git diagnostics from role writes (saa-cgh.120.3)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* test(config): assert the actual Git lock diagnostic (saa-cgh.120.3)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(config,hooks): restore the inherited-tracking fallback in the secret guard

Maintainer review fixes for PR #6454 (adopt-pr iteration 1). The scorecard
approved at 913/1000 with no blocker or major surviving synthesis; these are
the non-gating findings that were cheap to close while the fixup was open.

Finding 1 (minor, security) is the only in-range regression in the report. The
range switched internal/config.isGitTracked from the inherited environment to
gitenv.ScrubRouting only, so a config.yaml tracked solely through legitimate
routing -- a bare repository whose work tree is named by GIT_DIR/GIT_WORK_TREE
-- reported untracked, and a secret-key write that upstream-base refused was
silently allowed. Restores the scrubbed-then-inherited union the same stack
already gave cmd/bd.isGitTrackedFile.

Finding 4 (nit) composes with it rather than conflicting, so both land as one
change: the inherited probe now runs only when the scrubbed probe failed for a
configuration reason. git's exit codes discriminate exactly -- 0 tracked, 1
repository reached but path untracked (final), 128 no reachable repository --
so the ordinary untracked-hook miss no longer spawns a second `git ls-files`
while the bare-work-tree fallback is preserved.

Finding 2 (minor). scrubWorktreeRemovalGitEnvForOS keyed its stricter
no-optional-locks policy on strings.ToUpper while the rest of the PR uses
execenv key identity. The two disagree in both directions on Windows:
GIT_OPTIONAL_LOCKS with a dotted capital I (U+0130) survived the scrub although
Git honors it, and GIT_OPTIONAL_LOCK with a long s (U+017F) was dropped
although os/exec keeps it distinct. normalizeWorktreeGitEnvKey is deleted in
favour of execenv.KeyEqualForOS. Base applied ToUpper on all platforms, so this
is a consistency fix in newly rewritten code, not a regression.

Finding 5 (nit). The comment above resetHooksPathIfBeadsManaged's probe
asserted that repoRoot and commonDir share the cached Git context. Probed
false: with cwd A and GIT_DIR=B/.git, `git rev-parse --git-common-dir
--show-toplevel` prints B/.git and A. Restated as intent.

Finding 3 (scrubGitHookEnv is a fifth, strictly weaker routing scrubber) is
deliberately not taken here: cmd/bd/export_auto.go is untouched by this range,
so the hazard is byte-identical at base, and the synthesis scoped it to a
follow-up bead rather than growing this stack.

Each fix is mutation-proved. Reverting isGitTracked reds only the new
TestSecretGitTrackingHonorsInheritedBareWorkTree -- including "refusal = <nil>",
the actual security consequence -- while the incumbent decoy test stays green,
so the pin adds coverage rather than duplicating it. Restoring ToUpper reds
only the new Windows row, showing both directions at once.
TestGuardHookWritePathHonorsInheritedRepository gains a fixture guard asserting
its scrubbed probe fails for a configuration reason rather than exit 1, so a
future fixture change cannot silently make the fallback unreachable.
scrubWorktreeRemovalGitEnvForOS had no test at all before this.

Green locally: ./internal/config, ./internal/execenv, ./internal/gitenv,
./internal/githooksenv, ./internal/gittraceenv, ./internal/metrics, ./scripts,
./internal/beads (the GIT_CONFIG_GLOBAL blast radius neither reviewer ran), and
a blast-radius cmd/bd run over the hooks, worktree, role and uninstall suites.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Signed-off-by: Ewen Cuthiell <ewencuthiell@gmail.com>
Co-authored-by: Bee <bee@ghosttrack.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-27 02:00:16 -07:00
..
ado test(proxy): topology-parameterized history and remote front-door matrix (#6269) 2026-09-05 08:25:49 -07:00
atomicfile /internal/atomicfile/atomicfile.go: use io.Copy 2026-05-01 17:03:30 -07:00
audit fix(audit): make JSONL sidecar opt-in (#4688) 2026-07-11 00:09:17 -07:00
beads fix: honor changed directory when running prime (#6550) 2026-09-27 00:59:29 -07:00
compact feat: add MiniMax provider support via Anthropic-compatible API (#3610) 2026-08-02 22:23:37 -07:00
config fix(config): pin role writes to a fresh common-config context (#6454) 2026-09-27 02:00:16 -07:00
configfile test(configfile): make port-env fallback tests ambient-blind (be-v4g1j) (#6592) 2026-09-26 09:01:43 -07:00
creds chore(creds): drop the two unreferenced credential rungs (#5379) 2026-08-06 07:03:09 -07:00
debug feat(verbosity): wire --quiet into create/close/update (bd-au0.10) (#4058) 2026-07-06 22:35:42 -07:00
doltremote fix(doltremote): fold host case, strip creds, recognize user-less SCP in CanonicalForComparison (#4576) 2026-07-07 12:59:18 -07:00
doltserver fix(doctor,doltserver): escape SHOW DATABASES identifiers at raw-interpolation sites (#6434) (#6638) 2026-09-26 14:26:04 -07:00
doltversion feat(doltversion): dolt CLI discovery, hardened version probe, and warn-only version policy (contract part 1) (#5092) 2026-08-12 21:18:24 -07:00
eventsjournal feat(events-journal): record the mutating actor on every journal row (#5908) 2026-08-23 13:55:59 -07:00
execenv fix(config): pin role writes to a fresh common-config context (#6454) 2026-09-27 02:00:16 -07:00
fdhygiene fix(doltserver): stop detached children inheriting the caller's fds (#4634) (#5184) 2026-07-31 08:41:41 -07:00
formula fix(cook/pour): honor declared formula step types instead of squashing them to task (#5520) 2026-08-10 05:36:33 -07:00
git test(git): restore cwd before temp cleanup (#4935) (#4936) 2026-07-23 18:40:44 -07:00
gitenv fix(config): pin role writes to a fresh common-config context (#6454) 2026-09-27 02:00:16 -07:00
githooksenv fix(config): pin role writes to a fresh common-config context (#6454) 2026-09-27 02:00:16 -07:00
github test(proxy): topology-parameterized history and remote front-door matrix (#6269) 2026-09-05 08:25:49 -07:00
gitignore refactor(init): retire the unused global-ignore writer (#6452) 2026-09-27 01:34:19 -07:00
gitlab Beads #6735: prevent duplicate GitLab sync on self-hosted URLs (#6736) 2026-09-26 04:15:47 -07:00
gittraceenv fix(config): pin role writes to a fresh common-config context (#6454) 2026-09-27 02:00:16 -07:00
hooks Make wasm hook refusals observable (#5607) 2026-08-10 21:01:31 -07:00
httpapi test(httpapi): match missing token file with errors.Is, not Unix text (#6628) 2026-09-26 09:45:11 -07:00
idgen fix(idgen): correct test vectors in hash_test.go 2025-12-19 18:13:56 -08:00
jira test(proxy): topology-parameterized history and remote front-door matrix (#6269) 2026-09-05 08:25:49 -07:00
linear test(proxy): topology-parameterized history and remote front-door matrix (#6269) 2026-09-05 08:25:49 -07:00
lockfile Triage and clean up an unreviewed automated commit stream on main (#4418) 2026-06-15 20:24:57 -07:00
memoryapi Put the memory plane behind memoryops, conformance-tested at three backends (#5387) 2026-08-07 03:57:04 -07:00
metrics fix(config): pin role writes to a fresh common-config context (#6454) 2026-09-27 02:00:16 -07:00
migration fix(migration): vendor-neutral freeze gate — generic freeze-file discovery, exit code 14, proper error returns (D-6) (#6043) 2026-08-29 21:59:43 -07:00
molecules refactor: delete the dead orphan-handling capability (bd-gwryr) (#5497) 2026-08-09 12:03:18 -07:00
notion test(proxy): topology-parameterized history and remote front-door matrix (#6269) 2026-09-05 08:25:49 -07:00
procid fix(build): restore freebsd compilation with unsupported-platform stubs for procid + unverified-process (release v1.2.0 blocker) (#5661) 2026-08-11 14:03:44 -07:00
query fix(timeparsing): add min minutes unit to compact duration parser (#6609) (#6629) 2026-09-26 18:51:37 -07:00
recipes [codex] Add Kiro setup recipe (#4535) 2026-07-27 22:28:43 -07:00
remotecache fix(dolt): scrub stderr-directed git tracing before git-remote transfers (#5323) 2026-08-10 05:25:15 -07:00
routing fix(routing): warn when contributor auto-routing swaps bd list/ready to the planning store (#4866) 2026-07-25 22:31:03 -07:00
storage fix(config): pin role writes to a fresh common-config context (#6454) 2026-09-27 02:00:16 -07:00
telemetry fix(ready): keep the ReadyCounter span through externaldeps, and announce the interface break (#6748) 2026-09-25 13:53:47 -07:00
templates fix(cli): printed doc paths point at the new docs locations 2026-07-12 10:37:17 -07:00
testutil fix(test): recover when a Dolt test server dies mid-suite (#6756) 2026-09-26 14:27:18 -07:00
timeparsing fix(timeparsing): add min minutes unit to compact duration parser (#6609) (#6629) 2026-09-26 18:51:37 -07:00
tracker fix(test): recover when a Dolt test server dies mid-suite (#6756) 2026-09-26 14:27:18 -07:00
types Merge release/1.3.0 into main (post-tag forward-port) 2026-09-15 22:09:13 +00:00
ui fix(ui): stop using blocked ● for priority in CLI output (#5511) 2026-08-10 06:19:51 -07:00
uimd fix(show): stop bd show corrupting shell globs in descriptions (#5799) 2026-08-20 07:54:36 -07:00
utils feat(issueops): add the Reader role and wire both front doors through it 2026-07-31 18:37:25 +00:00
validation fix: canonicalActor collapses the --/__ axes correctly; claim-verify uses ActorMatches (be-p7dzx, bundled be-vc51) (#5856) 2026-08-19 13:23:35 -07:00
workapi fix(ready): keep the ReadyCounter span through externaldeps, and announce the interface break (#6748) 2026-09-25 13:53:47 -07:00
workspacegate feat(workspacegate): shared physical-root resolver, beads.OpenGated, and CLI gate wiring (part 2) (#5093) 2026-07-31 01:41:20 -07:00
worktreeremove test: replace worktree removal process matrix (bd-kuqlg.2) (#5280) 2026-08-02 09:34:29 -07:00