Skip to content

feat: add read-only Zapier MCP setup for Codex (QUA-2406) - #225

Merged
Desperado merged 4 commits into
mainfrom
feat/qua-2406-zapier-codex
Nov 16, 2026
Merged

Desperado merged 4 commits into
mainfrom
feat/qua-2406-zapier-codex

Conversation

@Desperado

@Desperado Desperado commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Adds explicit read-only Zapier MCP setup and discovery for the Codex backend through qmax-code zapier connect|status|disconnect. Setup and agent turns honor the selected CODEX_HOME, preserve existing MCP configuration and credential-storage choices, and refuse conflicting custom configuration.

Native OAuth uses keyring-only MCP storage and exactly inspect_zapier_actions / execute_zapier_read_action. Configuration changes are atomic and serialized across qmax processes. Discovery records structural metadata only and refuses interactive requests. The agent prompt treats external business content as untrusted data; it is not a deterministic execution sandbox.

Epic: QUA-2405. Ticket: QUA-2406.

Acceptance evidence:

  • Configuration preservation, selected-home behavior, custom configuration refusal, concurrent disconnect, protocol/error/cancellation/permission checks, and real subprocess shutdown regressions.
  • Native Codex 0.144.5 discovery: qmax four tools, historically qualified 9lives 0.6.0 seven tools, missing-auth failure with zero Zapier tools and a nonzero exit.
  • User completed OAuth. Actual native inventory reports Zapier OAuth and exactly the two allowed tools alongside qmax and 9lives. A qmax-code --local --backend codex turn executed Google Sheets get_data_range for one selected A4:K4 range on 2026-11-16. The direct tool result verified one row and source identifiers. No business-app write executed. Private sanitized receipts remain in the workspace.
  • Live provider-revocation failure and OAuth recovery: user authorized Disconnect for the Zapier codex client. Native status returned exit 1 and zero Zapier tools despite a cached oAuth label. Updated diagnostic explicitly suggests reconnect for revoked/expired access. After native OAuth login, status returned exit 0 with exactly the two allowed tools and qmax/9lives coexistence. No app action executed. Natural token expiry/automatic refresh were not exercised.

CODEX_HOME isolates configuration but does not isolate Codex 0.144.5 MCP keyring credentials: its key derives from server name and URL. Documentation makes that boundary explicit. User explicitly authorized provider revocation and restoration after the shared-keyring impact was explained; the full cycle is now verified and access restored.

Local validation for runtime code at head 5898b06: go test ./... passed across 20 packages; go vet ./... and release-style Go build passed; git diff --check passed before commit. Final ponytail review read the changed paths and connected callers and found no remaining confirmed code finding. Earlier validation on the unchanged runtime code includes CI-pinned golangci-lint v2.15.0 (zero issues), atomic-coverage suite, and Windows lock-path cross-compilation. No Windows runtime qualification. No pre-commit configuration exists in this repository.

Review fixes in 3a2dc5f: disconnecting an absent server leaves configuration unchanged, including a fresh home; the Codex version probe bounds inherited output pipes after exit/cancellation. Added subprocess coverage for connect/status/disconnect, refusal/error paths, output failures and both inherited-pipe cases. Both Copilot threads are resolved with fix/test evidence.

Previous-head CI (3a2dc5f, not evidence for 861e357): required build-and-test and Run Go Tests, Code Health, and both Socket checks passed. QualityMax Pipeline completed neutral, with 1588/1588 Go tests passing; AI diff review 17/17 files and SAST 19/19 completed. AI Tests were blocked before execution by sandbox_concurrency_limit; go_test; preview gate skipped without a deployment. The exact-head review delivered no blocking findings; two model-only advisories were checked against the existing frame/page limits, deadline, typed parsing, RPC-ID matching and sanitized output allowlists, with no concrete defect reproduced.

Previous-head Codecov: patch 207/239 lines (86.61088%, 32 missing, previously 63); overall 85.82%. Coverage upload succeeded, but the missing-line warning remains. Local aggregate statement coverage was 85.2%, runZapierCommand 92.7%.

