Repository navigation
fix(core): resourceTools reads only llmReadable collections, without secret fields (FIX-2436) - #4426
Conversation
…secret fields (FIX-2436) readResource resolved a path against every registered collection and returned the full stored state, so a worker given resourceTools() beside a collection it may not show the model (a user's MCP keys) could read it. The read now reaches only a collection that opted in with llmReadable, the gate the content and search tools already apply, and drops the fields the collection names in secret. Any other path answers as one no collection matches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGRHaqqMGz8cJxCeoQ
…436) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGRHaqqMGz8cJxCeoQ
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Second look + architecture pass (FIX-2436)Verdict: the approach is right and about as lean as it gets. Reusing the collection's own 1. Real gap: writes still reach the key (follow-up, not necessarily this PR)
On the PR's worry that gating on 2. Small reuse nit: the gate is now written inline a fourth time
3. Nits
Architecture (improve-codebase-architecture lens)No refactor is justified by this PR. The one structural smell is the repeated read-gate expression above, which the one-line reuse fixes without a new abstraction. A broader "single visibility gate for all generic resource tools" module would be speculative until the write-gate follow-up shows what shape both sides share, so revisit it there. Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 40814a1200
ℹ️ 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".
…k a consumer (FIX-2436) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGRHaqqMGz8cJxCeoQ
There was a problem hiding this comment.
/simplify review (FIX-2436)
Verdict: approve. This is a small, behavior-aligned fix, not an over-built layer. The risky alternative would have been a new abstraction or a second resolution path; instead you extended the existing resolvePathToCollection(..., intent) split (read vs write) and reused omitSecretFields, which is the same primitive client-projection already documents for server-leaving reads.
Did the approach go too far?
No — if anything it stayed appropriately narrow:
| Alternative | Why it would be more complex or worse |
|---|---|
Gate only inside readResource after get() (content-tool style: resolve, then isLlmReadable(ref)) |
Still need matching logic; may fetch secret state before rejecting; error shape may diverge from "no collection matches" unless you rethrow carefully. |
Route reads through resolveClientData / full client projection |
Changes what agents see for collections with client.expose / data; not equivalent to "raw state minus secret". |
| New package or wrapper around CRUD tools | Cross-import smell for ~15 lines of policy already owned by resource-tools.ts. |
Fold readResource into content/search tools only |
Different contract (path vs uri, state vs rendered content); FIX-2436 is specifically generic CRUD beside workforce keys. |
Putting the llmReadable filter on read intent in resolvePathToCollection matches how search/discovery skip non-readable collections before touching instances (lazy collections, no accidental bulk work). That is the cleaner symmetry, not over-engineering.
Simplify follow-ups (non-blocking)
-
Duplicate predicate — The module already warns that a gate written twice can drift (
collectReadableProjectedCollections). This PR adds a fourth copy ofref.config?.llmReadable === true(also incollectReadableResources). Consider a single private helper (or wideningisLlmReadableto accept anything with{ config?: { llmReadable?: boolean } }) and using it in all four places. Same behavior, less future drift. -
Tool description — Block comment and README mention opt-in + secrets;
readResource's generator-facingdescriptionstill reads like an unconstrained read. Aligning one clause there would reduce surprise (product/docs nit). -
Workforce integration test —
resource-tools-key-read.test.tsis a fair regression for realmcpCredentialsCapabilitywiring, but the engine table already covers non-llmReadable→NO_COLLECTIONandsecretstripping. If CI time or maintenance cost matters, you could drop the workforce file and rely on engine coverage; keeping it is also defensible for the FIX-2436 story. -
Out of scope (mention only) — Write CRUD still resolves on visibility, not
llmWritable; content tools useisLlmWritableNow. I am not asking to expand this PR, but if someone expects "non-llmReadablecollections are inert for all generic tools," writes may still surprise them. Worth a separate issue if that is a product requirement.
Checks
Ran pnpm test resource-tools-path-matching in @flow-state-dev/engine — 56 tests passed on this branch.
Performance: no meaningful concerns (filter may reduce work on read; omitSecretFields is a no-op copy when secret is empty).
Sent by Cursor Automation: Review For Best Approach
…ource (FIX-2436) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGRHaqqMGz8cJxCeoQ
There was a problem hiding this comment.
Code Snob. A smaller shape exists. The read contract stays the same.
isCollectionLlmReadable is isLlmReadable on ns.ref. Widen isLlmReadable so it takes a resource ref or a collection ref, and use it for listing, projected search, and readResource. Delete the helper.
POC, do not merge: #4428
Fold that subtraction into this PR. After this PR lands, close the POC unmerged.
Sent by Cursor Automation: Code Snob
…d gate (FIX-2436) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGRHaqqMGz8cJxCeoQ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiGRHaqqMGz8cJxCeoQ
|
Kitchen-sink E2E (Playwright) failed on d0e148c, and the cause isn't this PR. The job never got to run tests: Generated by Claude Code |


