Skip to content

feat: migrate conditions to shared conditions-core evaluator (byte-identical) - #17

Merged
Juliusolsson05 merged 2 commits into
mainfrom
feat/conditions-core-evaluator
Jun 22, 2026
Merged

Juliusolsson05 merged 2 commits into
mainfrom
feat/conditions-core-evaluator

Conversation

@Juliusolsson05

Copy link
Copy Markdown
Owner

What

Migrate Codex's headless conditions onto the new generic conditions-core evaluator (vendored from agent-code's `src/shared/conditions-core`), proven byte-for-byte against the prior builder implementation.

Changes

  • Vendored core (`src/conditions/core/{contract,evaluator}.ts`): the headless slice of conditions-core, copied in by agent-code's `scripts/sync-conditions-core.mjs`. Header-stamped GENERATED — do not hand-edit. (Submodules can't import the app's `src/shared`.)
  • Modules: `trustDialogModule` + `approvalModule` (`defineModule` shape). The approval module preserves the EXACT two-source merge (screen `approval` + rollout `approvalMetadata`) and the exact pty actions (`\r`, `p`, `\x1b`; trust `accept`/`2\r`).
  • `CODEX_MODULES = [trustDialogModule, approvalModule]` — order preserved (trust first); insertion order is observable via the `JSON.stringify(conditions)` dedupe key.
  • `evaluateCodexConditions` + `codexConditionSnapshotKey` kept exported (re-implemented via the evaluator) so existing importers are unchanged.
  • `CodexHeadless.publishConditionSnapshot` repointed to a long-lived `makeEvaluator('codex', CODEX_MODULES, () => Date.now())`. Emitted snapshot shape + the two events (`conditions` and `event{type:'conditions'}`) are byte-identical. Legacy per-event `trust-dialog` emission untouched.

Byte-for-byte golden matrix

Throwaway script ran OLD (inline copy of prior builders) vs NEW over the full matrix; assert `JSON.stringify(snapshot.conditions)` identical (ts excluded, keys NOT sorted):

Case Result
trust hidden, no approval PASS
trust visible, no approval PASS
approval screen-only PASS
approval metadata-only PASS
approval screen+metadata PASS
approval metadata-cleared (screen present, meta null) PASS
trust visible + approval screen+metadata (both live, order) PASS
approvalMetadata undefined (omitted) PASS
screen with null command + metadata PASS

ALL PASS.

Typecheck

`npx tsc --noEmit` and full `npx tsc` build: 1 error — `SemanticChannel.ts:283` — which is pre-existing on main (unrelated). Zero new errors.

🤖 Generated with Claude Code

…entical)

Migrate Codex's headless conditions onto the new generic conditions-core
evaluator vendored from agent-code's src/shared/conditions-core. The trust
dialog and approval builders become ConditionModules; CODEX_MODULES preserves
trust-before-approval insertion order (observable via the JSON.stringify dedupe
key). CodexHeadless.publishConditionSnapshot now drives a long-lived
makeEvaluator instance. Verified byte-for-byte against the prior builder path
across the full input matrix (trust hidden/visible; approval
absent/screen-only/metadata-only/screen+metadata/metadata-cleared/null-command).

The vendored core (src/conditions/core/{contract,evaluator}.ts) is GENERATED by
agent-code scripts/sync-conditions-core.mjs and must not be hand-edited.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… review fixes

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Juliusolsson05
Juliusolsson05 merged commit f9faa35 into main Jun 22, 2026
@Juliusolsson05
Juliusolsson05 deleted the feat/conditions-core-evaluator branch June 22, 2026 08:30
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