Previous documentation head 861e357: required CI and Socket checks passed; QualityMax Code Health passed and Pipeline completed neutral with 1588/1588 tests, review/SAST complete, AI Tests sandbox-blocked and no preview deployment. Its Go-test reporting step emitted HTTP 401 (Invalid API key): tests passed, but external delivery failed. The workflow references repository secret QAMAX_API_KEY; its value was not read or changed.

Live follow-up 5898b06 adds the reconnect diagnostic and a subprocess regression for the actual cached-oAuth/empty-inventory response. Local full tests, vet, release build and final ponytail review passed. Exact-head CI completed: required build-and-test and Run Go Tests, Code Health (A, 100/100, zero findings) and both Socket checks passed. QualityMax Pipeline completed neutral: 1589/1589 Go tests passed, AI review 17/17 files and SAST 19/19 completed, exact-head review #5923075959 delivered no blocking or inline findings. AI Tests were blocked before execution by sandbox_concurrency_limit; preview gate skipped without deployment. Four model-only advisories were checked against reachable callers, bounded/typed discovery and ASCII output validation; no concrete defect reproduced. Go-test external report delivery still warns HTTP 401 Invalid API key; QAMAX_API_KEY was not read or changed. No release or deployment.

Evidence limits: the returned completed/passed row is historical demo data, not a new test result. The agent's final answer omitted returned fields and confused a pinned GitHub revision with a sheet revision; the direct result projection preserves the fields and marks sheet revision unknown. Deterministic provenance belongs to QUA-2408. The earlier v1.40.2 approved Sheets append is complete and must not be replayed.

No application dependency changes, migrations, write broker, result-write command, release or deployment. 9lives doctor previously reported missing Playwright dependencies at this Go repository root; no runner/browser test execution is claimed. Full before/after workflow, provenance and approved result delivery remain QUA-2407–2410. See docs/ZAPIER_MCP.md for setup and qualification boundaries.

@qualitymaxapp

qualitymaxapp Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

QualityMax Review

Verdict: COMMENT · Confidence: model judgment; findings have not been reproduced

Re-review: Open the QualityMax check and select Re-review after it completes.

Files eligible: 19 · Files reviewed: 19 · Files with findings: 2 · Findings: 4 · Inline cards: 0

Priority findings

priority location finding
— — No blocking findings

Review gates

gate status
AI diff review completed · eligible 17, reviewed 17 · MODEL-ONLY findings are advisory · batches reviewed 2 of 2 · LLM · served gemini-3.1-flash-lite
SAST completed · eligible 19, reviewed 19 · hybrid · served qwen3.7-plus
Overall review evidence non-blocking findings remain
Inline evidence not needed

Important files

file risk note next step
— — No findings —
Advisory MODEL-ONLY candidates (4)

These model judgments do not block this PR and are not posted inline. Check reachable callers and existing protections, and reproduce a concrete failure before treating a candidate as a defect. A second model's confirmation or a model-reviewed patch does not reproduce a failure.

location candidate served model
internal/agent/codex_config.go:24 The CODEX_HOME environment variable is used to construct file paths without validation, allowing potential path traversal attacks. An attacker could set CODEX_HOME to an arbitrary directory to read or write files outside the intended configuration location. gemini-3.1-flash-lite
internal/zapier/discovery.go:31 The Discover function accepts a 'binary' argument that is passed directly to exec.CommandContext. If this argument is user-controlled, it could lead to arbitrary command execution. gemini-3.1-flash-lite
internal/zapier/discovery.go:95 JSON unmarshaling of untrusted data from Codex subprocess without strict validation. The 'safeName' regex check at line 108 is insufficient—tool names are validated but other fields in the JSON response are not fully validated before use. qwen3.7-plus
internal/zapier/discovery.go:108 The safeName regex `^[a-zA-Z0-9_.-]{1,128}$` allows dots and hyphens in tool names. While this appears intentional, combined with the tool name being used in error messages and logs without escaping, it could enable log injection or other attacks if tool names are displayed to users. qwen3.7-plus

Change diagram — Flow

