Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/test_live_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,20 @@ def test_codex_never_overrides_a_key_the_user_set(tmp_path):
assert kept == "[agents] # t\nmax_threads = 4\n"


def test_codex_apply_does_not_record_a_capability_the_user_already_set(repo, tmp_path,
codex_accepts):
st = Store(str(tmp_path / "st"))
path = denylist.settings_path(repo, "codex")
os.makedirs(os.path.dirname(path))
with open(path, "w", encoding="utf-8") as f:
f.write("[features]\ngoals = true\n")
assert denylist.apply(repo, ["goals"], st, host="codex") == []
assert denylist.applied(st) == []
assert open(path, encoding="utf-8").read() == "[features]\ngoals = true\n"
assert denylist.apply(repo, ["goals", "image_media"], st, host="codex") == ["image_media"]
assert denylist.applied(st) == ["image_media"]


def test_codex_trust_is_read_from_the_users_config(tmp_path, repo):
home = tmp_path / "codex-home"
home.mkdir()
Expand Down
7 changes: 5 additions & 2 deletions tokeneconomizer/plugin/denylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,12 @@ def _apply_codex(repo_root, capabilities, store):
for cap in capabilities:
if cap not in CODEX_TOGGLES or cap in applied(store, path):
continue
changed = False
for table, key, value in CODEX_TOGGLES[cap]:
text, _ = _toml_insert(text, table, key, value, f"{MARK}:{cap}")
added.append(cap)
text, did = _toml_insert(text, table, key, value, f"{MARK}:{cap}")
changed = changed or did
if changed:
added.append(cap)
if not added:
return []
if not _toml_valid(text):
Expand Down
Loading