Skip to content

Add general Codex router and usage controls - #23

Draft
gbharg wants to merge 8 commits into
DannyMac180:mainfrom
gbharg:codex/general-codex-router
Draft

Add general Codex router and usage controls#23
gbharg wants to merge 8 commits into
DannyMac180:mainfrom
gbharg:codex/general-codex-router

Conversation

@gbharg

@gbharg gbharg commented Aug 13, 2026

Copy link
Copy Markdown

Summary

  • add the sol-advisor:routing entrypoint and strict schema-v2 routine, medium-compatible high, hard, and advisor roles
  • migrate v1 profiles atomically while preserving legacy three-role uninstall and crash recovery
  • resolve parent versus fresh-agent routes from inspected runtime evidence, with bounded Fast and fail-closed model, effort, tier, and read-only checks
  • add pathless token/tool/compaction inspection without returning prompt contents
  • preserve the Terra implementer and Sol reviewer compatibility aliases

Verification

  • PATH=/opt/homebrew/bin:$PATH bun test (46 passed)
  • PATH=/opt/homebrew/bin:$PATH bun run ci
  • plugins/sol-advisor/scripts/verify.sh
  • git diff --check
  • real rollout inspection for model, effort, 5.83M raw tokens, 56 rounds, 55 tool calls, and zero compactions

Rollout

The live plugin and Codex defaults are unchanged in this PR. MBP backup, install, and canaries remain a separate rollout step after review.

@gbharg
gbharg marked this pull request as ready for review August 13, 2026 20:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 485e3114e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if(route.storageRole==="hard"&&prefs.hardRoute.status!=="runtime-pending"&&prefs.hardRoute.status!=="ready")return blocked("hard route is pending four-role preview consent");
if(!pref.effort)return blocked("configured effort is unavailable");
const expectedTier=machineTier==="fast"?"priority":"default";
const exact=(e:RuntimeEvidence|TargetRuntimeEvidence,targetEvidence=false)=>e.evidenceSource==="codex-rollout-inspector"&&e.executionContext===(targetEvidence?"agent":"parent")&&e.agentIdentifier===(targetEvidence?identifier:null)&&e.model===pref.model&&e.effort===pref.effort&&(machineTier!=="fast"||e.observedRuntimeTier==="priority")&&(machineTier==="fast"||e.observedRuntimeTier===null||e.observedRuntimeTier===expectedTier)&&(pref.readonly?e.sandboxPolicyType==="read-only":e.sandboxPolicyType!=="read-only");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind target proof to the freshly spawned agent

When any older rollout exists for the same configured role, its evidence satisfies exact because the check compares only the shared role identifier, model, effort, tier, and sandbox; the inspector's unique thread_id is not accepted by TargetRuntimeEvidence. Consequently a review or changed route can be marked verified using stale evidence without proving that the required fresh agent was spawned or that the evidence belongs to it. Include and validate the expected rollout/thread identity (or an equivalent per-spawn binding) before accepting target proof.

Useful? React with 👍 / 👎.

Comment thread plugins/sol-advisor/mcp/server.ts Outdated
Comment on lines +327 to +328
if(current.evidenceSource!=="codex-rollout-inspector"||current.executionContext!=="parent"||current.agentIdentifier!==null)return blocked("current runtime evidence provenance must be the parent inspector record");
if(target&&(target.evidenceSource!=="codex-rollout-inspector"||target.executionContext!=="agent"))return blocked("target runtime evidence provenance must be the agent inspector record","fresh_agent");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Accept runtime evidence from configured non-Codex clients

For a Cursor profile with persisted effort, every general route still requires evidenceSource === "codex-rollout-inspector", even though that inspector reads Codex rollout sessions and cannot produce evidence for Cursor. The inspected Cursor smoke workflow expects orchestration to use the configured routine and advisor roles, while orchestration mandates resolve_route for every general route, so a truthful Cursor caller must always block (or falsely label Cursor metadata as Codex evidence). Evidence provenance needs to be client-specific or support validated host-native details.

Useful? React with 👍 / 👎.

Comment on lines +49 to +51
def consistent($values; $label):
($values | map(select(type == "string" and length > 0)) | unique) as $unique |
if ($unique | length) == 1 then $unique[0] else error("inconsistent " + $label) end;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject incomplete turn-context evidence

When a rollout contains one valid turn_context followed by another that omits model, effort, or the sandbox type, consistent filters the missing value out and reports the older value as authoritative. This regresses the previous fail-closed behavior and lets resolve_route verify a current route even though one of its turns lacks required routing evidence. Reject every non-string or empty entry rather than discarding it before checking uniqueness.

Useful? React with 👍 / 👎.

Comment on lines +61 to +63
[ .[] | select(.type == "event_msg" and .payload.type == "token_count") | .payload.info ] as $token_infos |
[ $token_infos[]?.total_token_usage?.total_tokens | select(type == "number" and . >= 0 and floor == .) ] as $raw_tokens |
[ $token_infos[]?.last_token_usage?.input_tokens | select(type == "number" and . >= 0 and floor == .) ] as $input_rounds |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not report missing token usage as zero

If a rollout has no usable total_token_usage.total_tokens values—for example because a token_count record is incomplete or its shape changes—the inspector emits raw_tokens: 0 rather than unavailable/error. That makes an unobservable session indistinguishable from a zero-token session and causes the new raw-token budget control to fail open. Require a valid cumulative counter once runtime activity exists, or return an explicit unavailable value that blocks budget acceptance.

Useful? React with 👍 / 👎.

if(route.storageRole==="hard"&&prefs.hardRoute.status!=="runtime-pending"&&prefs.hardRoute.status!=="ready")return blocked("hard route is pending four-role preview consent");
if(!pref.effort)return blocked("configured effort is unavailable");
const expectedTier=machineTier==="fast"?"priority":"default";
const exact=(e:RuntimeEvidence|TargetRuntimeEvidence,targetEvidence=false)=>e.evidenceSource==="codex-rollout-inspector"&&e.executionContext===(targetEvidence?"agent":"parent")&&e.agentIdentifier===(targetEvidence?identifier:null)&&e.model===pref.model&&e.effort===pref.effort&&(machineTier!=="fast"||e.observedRuntimeTier==="priority")&&(machineTier==="fast"||e.observedRuntimeTier===null||e.observedRuntimeTier===expectedTier)&&(pref.readonly?e.sandboxPolicyType==="read-only":e.sandboxPolicyType!=="read-only");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require recognized writable sandbox evidence

For routine, medium, and hard routes, the sandbox predicate treats every value other than the exact string read-only as proof of writability. Because the server does not enforce the advertised JSON schema itself, omitted, empty, or unknown sandboxPolicyType values all make an otherwise matching route verified; the same applies to target evidence. This violates the fail-closed evidence gate and can dispatch implementation without any observed writable sandbox, so require a nonempty allowlisted writable policy rather than using a negative comparison.

Useful? React with 👍 / 👎.

@gbharg
gbharg marked this pull request as draft August 13, 2026 20:23
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