graph TD
    A[WriteMCPConfig] --> B[CodexConfigPath]
    B --> C{CODEX_HOME set?}
    C -- Yes --> D[Use CODEX_HOME]
    C -- No --> E[Use UserHomeDir]
    D --> F[updateCodexConfig]
    E --> F
    F --> G[tryCodexConfigLock]
    G --> H[upsertCodexMCPEntry]
    H --> I[Write Config]
Loading

Review lifecycle

Use the inline cards to inspect evidence and suggested remediation. Re-run the QualityMax review after pushing a fix; unchanged cards are identified by their stable finding marker. Dismiss with a reason through the existing QualityMax/GitHub review feedback flow. 0 prior card(s) are stale/resolved on this head. @qmax Q&A is tracked separately.

Proof legend: GROUNDED deterministic scanner evidence · MODEL-ONLY advisory model judgment · MODEL-REVIEWED patch model judgment, not reproduction.

QualityMax project results are available in the configured project.

Receipt · commit 5898b063236de95d08c7649e75895fe913b30ab2 · run 2026-11-16T15:59:59+00:00 · model served qwen3.7-plus, gemini-3.1-flash-lite · model requested qwen3.7-plus, gemini-3.1-flash-lite · model review recorded — 7970 model output tokens · model source repository ai_review_preferences.preferred_model · re-review 2 · proof counts {'MODEL-ONLY': 4}

@qualitymaxapp qualitymaxapp 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.

QualityMax Review — canonical overview updated; no inline findings were created for this review.

@qualitymaxapp

qualitymaxapp Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

QualityMax Code Health

Grade A · 100/100 · PASS — 0 finding(s) in 19 file(s).

No code-health findings.

Full report · Commit 5898b06

@codecov-commenter

codecov-commenter commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.61088% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/agent/codex_config.go 76.08% 11 Missing ⚠️
internal/zapier/discovery.go 90.38% 10 Missing ⚠️
main.go 0.00% 5 Missing ⚠️
zapier_command.go 93.33% 3 Missing ⚠️
internal/agent/zapier_config.go 92.30% 2 Missing ⚠️
internal/setup/orch.go 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@qualitymaxapp

qualitymaxapp Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

⚠️ QualityMax Pipeline

Gate Result
🔍 AI diff review ℹ️ 2 advisory MODEL-ONLY candidate(s) · gemini-3.1-flash-lite · completed · 17 eligible / 17 reviewed · gemini-3.1-flash-lite
🔍 SAST completed · 19 eligible / 19 reviewed · qwen3.7-plus
🔍 Canonical PR review delivery completed · 0 eligible / 0 reviewed · exact-head review #5923075959 and overview #6915167572 confirmed
🔍 Repository runtime evidence completed · 0 eligible / 0 reviewed · runtime execution passed for the assessed revision
🔍 Runtime evidence policy completed · 0 eligible / 0 reviewed · admissible runtime evidence satisfies this advisory runtime-only policy
🧪 Repo Tests ✅ 1589/1589 passed (go)
🤖 AI Tests ❌ blocked before sandbox execution (sandbox_concurrency_limit; go_test)

Powered by QualityMax — AI-Powered Test Automation

Copilot AI 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.

🟡 Changes recommended

The command timeout can still hang on inherited output pipes, and disconnecting with a fresh CODEX_HOME writes configuration that causes the next connect to fail.

2 open issues
What changed in this PR

Adds opt-in, read-only Zapier MCP setup for qmax-code’s Codex backend using native Codex OAuth and transport. Authenticated tool filtering, an agent-mediated source read, and revoked/expired-auth behavior remain pending live qualification.

Changes:

  • Adds zapier connect|status|disconnect, keyring-only OAuth setup, and structural discovery.
  • Uses the selected CODEX_HOME consistently and serializes configuration updates while preserving unrelated settings.
  • Adds regression coverage, untrusted-content prompt guidance, and setup documentation.
