Repository navigation
[blocked on core release] Best-of-N attempt comparison, codex driver, keyless operation in agent hosts - #19
Merged
Merged
Conversation
…n in agent hosts consensus_compare_attempts and consensus_list_attempts (stdio only). The server computes each attempt's diff with git via execFile, so diffs never pass through the calling agent's context: - refs validated with rev-parse --verify --end-of-options, and refused when they start with "-" - read-only: --no-ext-diff --no-textconv, fsmonitor off, GIT_OPTIONAL_LOCKS=0 - a checked-out attempt includes uncommitted and untracked changes - lockfiles, generated and binary files skipped; whole files dropped past a per-attempt token budget; omissions listed for jurors and the result The panel judges blind via ai-consensus-core's AdjudicationEngine (one round plus judge by default, deadline and token ceiling return partial results, progress per juror). Output: a short markdown verdict with the recommended ref first, plus the typed result in structuredContent. Optional testCommand (argv, no shell, per worktree, timeout) EXECUTES REPOSITORY CODE and is refused unless serve --allow-test-command. Keyless operation: - codex driver on `codex exec`, flags checked against the installed 0.170.0 help and accepted by a real run (approval never via -c approval_policy, read-only sandbox, shell tools disabled, --ignore-user-config, stdin prompt, -o answer) - CLI JSON mode: the CLI enforces the juror verdict schema - recursion guard AI_CONSENSUS_MCP_DEPTH on every CLI child; a server started with it >= 1 refuses to run - "envFile" config key (must not be group/world accessible, values never logged); the missing-key error names the allowlist cause - the wizard detects claude/grok/codex on PATH and offers a keyless panel first; "default" modelId omits -m for codex and grok Also skills/best-of-n-verdict/SKILL.md and a "Using with Emdash" README section. Tests that pinned the old "codex is refused" contract now pin the new one; unregistered-driver tests use a fake driver name. ai-consensus-core ^0.13.0 (unreleased).
…st timeouts
- Changes under agent tool directories (.claude/, .codex/, .grok/,
.cursor/, .gemini/, …) are skipped as "agent-files"; jurors see a count
only, because the paths can name the agent that produced the attempt.
- The jurors' omission header lists at most 20 paths per reason ("+N
more") and counts against the per-attempt token budget, so a vendored
directory cannot flood every prompt; the structured result caps file
lists at 50 with exact totals.
- README "Using with Emdash": Codex's 60 s default MCP tool timeout
(raise tool_timeout_sec) vs Claude Code's long per-call limit and
progress-reset stdio idle limit.
- Codex probe: the API-key refusal matches status text whose exact
wording was never observed; say so. The final argv (with and without
-m) was re-run against codex 0.170.0 and reached the API.
- envFile permission check skipped on Windows (no POSIX mode bits).
- Subscription example seats grok with modelId "default" (grok 1.0.89 no
longer lists grok-4); README no longer implies codex cannot be seated.
- Tests: the wizard's keyless and no-CLI new-config paths, a noisy
fixture attempt (vendored files + agent settings file).
marceloceccon
marked this pull request as ready for review
November 20, 2026 23:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Best-of-N attempt comparison (stdio only; never offered over HTTP or Workers).
consensus_list_attempts: branches, most recent first, with ahead/behind against a base (input, elseorigin/HEAD,main,master,HEAD), their worktree, and its uncommitted count. Makes no branch-naming assumption.consensus_compare_attempts:task,attempts: [{ref, label?, checks?}](2–6),repoPath(default cwd),base(default merge-base), and the existingpanel/participantIds/judge/maxRounds(default 1) /randomSeedknobs.deadlineMs,maxTokens,diffTokenBudget,includeUncommittedand opt-intestCommand.gitthroughexecFile, with no shell, so diffs never pass through the agent's context.rev-parse --verify --end-of-options, and anything starting with-is refused.--no-ext-diff --no-textconv, fsmonitor off,GIT_OPTIONAL_LOCKS=0.dist/,*.min.js,linguist-generated, …) and binary files are skipped. Whole files are dropped past the per-attempt token budget. Jurors get a header listing what was left out, and the result lists it too..claude/,.codex/,.grok/,.cursor/, …) are skipped and shown to jurors as a count only, since their paths can name the agent that produced the attempt.AdjudicationEngine. Progress notifications are sent per juror, and a deadline or token ceiling returns a partial result.structuredContentcarries the typed result plus per-attempt diff coverage, but no juror raw output and no diff bodies.testCommand: an argv array run in each attempt's own worktree, in its own process group, with a timeout; the exit status becomes a check. It executes repository code, so it is refused unlessserve --allow-test-command, which in turn is refused together with--http.Keyless operation inside agent hosts.
Codex driver on
codex exec(previously refused at resolve). The flags were checked against the installedcodex exec --help/codex --help0.170.0:-c approval_policy="never"(the documented exec route;-ais top-level only);--sandbox read-only;--disable shell_tool --disable unified_exec;--ignore-user-config(noconfig.toml, so no MCP servers; auth still usesCODEX_HOME);--ignore-rules --ephemeral --skip-git-repo-check --json;--output-schema, answer read from-o.The probe requires
codex login statusto succeed and refuses API-key auth.CLI drivers are now a uniform interface with a per-call JSON Schema ("JSON mode"). Juror verdicts are enforced by the CLI (
--json-schema/--output-schema) instead of the{answer, confidence}oracle schema, and come back untouched. The judge stays on the oracle schema.Recursion guard: every CLI child gets
AI_CONSENSUS_MCP_DEPTH= parent + 1, andserverefuses to start when it is ≥ 1."envFile"config key:KEY=VALUEfile read for provider keys;CONSENSUS_CONFIG_JSON/ Workers rejects it).Missing key: the error now names the variable, the provider and the allowlist cause ([feat]: Let users extend the agent env allowlist (MCP credentials referenced as ${VAR} are stripped) generalaction/emdash#3103), and points to
envFile. It still starts with the old text.Wizard: detects claude / grok / codex on
PATH(no execution) and, for a new config, offers a keyless panel first. Codex is now offered in the CLI form."modelId": "default"omits-mfor codex and grok, because model names rotate: grok 1.0.89 no longer listsgrok-4.Host timeouts (README): Codex gives an MCP tool call 60 s by default, so the README says to raise
tool_timeout_sec. Claude Code's limits are long, and its stdio idle limit resets on progress notifications. Values are from their docs, read today.Docs:
skills/best-of-n-verdict/SKILL.md(Agent Skills format: list, compare, report, never merge or delete; shipped infiles) and a "Using with Emdash" README section (Custom MCP setup, the skill, credentials).Why
In Emdash's best-of-N flow every attempt is a worktree off one base, and the user picks the winner by hand. This lets the agent in any attempt ask a blind panel instead. Emdash starts agents (and so MCP servers) with an allowlisted environment, so the server must work from signed-in CLIs, or from keys it loads itself, and must say so clearly when a key is missing.
How it was verified
npm run check(typecheck, eslint, prettier, 656 tests with coverage thresholds),npm run build,npm run test:smokeand the wrangler preflight all pass on Node 24 [executed]. Tests also pass on Node 20.20.2 [executed].refs/heads/-evilbranch and an orphan. Covered:-evil;GIT_OPTIONAL_LOCKS=0[executed].fetch;claude,grokandcodexrecords argv, stdin or prompt file, cwd, scratch contents and env. Checked:-oanswer and usage;buildCodexArgv, with and without-m, was accepted by a realcodex execthat reached the API and failed only on auth. A bogus flag fails at parse [executed].PATH→ keyless chosen → saved → re-validated and resolved with no keys), as does the no-CLI path [executed].GROK_HOMEandgrok mcp doctor: a stub server receivedAI_CONSENSUS_MCP_DEPTH=1and an arbitrary canary variable, and the user's grok config was unchanged [executed]. A live grok session spawning servers is assumed to behave the same [assumed].haiku) and grok 1.0.89 (grok-4.7-build-fast) in JSON mode both returned strictly valid verdicts;good";Deviations from the brief
CliDriverprobe/run with claude and grok). This PR adds codex and JSON mode rather than introducing the interface.--prompt-fileinside the empty scratch dir, not stdin: grok 1.0.89 advertises no stdin mode. It is still never on argv.--permission-mode dontAsk; I did not verify how grok treats MCP tool calls under that mode.shell_toolandunified_execplus the read-only sandbox. I found no flag that turns off every codex tool.codex login status; the exact wording for an API-key login was never observed [assumed].issue,summary) can still mention juror-local labels in the judge and rebuttal prompts. Jurors are told not to, but this is not enforced (core limitation).envFilepermission check is skipped, since there are no POSIX mode bits.[Unreleased]entry.What is left