opencode/packages/opencode/test
Kit Langton fce074726f refactor(core): migrate ConfigPermission.Info to Effect Schema canonical
Follow-up to #23716. Moves ConfigPermission.Info from zod-first (with a
preprocess hack) to Effect Schema canonical using Schema.StructWithRest +
Schema.decodeTo, and deletes the now-unused ZodPreprocess plumbing.

Core change: rule precedence in `Permission.fromConfig` now sorts top-level
keys so wildcard permissions (e.g. `*`, `mcp_*`) come before specific
ones (e.g. `bash`, `edit`). Combined with `findLast` in evaluate(),
this gives the intuitive semantic 'specific tool rules override the `*`
fallback' regardless of the user's JSON key order. This silently fixes the
previously-broken case `{bash: "allow", "*": "deny"}` (which under
the old semantics denied bash because `*` came last).

Once rule precedence no longer depends on JSON insertion order, the
`__originalKeys` + ZodPreprocess hack can go — StructWithRest's natural
canonicalisation is fine because fromConfig sorts anyway.

- src/config/permission.ts: rewrite. InputObject is StructWithRest with known
  permission keys (read/edit/bash/... as Rule, todowrite/webfetch/... as
  Action-only for type narrowing) + Record rest. Schema.decodeTo normalises
  the Action shorthand into { "*": action }. .zod is derived — walker
  already carries the decodeTo transform.
- src/config/config.ts, src/config/agent.ts: reference ConfigPermission.Info
  directly instead of via Schema.Any + ZodOverride. The Effect decoder now
  applies the permission transform at load time.
- src/permission/index.ts: fromConfig sorts wildcards-before-specifics at
  top level. Sub-pattern order inside a tool key is preserved (documented
  `*` first, specifics after).
- src/util/effect-zod.ts: delete ZodPreprocess symbol, its walkUncached
  branch, and the TODO comment. Zero remaining consumers.
- test/permission/next.test.ts: 6 new tests pinning the new semantics —
  order-independent precedence, wildcard-as-fallback, sub-pattern order
  preservation, canonical documented-example regression guard.
- test/config/config.test.ts: updated the "preserves key order" test to
  reflect the new canonical output shape (declaration-order known fields,
  then input-order rest keys). Behavioural guarantees live in the new
  permission tests.
- test/util/effect-zod.test.ts: delete the ZodPreprocess describe block
  (~115 lines of tests for the now-removed feature).

SDK diff vs dev:
- Removed `__originalKeys?: Array<string>` (internal leak).
- Catchall cleaned up (no unrelated `Array<string>`).
- Known-field types preserved (autocomplete + narrowing).
- Only shape change: PermissionConfig union order swap (commutative).