Requested by Jake · project thread
What
FIX-2436 (bug, child of epic FIX-2369, blocks closure FIX-2425). Direct route, no spec.
Core's generic
resourceTools()readResource({ path })resolved a path against every registered collection and returned the full stored state. A worker givenresourceTools()beside a collection it may not show the model, such as a user's MCP keys (mcp-credentials/*, which #4415 installs on a worker's model block), could read the key.Now
readResource:llmReadable, the same gate the content and search tools already apply. Any other path answers as one no collection matches, so it doesn't reveal that the collection exists (the conventionresourceVisibilityuses for hidden resources);secretfields (omitSecretFields, the helper every engine read already uses).Generic L1 rule: it honours the collection's own flags, and no Workforce noun enters core.
Worth your eye
readResourceon a collection withoutllmReadablenow gets "No resource collection found". No app in the repo usesresourceTools(). Changeset added (@flow-state-dev/corepatch) saying to mark the collectionllmReadable: true.create/update/deleteResourcestill reach any collection the visibility rule leaves writable; they return only{ ok }, so they can't leak a key, but a model could overwrite or delete one. Gating state writes onllmWritablewould widen that flag's meaning (today it covers content writes). I left it out of this bug; say if you want it filed.mcpCredentialsCapability, notprojectMcpCapability. feat(workforce): workers get their project's MCP servers as tools (FIX-2388 PR 2) #4415 is still open, soprojectMcpCapabilityisn't on main. The test holds the same collection objectprojectMcpCapabilityinstalls, on an agent worker's model, withreadResourcepicked from its catalog, and the model callsreadResource({ path: "mcp-credentials/linear" }). Once feat(workforce): workers get their project's MCP servers as tools (FIX-2388 PR 2) #4415 merges, swapping the capability is a one-line change if you want it.Verification
unset FSDEV_DEFAULT_MODELbefore every run.packages/workforce/test/resource-tools-key-read.test.ts(new): one agent worker holds the keys collection andreadResource; a user's key is stored; the model asks for it. The tool answers "No resource collection found matching path: mcp-credentials/linear" and the key appears nowhere in the run's items.packages/engine/test/resource-tools-path-matching.test.ts: fixture collections markedllmReadableso every existing row keeps its meaning; two rows added: a collection that didn't opt in answers as unmatched, and an opted-in collection is read without itssecretfield.get-items-hot-path,store-factory-defaults) are timing tests that pass in isolation on this branch. Workforce 147/148 files pass;coordinator-roundstimes out on main too.pnpm --filter @flow-state-dev/core typecheck: same 155 errors as main in this checkout (unbuilt workspace), none in the changed files. eslint clean; pre-push vocabulary sweep clean.Negative controls, each applied to the source and re-run (each goes red):
llmReadablecheckread vault/linearrow"value":"lin_api_users_own_key"omitSecretFieldsread keys/linearrowDocs
packages/core/README.md(Resource CRUD tools paragraph) and thellmReadabledoc comment onResourceCollectionConfig. Noapps/docspage mentionsresourceTools().Generated by Claude Code