Skip to content

fix(setup): preserve user fields on an existing REA client entry - #1732

Closed
xeropresence wants to merge 21 commits into
morluto:mainfrom
xeropresence:fix/setup-preserve-entry-fields
Closed

xeropresence wants to merge 21 commits into
morluto:mainfrom
xeropresence:fix/setup-preserve-entry-fields

Conversation

@xeropresence

Copy link
Copy Markdown
Contributor

Summary

Re-running rea setup on a client that already has a rea server entry
rewrote that entry from scratch. Environment overrides were carried over (since
#1607), but every other field the user had added was lost. The visible case: an
OMP entry with "timeout": 0 (OMP's MCP request timeout; 0 turns it off, which
long IDA analyses need) came back without timeout, so the next long request
timed out.

Setup now changes only the keys REA owns in its entry and keeps the rest. A
second setup run makes no change, and rea doctor still reports the entry as
aligned.

No issue is linked; this was found while running REA under Bun with an IDA
provider registration in OMP.

Problem and expected behavior

Smallest trigger (~/.omp/agent/mcp.json):

{ "mcpServers": { "rea": {
  "type": "stdio", "command": "C:\\old\\bun.exe", "args": ["C:\\old\\rea.mjs", "mcp"],
  "env": { "REA_ANALYSIS_PROVIDER": "ida", "REA_IDA_MCP_CONFIG": "C:\\ida-mcp.json" },
  "timeout": 0
} } }

rea setup --client omp --yes wrote {type, command, args, env}, without
timeout. That breaks AGENTS.md's rule that configuration changes are additive.
The setup plan already said "Existing server environment overrides are
retained", so users had no reason to expect other fields to go.

Expected: the new command/args replace the stale launcher, env is kept and
merged as before, and timeout stays.

Change and scope

The desired entry is built in one place,
clientConfigurationDesired (src/application/SetupClientConfiguration.ts).
Setup writes it, and both alignment checks (setup preflight, --dry-run, and
clientConfigurationAligned) compare against it. That function now passes REA's
fresh entry through a new retainClientRegistrationFields(dialect, existing, registration) in ClientConfigurationDocument.ts. Because the merge happens
there, every writer (JSON/JSONC, Codex TOML, Grok TOML, Hermes YAML, OpenCode
V1/V2) and every "is it current?" check sees the same merged entry, so setup stays
idempotent.

Rules:

  • REA-owned keys get REA's values: the launch keys command, args, type,
    transport, env/environment, plus anything REA's entry sets for that
    dialect (tools for Copilot CLI, enabled: true for OpenCode V1/Command
    Code/Hermes, startup_timeout_sec for Codex and Grok Build). If REA's new entry
    leaves out a launch key, the existing one is removed. For example, a stale
    type: "http" is removed from a JSON entry, and an empty env map is not left
    behind.
  • Keys that contradict a local stdio entry are removed: url, httpUrl,
    serverUrl, headers, http_headers, env_http_headers,
    bearer_token_env_var, oauth. Keeping a stale url beside the new command
    could make a client pick the remote transport or reject the entry.
  • Entry-level off switches are removed: enabled: false, and disabled: true except on Grok Build. Setup's job is an active registration, and it
    already removes rea from OMP's disabledServers and Grok's
    disabled_mcp_servers for the same reason. Grok's entry-level disabled is
    kept because registration status does not treat it as an off switch for Grok
    either.
  • Everything else is kept: e.g. OMP/Pi timeout, enabled: true,
    instructions; Codex tool_timeout_sec, enabled_tools; Gemini/Cursor
    timeout, trust; Hermes timeout, connect_timeout. Existing key order is
    kept, and new REA keys are added at the end.
  • Remote entries are replaced whole: if the existing rea entry has no
    command, it is a remote server, and setup replaces it entirely as before.
    Merging its remote-only fields into a local entry would be wrong.
  • Legacy OpenCode V1 → V2 migration: only the entry in the table being
    written is used as the base. A V1 mcp.rea entry that moves into a native
    mcp.servers table keeps only its environment (as before), because its other
    fields use the V1 shape.

Every writable dialect is covered. Clients with format unsupported (manual
registration) have no entry for setup to merge, so nothing changes for them.

Not included: preserving comments inside the rea entry itself (the JSONC writer
still replaces the entry value as one unit; comments elsewhere in the file were
already kept), and any change to uninstall.

Contract and boundary impact

  • Semantic owner and earliest changed stage: clientConfigurationDesired in
    src/application/SetupClientConfiguration.ts, using the new
    retainClientRegistrationFields in src/application/ClientConfigurationDocument.ts.
  • CLI and MCP/tool-catalog contract: no new commands or flags. The setup plan's
    client detail now also says that other fields on REA's existing entry are
    retained (the existing "Existing server environment overrides are retained"
    wording is unchanged).
  • Provider, bridge, target-format, or platform compatibility: applies to every
    writable client dialect; no provider change.
  • Evidence, artifact, provenance, or reconstruction contract: not applicable.
  • Process execution, authorization, cleanup, or containment impact: none. Writes
    still go through the same backup, atomic-replace, and read-back path.
  • Generated metadata, package, or installation impact: none. docs/installation.md
    describes which keys setup rewrites, removes, and keeps.

Evidence and regression coverage

  • Tests added or updated:
    • tests/boundary/filesystem/clientRegistrationFields.test.ts (new): one case
      for each writable dialect (Cursor JSON, VS Code, OMP, Pi, Copilot CLI, Command
      Code, OpenCode V1, OpenCode V2, Codex TOML, Grok Build TOML, Hermes YAML). It
      seeds an entry with a stale command, env, dialect-specific user fields, a
      stale url and enabled: false, then runs inspectClientConfiguration →
      update, configureClientConfiguration → configured. It checks that the
      entry equals REA's entry plus the user fields, that
      clientConfigurationAligned → true and inspect → already_current, and
      that a second configure → unchanged with byte-identical file text. One more
      case checks that a remote entry (no command) is still replaced whole.
    • tests/boundary/filesystem/ompClientConfiguration.test.ts: the reported OMP
      case with timeout: 0 and an env override. It checks setup output,
      second-run byte identity, and readClientRegistrationStatuses → aligned.
  • Base reproduction: with src/ checked out from the base commit (0ecf3f2),
    all 12 field-retention tests fail (11 dialect cases plus the OMP timeout case),
    because the extra fields are dropped. The remote-entry test passes on base,
    since that behavior did not change.
  • User-visible CLI output: see the smoke run under Validation.
  • Remaining proof gaps: several existing setup/registration suites fail on this
    Windows + Bun machine on the base commit too (POSIX path expectations, symlink
    creation needing privileges, process.execPath alignment). Those suites were
    not proven locally and rely on CI.

Validation performed

All local validation ran under Bun 1.4.2 on Windows x64 without Node.js or
npm installed
. CI covers Node.

  • bun --bun run compile — succeeded.
  • bun --bun run artifacts:skills, artifacts:product-catalog,
    artifacts:error-schema, artifacts:mcp-catalog, artifacts:managed-evidence —
    succeeded (needed by docs checks).
  • bun --bun node_modules/vitest/vitest.mjs run tests/boundary/filesystem/clientRegistrationFields.test.ts — 12/12 passed.
  • bun --bun node_modules/vitest/vitest.mjs run tests/boundary/filesystem/client tests/boundary/filesystem/omp tests/boundary/filesystem/pi tests/boundary/filesystem/qwen tests/boundary/filesystem/hermes tests/boundary/filesystem/setup tests/boundary/filesystem/windowsNpx tests/boundary/filesystem/gemini tests/acceptance/setup tests/unit/application
    — branch: 50 failed / 200 passed / 4 skipped. Base (same command with the
    change stashed): 50 failed / 187 passed / 4 skipped. The failing test names
    are identical on both (Windows/Bun environment failures listed above). The 13
    extra passes are the new tests.
  • The same new tests with base src/ — 12 failed, 1 passed (see above).
  • bun --bun run typecheck — passed.
  • bun --bun run lint — exit 0. No new findings; the existing max-lines
    warning on ClientConfigurationDocument.ts was already there.
  • bun --bun node_modules/.bin/oxfmt --check on the six changed files — all formatted.
  • bun --bun run docs:check:built — passed. (docs:check itself refuses to
    start without npm's node_modules/.package-lock.json.)
  • Real CLI smoke run (temp root; HOME, USERPROFILE, APPDATA,
    LOCALAPPDATA pointed inside it; REA_IDA_MCP_CONFIG set to a temp JSON
    file): seeded home/.omp/agent/mcp.json with the entry from the Problem
    section, using a stale command/args.
    • bun scripts\rea.mjs setup --client omp --yes → exit 0. Resulting entry:
      "rea": {
        "type": "stdio",
        "command": "C:\\Users\\<user>\\.bun\\bin\\bun.exe",
        "args": ["<worktree>\\scripts\\rea.mjs", "mcp"],
        "env": { "REA_ANALYSIS_PROVIDER": "ida", "REA_IDA_MCP_CONFIG": "<temp>\\ida-mcp.json" },
        "timeout": 0
      }
      mcp.json.rea.backup equals the original file byte for byte.
    • Second setup --client omp --yes → exit 0, plannedActions: [],
      appliedActions: [], and the file is byte-identical to the first run's output.
    • bun scripts\rea.mjs doctor → registrations: - client: omp … state: aligned, remediation: null. Doctor exits 1 only because the placeholder IDA config
      ({}) is not a valid IDA MCP registration (ida-registration check), which
      has nothing to do with this change.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Entries that only contain REA's keys
    produce the same output as before. Entries with user-added fields now keep them
    instead of losing them.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows x64 with Bun only. No
    provider is exercised.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: setup still writes only the
    rea entry, still backs up first and reads back. Remote credentials
    (headers, bearer_token_env_var, oauth) on a stale entry are removed, not
    carried into the local registration.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T17:25:39.336062Z 7c13ffe New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 9523472031

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/SetupPlan.ts Resolved

@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: 751ed5f8d6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/SetupPlan.ts Resolved

@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: 02f23b618e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/SetupPlan.ts Resolved

@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: 410d84ce96

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@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: bbd753de4d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/SetupPlan.ts Resolved

@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: 94af3cef39

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/SetupPlan.ts Resolved

@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: 0fc0160296

ℹ️ 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".

@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: 341892a46e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@dandgabr dandgabr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consolidated review

  • P2 — Validate retained client-specific registration fields. In src/application/ClientRegistrationShape.ts:36 and src/application/ClientConfigurationDocument.ts:1435-1438, the shared schema accepts unknown fields through passthrough, so fields with client-specific types can be retained without dialect validation. For example, an invalid tool_timeout_sec: "900" can survive setup and be reported aligned even though Codex rejects it. Validate retained fields against the selected client dialect before preserving them. This consolidates the still-open inline finding; prior findings were resolved and no distinct security issue was found.

@xeropresence
xeropresence force-pushed the fix/setup-preserve-entry-fields branch from 341892a to 303008f Compare October 13, 2026 03:12
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[Medium impact] Refactors client registration field preservation logic.

The PR should not merge until setup stops carrying invalid Kimi enabledTools values into the refreshed entry.

Findings

  1. P1 Kimi keeps invalid tool settings ▶
  2. P2 Codex retention docs disagree ▶
  3. P2 Codex test checks wrong format ▶
Fix with agent prompt
### Issue 1
src/application/SetupClientConfiguration.ts:728-732
Kimi's `enabledTools` is copied into the fresh registration before retained fields are checked. That bypasses `registrationFieldAccepted`, since `retainClientRegistrationFields` trusts keys already in the fresh registration. The new Kimi schema rejects values such as `enabledTools: "*"`, but setup keeps them and can report the entry current while doctor reports it invalid. Check the copied value or let the retention helper handle it.

### Issue 2
docs/installation.md:79-80
The installation guide says every `tools` value is removed except on Copilot CLI. The implementation also keeps valid Codex per-tool maps. Document that exception so Codex users know their approval settings survive setup.

```suggestion
removed too. Valid Codex per-tool `tools` maps are kept, but sequences are
removed. GitHub Copilot CLI replaces `tools` with `["*"]`; other clients
remove it. An existing entry
```

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 3
src/application/Setup.planning.test.ts:162-164
The fake Codex client has no `format: "toml"`, so these assertions check the JSON fallback rather than the real Codex plan. They expect `tools` to be removed, while the real plan says valid per-tool maps are kept. This leaves the Codex message without a useful regression check. Set the fixture’s format to `toml` and assert that valid maps are kept.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Setup now keeps user-added fields on existing local REA entries while refreshing REA’s launch settings.

  • Running rea setup keeps custom fields on an existing client entry.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read client configuration] --> B[Build fresh REA entry]
  B --> C[Merge retained user fields]
  C --> D[Inspect and compare]
  C --> E[Back up and write]
  E --> F[Read back and compare]
  F -->|Matches| G[Accept write]
  F -->|Differs| H[Restore original]
Loading

Reviews (12) · Last reviewed commit: "test(setup): match approval disclosure e..." · Reviewed by Greptile

@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: 3370bab50b

ℹ️ 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".

Comment thread src/application/DshCordisPatch.ts Resolved
Comment thread src/application/DshCordisPatch.ts Resolved

@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: 1f1bb95d53

ℹ️ 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".

Comment thread src/application/Setup.planning.test.ts Resolved
Comment thread src/application/DshCordisPatch.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Fixed in 1f1bb95d5355d4c87330085aa305fe52e7348b9b. The exact recovery preview expectation omitted the returned dialect metadata. The existing recovery-backup boundary expectation now includes dialect:"json", matching inspectClientConfiguration and the other preview expectations. The configure-result expectation remains tied to its separate contract.

Validation: inspected the producing boundary and affected consumers; existing expectations were adjusted where the contract changed. Tests, mutation runs, builds, lint, typecheck and CI reruns were skipped at the user's explicit request. No new real-provider verification is claimed. This source correction does not settle separate integration authority or mutation-generation/score proof requirements.

  1. thread 1

Fixed in 1f1bb95d5355d4c87330085aa305fe52e7348b9b. The shared schema did not own ZCode’s singular enable key, so a malformed value passed through as unknown data. registrationSchemaFor now selects a ZCode schema with optional boolean enable. Both retention and registration diagnostics consume this schema: malformed values are removed during retention and rejected in diagnostics, while explicit false follows the existing activation replacement rule.

Validation: inspected the producing boundary and affected consumers; existing expectations were adjusted where the contract changed. Tests, mutation runs, builds, lint, typecheck and CI reruns were skipped at the user's explicit request. No new real-provider verification is claimed. This source correction does not settle separate integration authority or mutation-generation/score proof requirements.

  1. thread 1

Fixed in 1f1bb95d5355d4c87330085aa305fe52e7348b9b. The DSH approval text described config-field retention but omitted removal of the outer Cordis row disabled flag. The owning DSH retention description now explicitly discloses that the row-level disabled flag is removed to activate the registration, alongside launcher replacement and environment merge behavior.

Validation: inspected the producing boundary and affected consumers; existing expectations were adjusted where the contract changed. Tests, mutation runs, builds, lint, typecheck and CI reruns were skipped at the user's explicit request. No new real-provider verification is claimed. This source correction does not settle separate integration authority or mutation-generation/score proof requirements.

@morluto morluto added bug Something isn't working area: setup Setup, packaging, upgrade, install, Doctor, and client registration area: cli CLI adapter and one-shot commands area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026

@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: 7b90bc5a67

ℹ️ 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".

Comment thread src/application/DshCordisPatch.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Fixed in the verified live source head 7b90bc5. Harness planning assertion omitted the newly disclosed disabled flag. It now checks final wording and the disabled-flag clause. Prior history is preserved. Tests, builds, checks and provider runs were skipped as required; no additional source cleanup remains.

review thread

Fixed in the verified live source head 7b90bc5. Known Codex fields required/cwd/env_vars were unmodeled and malformed known values passed retention. Dialect schema now validates boolean/string/string-array types, so setup repairs malformed fields. Prior history is preserved. Tests, builds, checks and provider runs were skipped as required; no additional source cleanup remains.

review thread

Fixed in the verified live source head 7b90bc5. Approval disclosure omitted the row-level name rewrite. The owned DSH plan now states disabled removal and canonical name replacement. Prior history is preserved. Tests, builds, checks and provider runs were skipped as required; no additional source cleanup remains.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

The registration schema now accepts structurally valid Codex per-tool maps, and the retention owner now exempts only Codex/toml values from the non-Copilot tools deletion gate; malformed sequences still fail registrationFieldAccepted and are removed. Added a regression that configures and reads back the approval map. Published across 4509c13 and corrective commit 2069acd. Targeted formatting and diff checks only; tests were not run.

review thread

The serializer collapses duplicate literal id: rea-mcp rows to one canonical row, carrying fields from the last match; caller-only fields on earlier duplicate rows are discarded. The DSH approval detail now discloses this exact behavior before mutation. Added a focused expectation. Published in 4509c13 and clarified exact last-row wording in a236e5d. Targeted formatter and diff check passed; tests were not run.

@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: 2069acd6ec

ℹ️ 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".


const codexRegistrationSchema = registrationSchema.extend({
tools: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),
tool_timeout_sec: z.number().optional(),

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 Reject negative Codex tool timeouts

When an existing local Codex entry has tool_timeout_sec = -1, this z.number() validator accepts and retains it, so setup readback and doctor report the registration configured/aligned even though Codex cannot load it. Fresh evidence beyond the earlier wrong-type thread is that installed Codex 0.144.0-alpha.4 documents mcp get --json as “Output the server configuration as JSON”, but that command fails on this retained value with cannot convert float seconds to Duration: value is negative; require a nonnegative duration here.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

.passthrough();

const codexRegistrationSchema = registrationSchema.extend({
tools: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),

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 Validate Codex tool approval modes

When an existing Codex entry has a map-shaped tools value but tools.<name>.approval_mode = "bogus" (or a number), this unconstrained nested record accepts and retains it, and the shared doctor schema reports aligned. Fresh evidence beyond the earlier map-retention thread is that installed Codex 0.144.0-alpha.4 documents mcp get --json as “Output the server configuration as JSON”, while that command rejects the retained value as an unknown variant and requires one of auto, prompt, writes, or approve; validate the per-tool policy contract rather than only the outer map shape.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

Comment on lines +728 to +732
const retained = retainClientRegistrationFields(
format,
previous,
registration,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Kimi keeps invalid tool settings

Kimi's enabledTools is copied into the fresh registration before retained fields are checked. That bypasses registrationFieldAccepted, since retainClientRegistrationFields trusts keys already in the fresh registration. The new Kimi schema rejects values such as enabledTools: "*", but setup keeps them and can report the entry current while doctor reports it invalid. Check the copied value or let the retention helper handle it.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/SetupClientConfiguration.ts
Line: 728-732

Comment:
**Kimi keeps invalid tool settings**

Kimi's `enabledTools` is copied into the fresh registration before retained fields are checked. That bypasses `registrationFieldAccepted`, since `retainClientRegistrationFields` trusts keys already in the fresh registration. The new Kimi schema rejects values such as `enabledTools: "*"`, but setup keeps them and can report the entry current while doctor reports it invalid. Check the copied value or let the retention helper handle it.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment thread docs/installation.md
Comment on lines +78 to +79
removed too. A `tools` value is removed except on GitHub Copilot CLI, which
replaces it with `["*"]`; Codex rejects a `tools` sequence. An existing entry

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Codex retention docs disagree

The installation guide says every tools value is removed except on Copilot CLI. The implementation also keeps valid Codex per-tool maps. Document that exception so Codex users know their approval settings survive setup.

Suggested change
removed too. A `tools` value is removed except on GitHub Copilot CLI, which
replaces it with `["*"]`; Codex rejects a `tools` sequence. An existing entry
removed too. Valid Codex per-tool `tools` maps are kept, but sequences are
removed. GitHub Copilot CLI replaces `tools` with `["*"]`; other clients
remove it. An existing entry
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/installation.md
Line: 78-79

Comment:
**Codex retention docs disagree**

The installation guide says every `tools` value is removed except on Copilot CLI. The implementation also keeps valid Codex per-tool maps. Document that exception so Codex users know their approval settings survive setup.

```suggestion
removed too. Valid Codex per-tool `tools` maps are kept, but sequences are
removed. GitHub Copilot CLI replaces `tools` with `["*"]`; other clients
remove it. An existing entry
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

cursoragent and others added 17 commits October 15, 2026 13:14
A string such as enabled: "false" was kept and then accepted as the desired
entry, so setup could report success while doctor rejected the registration.
Those values are removed with the other managed switches.
Setup kept malformed startup_timeout_sec and tools values that doctor
rejects, and the approval plan restated retention rules by client name.
Both now use the registration schema and the entry the writer builds.
Setup keeps a registration field only when the schema doctor parses accepts it, and the OpenCode legacy disclosure follows that client's dialect.
The approval plan uses the dialect configuration inspection parsed, so a native OpenCode server table is not described as rewriting enabled.
Codex drops a tools array that its stdio config rejects, and the Harness approval plan lists the Cordis launcher keys the writer replaces.
Main's ZCode registration treats a native enable: false as stale and expects setup to repair it. Entry retention kept that switch, so setup reported unchanged while doctor still reported stale.
Setup retention and doctor validate Kimi's enabledTools with the client's own schema, as the earlier main merge on this branch did. Kimi's timeout fields stay in the shared schema that doctor parses for every client.
The Cordis disclosure names the retained row and the activation edits in separate sentences, and the Codex dry run no longer reports a replaced startup timeout. The plan application suite stays within the function length limit.
@xeropresence
xeropresence force-pushed the fix/setup-preserve-entry-fields branch from 1899092 to 7c13ffe Compare October 15, 2026 17:18

@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: 7c13ffeb43

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

.filter((key) => Object.hasOwn(entry, key))
.sort((left, right) => left.localeCompare(right))
.map((key) => `${key} with ${JSON.stringify(entry[key])}`);
return `Other fields on the retained Cordis server row are kept. Duplicate existing rows with id ${JSON.stringify(DSH_ENTRY_ID)} are collapsed to one canonical row using the last matching row, so fields unique to earlier rows are discarded. The row-level disabled flag is removed to activate the registration and name is set to ${JSON.stringify(DSH_CLIENT_PACKAGE)}. Setup replaces ${replaced.join(", ")}. Environment overrides are merged.`;

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 Disclose canonicalization of direct Harness patches

When the Harness config contains a top-level direct - id: rea-mcp patch, DshCordisDocument.serialize removes that operation; if it is the only such patch, its non-launcher fields are discarded before a fresh insertion is appended. This new disclosure only names duplicate inserted rows and otherwise says fields on the retained row are kept, so the approved plan omits a whole-operation removal for a supported repair path; explicitly disclose direct-patch canonicalization, including the direct-only loss.

AGENTS.md reference: AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

Comment thread docs/installation.md
Comment on lines +79 to +80
removed too. A `tools` value is removed except on GitHub Copilot CLI, which
replaces it with `["*"]`; Codex rejects a `tools` sequence. An existing entry

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 Document retained Codex tool policy maps

When a Codex entry contains a valid map such as tools.inspect.approval_mode = "prompt", registrationFieldAccepted("toml", ...) accepts it and the TOML retention path keeps it; only invalid or array-shaped Codex values are removed. These new lines instead say every tools value outside Copilot is removed, so the installation guidance misstates whether setup preserves a caller's per-tool approval policy; add the valid Codex-map exception.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you for this fix! Preserving client-owned fields and policy on an existing REA client registration during rea setup has since landed on main (in commit f5d791f2a1 / refreshClientRegistration in src/application/ClientRegistration.ts, further refined in #10430), so we are closing this PR as already landed.

@morluto morluto closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands area: domain Domain logic, errors, and pure functions area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants