Repository navigation
fix(plugin): guard runs under the plugin's tool names and asks once; commands use tools that return what they ask for (2.1.0) - #1
Merged
Conversation
…e guard asks once instead of blocking a confirmed call (cpzai#2908)
…hey ask for (cpzai#2797, #2886, #2906, #2909)
…ailed calls and the whole input (cpzai#3024)
…tention and five more formula fixes (cpzai#3012, #3022, #3023)
…er writes Strategy Lab's format, book commands page (cpzai#3013, #3014, #3034, #3037)
…mes; the banner reads confirm like the guard and flags a missing python3 (review of #2908)
…, and the banner runs python3 instead of trusting command -v (re-review of #2908)
… with is_interrupt and duration; wider redaction; audit.log 0600 (re-review of #3024)
…ve balances apart, never one total (cpzai#3120)
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.
Fixes the plugin side of CPZ-Lab/cpzai bug sweep 11-18 (plugin-accounts group). The server side is CPZ-Lab/cpzai#3197. Version 2.1.0, so installed copies pick it up.
mcp__plugin_cpzai_cpzai__*(create_strategy, update_strategy, execute_strategy, delete_webhook...), the hooks matchmcp__cpzai__*, and the plugin data folder holds no audit.log. The old guard always answered{"decision":"block"}and stored nothing^mcp__(plugin_cpzai_)?cpzai__(...)$. Newscripts/pre_trade_guard.pyanswerspermissionDecision: "ask"with an order summary (side, qty, symbol, type, price, account, default environment): Claude Code asks the user once and runs the call on approval. Allallowed-tools, agenttoolsanddisallowedToolsuse the plugin names (the agents could not reach any CPZAI tool before). Audit log no longer recordsok: truefor every call. execution-reviewer checks buying power withcash_summaryand volume and ADV withget_barstests/test_hooks.py(9 of 11 fail on main)execute_strategytakes onlystrategy_idandcode; CPZAI docs: it "runs code and can submit orders" and no tool launches a backtest; commands/backtest.md and 3 skills said to backtest with itget_backtest_results,get_backtest_result) and says runs start in Strategy Lab; skills corrected; quant-researcher can no longer callexecute_strategytests/test_content.pyget_market_datarefusesSPY261218P00600000("Alpaca has no stock under the symbol") and an AAPL quote carries no P/E or fundamentalsget_barstests/test_content.pylist_accountsrow: broker, environment, status, tradable, timestamps, no money fields;cash_summaryhas themcash_summary; /trade checks the account'senvironmentagainst the paper defaulttests/test_content.pycompute_riskreturns no per-holding beta, volatility or factor exposure; the reporter's positions havesectornull (production SQL)get_bars; sector only where recorded; week and month P&L and margin used removed; every command carries the "not available from CPZAI, never from memory" rule; CONNECTORS.md lists what each tool returnstests/test_content.pyLimits, stated in CONNECTORS.md:
list_accountsenvironment check in /trade and execution-reviewer. The hook cannot check the account's environment:place_orderinput carries the account id, not its environment. A hard check needs the MCP server to accept and verify an expected environment (CPZ-Lab/aquila-mcp-server).permissionDecision: "ask"is the documented Claude Code PreToolUse decision. Whether Cowork honours it is not verified; /trade asks in chat when no session banner shows the guard running.Tests:
bash tests/run-all.sh --offline: structure validation OK,test_hooks.py11 passed,test_content.py10 passed. On origin/main the two new suites fail:test_hooks.pywith 2 failures and 7 errors,test_content.pywith 9 failures. The validator now also rejects the shortmcp__cpzai__names and knows the current 39-tool catalog.Wave 2 (11-25): three more commits
successfield PostToolUse does not send, never readstool_response, registers no failure hook, and cuts input at 240 charactersscripts/audit_log.py: refusals with their reason, brokerorder_idandstatus,PostToolUseFailurecalls, the whole input with credential fields redactedMCTR_i = w_i (Σw)_i / σandCR_i = w_i MCTR_igive Σ CR = 0.0657 against the claimed σ² = 0.0384 on a 4-asset book (test); portfolio-optimization's ERC sentence is the minimum-variance conditionplace_orderschema:price,stop_price, positive sharequantity,time_in_forceday only; /trade had one price and offered$500place_ordersays a resend returns the first order;cpzai://guides/tool-usagesays there is no end-to-end idempotent retry guarantee; MCPlist_ordershas noclient_order_idparameter though REST supports itclient_order_idinlist_ordersfirst. Remaining (CPZ-Lab/aquila-mcp-serversrc/tools.ts): fix theplace_orderdescription and addclient_order_idtolist_orderssrc/lib/backtest-templates.ts) refuses code without a module-levelgenerate_signal,generate_signalsoron_bar("No strategy interface function is available"); the command asked for generic numpy/pandas codeSYMBOLS, one module-level signal function returning weights, polars frames, no live callslist_positions/list_ordersonce; the tool and guide say to page until a short pageaccount_errorsTests:
bash tests/run-all.sh --offlinepasses (validator OK,test_hooks.py15 passed,test_content.py18 passed). The new wave-2 tests fail on this branch's previous head (8 content failures, 6 hook errors).Review fixes (independent review, plugin head 69bf885)
{}, a missing or non-stringtool_name, an unrecognised tool name, a non-object input and any exception inside the guard now answerask(they used to exit 0, or exit 1 on a TypeError, which Claude Code treats as non-blocking). The user's ownrequire_trade_confirmation=falsestill turns it off.session-start.shreadsconfirm=the way the guard does (only false, 0, no or off turn it off) and showsguard=OFF (python3 not found ...)withconfirm=falsewhen python3 is missing.add_to_watchlist/remove_from_watchliststay unguarded on purpose: they edit a 10-symbol watch list, move no money and are undone by the opposite call. Stated in CONNECTORS.md.Tests:
bash tests/run-all.sh --offlinepasses (test_hooks.py18 passed,test_content.py18 passed). On the previous head 6f60701^ (e75003e), 4 of the new guard and banner tests fail.Re-review fixes
"onFailure": "block"on the PreToolUse guard (Claude Code 2.1.295+): a guard that cannot start, exits with an error or times out blocks the call.session-start.shnow runs python3 (the/usr/bin/python3stub on a Mac without developer tools passedcommand -v) and showsguard=OFF (no working python3 ...)withconfirm=false.ok: nullwithoutcome"unknown: reconcile with list_orders before any resubmission" (orders and strategy runs) or "check the resource", plusis_interruptandduration_ms. Redaction widened (auth, credential, bearer, cookie, pass, pwd, pin, private, signature; identifiers ending in_idkept);create_connectionconfiguration logged as field names only;audit.logcreated 0600./sync,/positionsand/portfolio-reviewshow paper and live balances on separate lines fromtotals.by_environment(cpzai#3120, server side in CPZ-Lab/cpzai#3206).Tests:
bash tests/run-all.sh --offlinepasses (test_hooks.py24,test_content.py19). On the previous head 6f60701 the new guard and banner tests fail (3), and on f3f0298 the new audit tests fail (5).