Repository navigation
fix(files): a shared file is for the person the turn was for (abilityai/trinity-enterprise#549) - #2936
Conversation
…ai/trinity-enterprise#549) `agent_shared_files` was scoped by agent alone, so the Workspace Files tab listed every active share of an agent -- download link included -- to everyone on its roster: a file made in one person's chat appeared in another person's tab. Third occurrence of one class (asks, reports, now files): a table scoped by an owning entity gains a per-person dimension, and a reader written before the column cannot be neutral about it. A share now has an addressee. Three nullable columns on both migration tracks (`addressed_to_email`, `addressed_to_channel` -- display only --, `audience_source`); NULL email and NULL channel is the owner only, which is also what every existing row becomes, so there is no backfill. The platform decides the addressee; the agent does not choose. `services/turn_audience.py` keeps two questions apart. Given a turn, who is it for -- pure, table-driven over columns every entry path already stamps, with an allow-list of channels. And which turn did this call come from -- the hard one: an MCP call carries the agent's key and nothing about the turn, so the only link is an execution id the agent types, and a resumed session cites ids out of its own history (observed live: a turn 22 minutes old). The rule therefore needs positive evidence: only the agent's own key; the cited id must be this agent's; an agent-to-agent child is nobody; otherwise the id proves the CONVERSATION and never the person, and that conversation's running direct turns must agree on who it is. Every "could not tell" is the owner only, so the failure direction is under-share. The shortcut that must not come back is "the agent has exactly one running turn, so take it": a web-terminal session holds the agent's key, has no execution row, and would hand an operator's file to whichever client happened to be mid-conversation. On a channel turn the resolver reads `source_channel_client`, which the router now stamps only for a verified speaker in a one-to-one chat. In a group the verified email is the unlocker's, set once per group and not per speaker. - One override: `audience_email`, checked with the reader's own roster predicate; an off-roster address is refused by name and nothing is stored. - The addressee joins the effect key, so re-addressing a file within one turn is a second share rather than a silent replay; the key is hashed and the replay snapshot carries no address, so `idempotency_keys` never holds one. - The Workspace Files tab narrows in the query to the viewer, plus the owner-only rows for the agent's owner; an unidentifiable viewer matches nothing. The owner's Sharing panel lists everything, says who each file is for, and withholds the addressee from key-authenticated callers. - WhatsApp media and voice notes are addressed by the platform code that already holds the recipient. - `share_file` returns `visible_to_requester` / `visibility_note` (the names `set_canvas` uses) and never an address the platform resolved; the guidance lives in the tool description, since the prompt section is dropped at the minimal tier. Unchanged and stated: the `?sig=` link remains a bearer credential -- the audience governs the listing, not the download. Tests: 87 in tests/unit/test_ent549_file_audience.py, built on real-SQLite write-to-read round trips (every earlier share test mocked the persist step and every listing test seeded by INSERT, so nothing crossed write to read), plus mcp-server and frontend helper tests. 33 call-site mutations, all red, run in isolated scratch copies; the battery is what found a vacuous test (`column == None` compiles to `IS NULL`, and the table was empty). Fixes Abilityai/trinity-enterprise#549 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…d it as a secret CodeQL's sensitive-data heuristic classifies any identifier containing "trusted" as secret material. The unused slot for a platform-injected execution id was named `trusted_execution_id`, and that value reaches two existing log lines in `idempotency_service.resolve_and_validate_execution` that print an execution id -- so the first push raised two HIGH `py/clear-text-logging-sensitive-data` alerts on a file this change never touched. An execution id is not a secret; the alerts were true to the naming heuristic and false to the data. Renamed to `platform_execution_id` (and the local to `platform_turn`), which is also what the docs already call it. No behaviour change. A comment at the declaration says why, so the next reader does not name it back. Refs Abilityai/trinity-enterprise#549 Co-Authored-By: Claude Fable 5.1 <[email protected]>
A new data flow into an existing log line raises the alert on a file the PR never touched; the fix is a rename at the source, not a dismissal. Refs Abilityai/trinity-enterprise#549 Co-Authored-By: Claude Fable 5.1 <[email protected]>
merge-train — not on the 2026-09-21 train; rides the next one once these are settledNothing was pushed to this branch. Validated as lane B+schema. Three independent reasons, and the first is the only one that needs your judgement: 1. CodeQL reports 2 new high-severity alerts — "Clear-text logging of sensitive information" at My read is that this is very likely a false positive worth dismissing rather than fixing: the arguments are an 2. Alembic fork with #2920, which is on this train. Both declare 3. A real conflict with #2920 in So even with the CodeQL alert resolved, only one of #2936 / #2920 could ride this train. #2920 went because it was already validated and conflict-free against For what it is worth, nothing else about this PR argued against it — it was the freshest thing in the queue and its checks were still running when the queue was walked. |
|
|
|
Thanks — verified all three, and the (1) CodeQL — already fixed, not dismissed. Alerts #365/#366 were raised on the first push (15:18Z). (2) Alembic fork — agreed, and live now that #2920 has landed. One note on the target: #2924 ( (3) Conflicts — agreed. Against the current Nothing pushed yet, on purpose — a re-parent pushed before its parent exists on |
|
Resolve by running |
Conflicts: src/backend/db/migrations.py (the SQLite runner's function block and the MIGRATIONS tail) and docs/memory/learnings.md — all tail appends on both sides, so dev's entries are kept first and this branch's follow. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…d after #2920/#2924/#2927 Content of both tracks is unchanged; only the Alembic parent moves so the version line resolves to one head again (Invariant #3, #2068). It was chained on 0064 while 0065–0067 were still open PRs; they have all landed on dev. Refs Abilityai/trinity-enterprise#549 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…onvention) dev now takes new ledger entries as one file per lesson under docs/memory/learnings/, folded into learnings.md at the release cut, so same-day PRs stop conflicting on the ledger's tail. The two entries this branch had appended to learnings.md move there unchanged; learnings.md is byte-identical to dev again. Refs Abilityai/trinity-enterprise#549 Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Ready for the next train —
The description's migration line is updated. Still waiting only on the required review. |
/review ReportBranch: Execution coverage (Step 2.5)
No source-text assertion over a module under test; no bound check at a coinciding value. I re-ran four of the PR's mutations independently, each in a scratch copy, restored by copy:
Suites on my machine: Critical FindingsNone. Informational Findings[I1] Alembic: [I2] addressed_to=row.get("addressed_to_email") if show_audience else None,
addressed_to_channel=row.get("addressed_to_channel") if show_audience else None,
audience_source=row.get("audience_source"),No identity in it, and the UI needs it for the "Owner only" reason line — so this is plausibly deliberate. What it does still tell an agent-scoped key reading a sibling's panel is whether each of the owner's shares was addressed at all ( [I3] [I4] Pre-column rows become owner-only (Confidence 9/10) — stated, not a defect Clean Categories
Summary
The resolver is the part worth the reading time, and it is the part that is written most carefully: two questions kept apart, positive evidence required, every "could not tell" landing on under-share. The four failed designs recorded in |
|
merge-train 2026-09-22: riding this train. Validated lane B+schema ( |
…y.json rebuilt (keep both, #2947's entries + ours) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
merge-train: merged |
|
Resolve by merging |
…it row — the #2807 case no longer reads its neighbour's (#2952) (#2978) * test(mcp): each loop-tool call drains and identity-checks its own audit row (#2952) The #2807 transport cases awaited the first `run_agent_loop` row past an index sampled at test start. That is a position, not an identity: the previous test never awaited its own fire-and-forget row, so on a busy host its late `success: true` row was the first match and the refusal read as audited-as-success (CI run 35730033664 on PR #2936). Every call through `asAgent().call` now drains the row at its own call index before parsing the envelope, and checks it for tool and session (a per-session bearer the stub echoes back as `key_name`). A loud precondition (rows == calls) makes a change to withAudit's one row per call break this file on purpose. audit.ts is untouched (#2926). Evidence: the stub recording its row 50 ms late reds the dev file (5 tests / 4 pass / 1 fail, 3 of 3 runs; also at 200 ms) and leaves the fixed file 5/5 (3 of 3 at 50 ms, 1 of 1 at 200 ms). A constant key_name reds 5/5 with "row N is not this session's". Unperturbed: npm test 504/504, file alone 10/10. Also registers access-wiring.test.ts in tests/registry.json (it had no row). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * docs(learnings): awaiting a fire-and-forget recorder is not identity (#2952) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * docs(learnings): state only the evidenced #2952 chain — CI failed one case; the sibling's red is timing-dependent (#2952) CI run 35730033664 attempt 1 failed only the refused-loop case (464/465); the fragment claimed the sibling case chained into 'stale refusal' there. Under the 50 ms stub perturbation the original sibling case goes red on either 'first' (a late success row) or 'second' (a refusal row) depending on arrival order — say that instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * test(registry): access-wiring row uses the catalog's access-control category and records its #2952 update (#2952) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: trinity-ability <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Description
agent_shared_fileswas scoped by agent alone, so the Workspace Files tab listed every active share of an agent — download link included — to everyone on its roster. A file made in one person's chat appeared in another person's tab. Reproduced on a live instance with two accounts before the change, and again in unit form (ADA sees: {'report.pdf'} | BOB sees: {'report.pdf'}) before any code was written.A share now has an addressee, and the platform decides it — the agent does not choose.
addressed_to_email,addressed_to_channel— display only —,audience_source). NULL email and NULL channel is the owner only, which is also what every existing row becomes: no backfill, and every share expires within seven days.services/turn_audience.pykeeps two questions apart. Given a turn, who is it for — pure and table-driven over columns every entry path already stamps, with an allow-list of channels. Which turn did this call come from — the hard one: an MCP call carries the agent's key and nothing about the turn, so the only link is an execution id the agent types, and a resumed session cites ids out of its own history (observed live: a turn 22 minutes old). The rule needs positive evidence — only the agent's own key; the cited id must be this agent's; an agent-to-agent child is nobody; otherwise the id proves the conversation and never the person, and that conversation's running direct turns must agree on who it is. Every "could not tell" is the owner only, so the failure direction is under-share.source_channel_client, which the router now stamps only for a verified speaker in a one-to-one chat. In a group the verified email is the unlocker's — set once per group, not per speaker.audience_email, checked with the reader's own roster predicate; an off-roster address is refused by name (AUDIENCE_NOT_ON_ROSTER) and nothing is stored.share_filereturnsvisible_to_requester/visibility_note(the namesset_canvasuses) and never an address the platform resolved. The guidance lives in the tool description, since the prompt section is dropped at the minimal tier.idempotency_keysnever holds one.The shortcut that must not come back: "the agent has exactly one running turn, so take it." A web-terminal session holds the agent's key, has no execution row, and would hand an operator's file to whichever client happened to be mid-conversation. Four resolver designs were wrong before this one; they are recorded in
docs/memory/learnings.md.Unchanged, and stated: the
?sig=link remains a bearer credential — the audience governs the listing, not the download. On channels, share rows arise only from WhatsApp media and voice notes (Telegram and Slack upload natively). Residual: a session that carries another conversation's history can cite a real id of it; a platform-injected execution id is the structural answer (first slice of #2392 — the resolver already has the slot, andTRINITY_EXECUTION_IDis already in every headless turn's environment).Reviewer notes
0068, chained on0067_agent_role_readiness—dev's head after fix(skills): refuse to overwrite an agent-authored skill of the same name (#2914) #2920/feat(schedules): a schedule that names a user runs as that seat — reads and writes their memory (abilityai/trinity-enterprise#637) #2924/feat(workspace): the role card in Agent details — role, objectives with metric freshness, readiness (abilityai/trinity-enterprise#527) #2927 landed (it was chained on0064while0065–0067were open PRs; re-chained 2026-09-22 after the merge ofdev). The single-head guard and the cross-track parity guard are both green at the head.src/backend/client_portal/service.pyis a code-health hotspot with an open decomposition issue (refactor(client-portal): decompose client_portal/service.py — new top-3 code-health hotspot (3460 lines, CC 126, highest churn in the fleet) #2556). This PR changes a few lines there and adds no function to it; all new logic lives in cold files.FileSharingPanel.vue: headers render from one list and cells share bound class strings, so the new column shrank the file's raw-gray count (49 → 37); the baseline entry is lowered by a one-line edit.docs/security-reports/cso-diff-2026-09-21-ent549-file-audience.md— 0 open; three defects found in the diff as first written and fixed before commit.Related Issue
Fixes abilityai/trinity-enterprise#549
Journey Impact
Journey Impact: none: narrows who an existing Workspace listing is shown to — no catalog promise (J01–J11) covers file delivery in the Workspace; a candidate promise for the catalog, not added here
Type of Change
Testing
module under test unless its live consumer is CI itself (a workflow, a vendored copy, a
route table), and no bound check at the one value where both bounds coincide (bug(process): tests that assert source TEXT instead of executing the path — three green-CI ejections in one train, third run running #2829)
tests/unit/test_ent549_file_audience.py— 87 tests built on real-SQLite write→read round trips: the realcreate_share/create_share_from_bytesinto a real database, read back through the realportal_documents, with only the container read and the disk write stubbed. Every earlier share test mocked the persist step and every listing test seeded by INSERT, so nothing crossed write to read. Plussrc/mcp-server/src/files.test.ts(6) andsrc/frontend/tests/unit/sharedFileAudience.spec.js(8).Full unit run: 16,725 passed. The 6 failures are pre-existing and unrelated — 5 order-dependent tests in
test_2703_skill_assign_delivery.py, andtest_2814_workflow_trigger_parity.py, which fails identically on a cleanorigin/devworktree (its accepted-until-release list needs pruning after the last release cut). Existing tests changed on purpose, each explained in the test itself: thetest_ent548fixture addresses its rows and restates the owner half; thetest_idempotencyharness loads the realturn_audience;test_ent79stubs the accessor the reader now calls.Mutation: 33 call-site mutations, all red, run in isolated scratch copies (restored by copy, never
git checkout). Reader back to the operator question — the reported bug — turns 26 tests red, firsttest_a_file_shared_in_adas_chat_is_in_adas_tab_and_nobody_elses.include_owner_only=bool(is_platform)→test_a_platform_user_who_is_not_the_owner_never_reads_owner_only_files. Router stamps the unlocker in a group →test_the_router_names_nobody_in_a_group_even_though_an_email_is_verified. A cited RUNNING row believed without asking the conversation →test_a_zombie_row_in_a_room_is_not_a_second_opinion_it_is_doubt. The WhatsApp call site forgets the recipient →test_whatsapp_media_is_addressed_to_the_number_the_reply_goes_to. The battery also found a vacuous test (column == Nonecompiles toIS NULL, and the table was empty), since fixed.Checklist
Screenshots (if applicable)
The Sharing panel's new For column and both Workspace tabs were checked by the operator on a local instance, light and dark, before this PR was opened.
🤖 Generated with Claude Code