secrets/test
Brian Majewski c09ac38b16 fix: discover workspaces in pnpm and yarn monorepos (EGB-1232)
Workspace patterns came from package.json's `workspaces` key only, at both
call sites. pnpm declares them in pnpm-workspace.yaml instead, so no pnpm
monorepo ever resolved a workspace: `push -w` refused outright, and plain
`push` failed silently — _maybe_workspace_env_files returned 0 the moment
the key was absent, leaving the auto-discovery that covers push's root-only
scan inert and printing "Nothing new to add", indistinguishable from a repo
with genuinely nothing new. That silence cost two sessions on the same repo.

Both call sites now resolve through one shared source, _workspace_patterns:
package.json when it declares any, else pnpm-workspace.yaml's `packages:`
block. The YAML read is deliberately not a parser — block sequence only,
stopping at the next top-level key so pnpm 10's onlyBuiltDependencies:/
catalog: cannot leak in as globs, with quote/comment handling and a symlink
refusal.

Also fixes yarn's object form. `.workspaces // .workspaces.packages | .[]`
short-circuits on the truthy object, iterating its values and yielding the
pattern array as one token; only npm's array form ever worked. Note the
obvious reorder is NOT the fix — `.workspaces.packages` errors on an array —
so the filter is type-aware.

Patterns are validated before reaching the unquoted glob expansion (no
absolute paths, `..`, metacharacters, or whitespace; pnpm `!` negations
skipped), matching the .secrets-store/.secrets-files posture. jq is now
required only when package.json is the source. A monorepo-shaped root that
resolves nothing warns and points at `secrets add` instead of returning in
silence, and `-w`'s error names pnpm-workspace.yaml when that is the file
present.

Scope note: the workspace re-scan still runs only for projects that already
have a .secrets.json — push's root-scan-only first push is by design
(EGB-677 E13), and this bug is the fallback covering it never engaging.

test/workspaces.bats: 18 new tests. Full suite 371/371 green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BrUoYuUMoTj91rzV4vxGPB
2026-09-08 15:22:04 -07:00
..
install.bats feat: thin install.sh onboarding bootstrap (EGB-671) 2026-06-08 16:23:50 -07:00
join.bats feat: secrets join + init --remote + verified onboarding (EGB-671) 2026-06-08 16:23:50 -07:00
manifest.bats refactor: dedup external extractor + read guards, warn on legacy-pull nested blobs (EGB-701) 2026-06-18 10:08:13 -07:00
migrate.bats feat: secrets migrate --status surfaces v2-only externals (coverage, EGB-712) 2026-06-08 10:44:34 -07:00
recipients.bats fix: validate-before-mutate in recipients add/rm + verify messaging + doc/UX polish (EGB-283) 2026-06-24 13:37:56 -07:00
run-security.sh chore: security review policy + operator runner, doc updates (EGB-677 stage 1) 2026-06-07 13:12:39 -07:00
secrets.bats feat: secrets join + init --remote + verified onboarding (EGB-671) 2026-06-08 16:23:50 -07:00
sync.bats fix: surface store sync failures + add secrets sync (EGB-1230, EGB-1231) 2026-09-08 14:20:20 -07:00
test_helper.bash feat: multi-recipient encrypt core + recipients.txt (EGB-283) 2026-06-24 12:33:05 -07:00
upgrade.bats feat: secrets upgrade verb — self-update + re-check version skew (EGB-716) 2026-06-18 11:01:17 -07:00
version.bats feat: version-skew nudge — stamp store writer-version, warn when behind (EGB-713) 2026-06-08 12:07:50 -07:00
workspaces.bats fix: discover workspaces in pnpm and yarn monorepos (EGB-1232) 2026-09-08 15:22:04 -07:00