Safety audit: no config, test, or doc in the repo (including all 16
translations) exercises the pattern where specifics come before wildcards
at the top level. The only configs whose behaviour changes are ones that
were silently broken.
2026-04-21 17:38:24 -04:00
..
account refactor: eliminate account/ barrel, route consumers to sibling files (#22995) 2026-04-17 01:55:50 +00:00
acp fix: clean up final 16 no-unused-vars warnings (#22751) 2026-04-16 03:54:21 +00:00
agent chore: kill unused tool (#23701) 2026-04-21 11:31:20 -04:00
auth refactor(auth): remove async auth facade exports (#22306) 2026-04-13 12:31:43 -04:00
bus refactor(auth): remove async auth facade exports (#22306) 2026-04-13 12:31:43 -04:00
cli refactor: consolidate npm exports and trace flock acquisition (#23151) 2026-04-17 18:58:37 +00:00
config refactor(core): migrate ConfigPermission.Info to Effect Schema canonical 2026-04-21 17:38:24 -04:00
control-plane feat(core): expose workspace adaptors to plugins (#21927) 2026-04-13 13:33:13 -04:00
effect chore: generate 2026-04-18 15:21:48 +00:00
fake feat: unwrap Provider namespace + improved automation script (#22690) 2026-04-15 21:44:46 -04:00
file chore: delete filetime module (#22999) 2026-04-16 23:31:21 -05:00
filesystem shared package (#22626) 2026-04-15 14:26:20 +00:00
fixture CLI perf: reduce deps (#22652) 2026-04-16 02:03:03 -04:00
format chore: generate 2026-04-17 02:34:07 +00:00
git feat: restore git-backed review modes (#20845) 2026-04-03 09:54:57 -05:00
ide fix(test): replace structuredClone with spread for process.env (#14908) 2026-02-24 23:16:24 +10:00
installation refactor(effect): upgrade opencode to beta.46 context APIs (#21977) 2026-04-10 23:06:28 -04:00
lib fix: delete 9 dead functions with zero callers (#22697) 2026-04-16 02:01:02 +00:00
lsp refactor: remove ambient instance reads from lsp (#23023) 2026-04-17 21:47:59 -04:00
mcp fix: clean up final 16 no-unused-vars warnings (#22751) 2026-04-16 03:54:21 +00:00
memory feat: enable type-aware no-floating-promises rule, fix all 177 violations (#22741) 2026-04-15 23:27:32 -04:00
patch big format 2025-11-06 13:03:12 -05:00
permission refactor(core): migrate ConfigPermission.Info to Effect Schema canonical 2026-04-21 17:38:24 -04:00
plugin refactor: consolidate npm exports and trace flock acquisition (#23151) 2026-04-17 18:58:37 +00:00
project feat: unwrap storage namespaces to flat exports + barrel (#22747) 2026-04-15 23:30:49 -04:00
provider test: fix bedrock test (#23351) 2026-04-18 17:46:15 -05:00
pty refactor(pty): remove async facade exports (#22305) 2026-04-13 11:47:05 -04:00
question add experimental question HttpApi slice (#22357) 2026-04-14 19:43:49 +00:00
server refactor(server): align route-span attrs with OTel semantic conventions (#23198) 2026-04-18 00:29:26 +00:00
session refactor(core): make Config.Info canonical Effect Schema (#23716) 2026-04-21 14:06:47 -04:00
share refactor: eliminate account/ barrel, route consumers to sibling files (#22995) 2026-04-17 01:55:50 +00:00
shell feat: unwrap 11 util namespaces to flat exports + barrel (#22739) 2026-04-15 23:15:58 -04:00
skill feat: enable type-aware no-floating-promises rule, fix all 177 violations (#22741) 2026-04-15 23:27:32 -04:00
snapshot feat: unwrap 11 util namespaces to flat exports + barrel (#22739) 2026-04-15 23:15:58 -04:00
storage CLI perf: reduce deps (#22652) 2026-04-16 02:03:03 -04:00
sync refactor: convert Flag namespace to const object with getters (#22984) 2026-04-17 01:57:21 +00:00
tool chore: generate 2026-04-20 05:15:29 +00:00
util refactor(core): migrate ConfigPermission.Info to Effect Schema canonical 2026-04-21 17:38:24 -04:00
workspace fix(core): add historical sync on workspace connect (#23121) 2026-04-17 13:30:09 -04:00
AGENTS.md refactor(file): destroy FileTime facade (#22090) 2026-04-11 20:08:55 -04:00
keybind.test.ts feat: unwrap 11 util namespaces to flat exports + barrel (#22739) 2026-04-15 23:15:58 -04:00
npm.test.ts fix(plugin): parse package specifiers with npm-package-arg and sanitize win32 cache paths (#21135) 2026-04-06 00:26:40 +00:00
permission-task.test.ts feat: unwrap Config namespace to flat exports + barrel (#22689) 2026-04-15 21:26:24 -04:00
preload.ts feat: add LLM Gateway provider (#7847) 2026-04-17 10:29:31 -05:00