File Description
zapier_command.go Implements connection, status, and disconnect commands.
zapier_command_test.go Tests command validation and selected-home disconnect behavior.
README.md Links to Zapier setup documentation.
main.go Routes the Zapier subcommand.
internal/​zapier/​process_test.go Tests shutdown with inherited subprocess streams.
internal/​zapier/​discovery.go Implements structural discovery and read-tool validation.
internal/​zapier/​discovery_test.go Tests protocol handling, filtering, cancellation, and failures.
internal/​setup/​orch.go Uses the selected Codex home during setup and detection.
internal/​setup/​orch_test.go Isolates tests from inherited CODEX_HOME.
internal/​agent/​zapier_config.go Manages the read-only Zapier entry and credential-policy checks.
internal/​agent/​zapier_config_test.go Tests preservation, refusal cases, concurrency, and home selection.
internal/​agent/​mcp_reconnect_test.go Clears inherited CODEX_HOME in test setup.
internal/​agent/​codex_config.go Centralizes home selection and locked configuration updates.
internal/​agent/​codex_config_test.go Accounts for the retained lock file.
internal/​agent/​codex_config_lock_windows.go Adds Windows configuration locking.
internal/​agent/​codex_config_lock_unix.go Adds Unix configuration locking.
internal/​agent/​codex_agent.go Uses the selected home and adds external-content safeguards.
docs/​ZAPIER_MCP.md Documents setup, scope, disconnect limits, and qualification status.

Review effort: Balanced

Comment thread internal/agent/zapier_config.go Resolved
Comment thread zapier_command.go Resolved
@Desperado
Desperado requested a balanced review from Copilot November 16, 2026 14:10
@Desperado
Desperado marked this pull request as ready for review November 16, 2026 14:10

Copilot AI 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.

🔵 Needs a closer look

Disconnecting an unconfigured Zapier integration can block its first connection, and the version probe can hang beyond its timeout when launcher descendants keep output pipes open.

2 open issues

Review effort: Balanced

@qualitymaxapp qualitymaxapp 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.

QualityMax Review — canonical overview updated; no inline findings were created for this review.

😸 2 finding(s) auto-dismissed by the Finding Verifier
  • llm-path-traversal internal/agent/codex_config.go:27 — false positive: CODEX_HOME is an environment variable controlled by the local user executing the tool, so writing to an arbitrary path on their own filesystem is not a path traversal vulnerability.
  • llm-command-injection internal/zapier/discovery.go:48 — false positive: exec.CommandContext executes the binary directly without a shell, so shell metacharacters are treated as literal filename characters and cannot cause injection.

Auto-dismissals are advisory. If a dismissal looks wrong, treat the finding as blocking and request a verifier review.

@qualitymaxapp qualitymaxapp 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.

QualityMax Review — canonical overview updated; no inline findings were created for this review.

😸 2 finding(s) auto-dismissed by the Finding Verifier
  • llm-command-injection internal/zapier/discovery.go:48 — false positive: exec.CommandContext uses an argv list without invoking a shell, and all subsequent arguments are strictly hardcoded, preventing any shell injection or arbitrary command execution.
  • llm-path-traversal internal/agent/codex_config.go:27 — false positive: CODEX_HOME is an environment variable controlled by the local user running the tool, so overriding the config path is intended behavior, not a path traversal vulnerability.

Auto-dismissals are advisory. If a dismissal looks wrong, treat the finding as blocking and request a verifier review.

@qualitymaxapp qualitymaxapp 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.

QualityMax Review — canonical overview updated; no inline findings were created for this review.

😸 2 finding(s) auto-dismissed by the Finding Verifier
  • llm-path-traversal internal/agent/codex_config.go:26 — false positive: CODEX_HOME is an environment variable controlled by the local user executing the tool, so specifying an arbitrary path does not cross a privilege boundary.
  • llm-command-injection internal/zapier/discovery.go:48 — false positive: exec.CommandContext uses an argv list without invoking a shell, so it is not susceptible to shell command injection.

Auto-dismissals are advisory. If a dismissal looks wrong, treat the finding as blocking and request a verifier review.

@Desperado
Desperado merged commit 2f9f950 into main Nov 16, 2026
6 checks passed
@Desperado
Desperado deleted the feat/qua-2406-zapier-codex branch November 16, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants