Repository navigation
feat(executions): project attribution seam + project Runs tab (abilityai/trinity-enterprise#1105) - #4492
Conversation
…xplicit project_id checked first (abilityai/trinity-enterprise#1105)
An edition may attribute an execution to a project. The platform side is an
inert seam, services/execution_attribution.py:
- every create_task_execution( site offers its row to record_row right after
it exists: /chat, /task, execute_task, both Workspace turn sites, loop
iterations, fan-out children (project resolved once at request time and
carried, since children are created when a slot frees), the skill-gate
replay, and the scheduler's row in the internal execute-task route;
- the public link, external A2A and brain-orb postprocess turns are untagged
by design, allowlisted with a reason;
- a request naming project_id on /chat, /task or /fan-out is checked via
dependencies.check_requested_project before admission, any claim or row;
with no attributor registered it is 422 project_attribution_unavailable;
- GET /api/agents/{name}/executions/{id} carries project_id from annotate;
record and annotate fail open;
- MCP chat_with_agent and fan_out take an optional project_id, forwarded and
keyed only when set; get_execution_result passes project_id through when
present.
Census guard tests/unit/test_1105_execution_attribution.py walks the platform
backend (rglob) and fails on an unrecorded creation site or a stale allowlist
entry.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lityai/trinity-enterprise#1105) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…licit attribution says so (abilityai/trinity-enterprise#1105)
Review I1, (b) and (c) of the planned attribution paths (plan §2.2 rules 2-3).
(b) Skill-gate replay. A hold on /chat (admit_chat_request), on /task
(dispatch_parallel_task) and on a fan-out subtask (via gate_replay) now
freezes the project resolved while the requesting turn runs into the gate
record's `dispatch` (`skill_gate_service.frozen_project`: `project_id`, plus
`project_requested` when the request named it). `_dispatch_approved` records
the approved run with it: as the explicit claim when the request named it,
otherwise as inherited. Inert in OSS, where resolve returns None and nothing
is frozen.
(c) Honest status. `record_row` now reports FAILED for a named project that
passed `check` and was then not recorded (the write raised, or the
record-time re-assert no longer held). /chat and /task record inline, so the
outcome rides a per-request ContextVar (reset by `check`) to the router,
which answers `project_attribution: "failed"` (`execution_attribution.report`).
Fan-out answers it on `FanOutResponse` when the named project did not
resolve at request time, or when a sync batch's subtask record failed.
(a) Loop iterations are NOT built. The loop record (`agent_loops`) has no
project column and no free-form field, so storing the project resolved at
loop start needs an OSS schema migration, which has not been ruled.
Iterations still record from their own row only.
Mutation check: each wiring line was reverted on its own and a named test went red:
- the chat/task router `report` → test_{chat,task}_route_answers_failed_…[False];
- the chat/task hold `frozen_project` → test_a_held_{chat,task}_freezes_…;
- the fan-out gate_replay project → test_a_fan_out_subtask_hands_its_project_to_the_gate;
- the child failure append → test_a_fan_out_subtask_whose_record_failed_marks_the_batch;
- the router FAILED → test_fan_out_answers_failed_when_the_named_project_did_not_resolve;
- the replay `requested` → test_the_approved_replay_records_the_frozen_project[frozen1];
- the seam's unrecorded → FAILED → test_an_explicit_request_that_was_not_recorded_is_failed.
Known gap: an Idempotency-Key replay of /chat or /task returns the stored
snapshot, which does not carry the field.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ackend's bound (abilityai/trinity-enterprise#1105) Review I4. The tool had `max(16)` while the route has `Query(max_length=64)`. The new test (64 accepted, 65 refused) went red against max(16). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Validation Report — run
|
| Category | Status | Notes |
|---|---|---|
| Commit Messages | ✅ | 4 conventional commits plus a dev merge |
| Base Branch | ✅ | dev |
| PR Size | ✅ | 31 files |
| Status Auto-Promotion | ✅ | Fixes abilityai/trinity-enterprise#1105 is a cross-tracker ref, so set status-in-dev by hand after merge |
| Journey Impact | ✅ | check_journey_impact.py exit 0. It warns that the PR declares no Journey Impact line |
| Requirements | New capability, but no change under docs/memory/requirements/. If ent#1247 carries the requirement, say so in the body |
|
| Architecture | ✅ | docs/memory/architecture/execution.md updated |
| Feature Flows | Behaviour changed and no flow was added or updated | |
| Security Check | ✅ | §4.1–4.6 clean. The only §4.2 hits are @pytest.* decorators |
| Infrastructure | ➖ | |
| Build Packaging | ✅ | No new top-level src/backend/ directory |
| Config Packaging | ➖ | No new env reads |
| File Modes / Host Paths | ✅ | |
| Audit Rows | ➖ | audit_rows.py prints ➖ no gated write handler touched |
| Structural Review | No /review is posted on the PR. The body cites a "reading review", but this report does not cover SQL safety, races or auth boundaries |
|
| Merge Gate | ❌ | Tier 1 regression diff is red (below). Lane C PR-side journey-smoke and e2e are green. dev-ci is success |
| Test Adequacy | ✅ | Non-happy paths covered: refusals before admission, failed attribution, fail-open, gate replay |
| Cross-Surface Drift | See §5.5 | |
| Code Quality | ✅ | Seam is inert in OSS and fails open. check is the only refusal and runs before admission |
| Requirements Trace | ✅ | Traces to ent#1105 |
| Product Fit | ❓ | ent#1105 still carries status-incubating |
| Product Bar 7–11 | ✅ | MCP and UI ship together (chat_with_agent/fan_out project_id, list_project_executions, Runs tab). User docs updated |
Tests run at head 57b5cb1d2 (both halves present: nested enterprise at 583f16e)
| Suite | Result |
|---|---|
tests/unit/test_1105_execution_attribution.py |
44 passed (34 functions, some parametrised) |
src/mcp-server/src/tools/chat.project_id.test.ts |
7 passed (node --test) |
src/mcp-server/src/tools/projects.test.ts |
33 passed (node --test) |
src/frontend/tests/unit/projectRuns.mount.spec.js |
7 passed (vitest) |
| Frontend ratchets (rawColor, loadingGate, sourceText) | 28 passed |
tests/unit/test_ent875_exec_control_routes.py::test_every_router_read_of_an_execution_row_has_a_viewer_decision |
FAILED, reproduced locally |
Execution coverage (§5.4)
| changed symbol / test file | executed by | live consumer | verdict |
|---|---|---|---|
execution_attribution.check / check_requested_project |
test_{task,chat,fan_out}_route_refuses_a_named_project_* |
routers/chat.py, routers/fan_out.py |
✅ |
record_row / explicit_status / report |
test_*_answers_failed_when_the_named_project_was_not_recorded |
routers/chat.py (both returns) |
✅ |
fan-out project_id carry + attribution_failed |
test_fan_out_*, test_a_fan_out_subtask_whose_record_failed_marks_the_batch |
fan_out_service._dispatch_all |
✅ |
skill_gate_service.frozen_project + _dispatch_approved |
test_a_held_{chat,task}_freezes_*, test_the_approved_replay_records_the_frozen_project |
dispatch_admission_service, chat_execution_service |
✅ |
| creation-site census (AST guard) | test_every_creation_site_records_*, test_deleting_a_record_call_turns_the_census_red |
CI itself | ✅ guard, negative-controlled |
ProjectRuns.vue |
projectRuns.mount.spec.js (real mount, 0 source-text reads) |
ProjectPage.vue |
✅ |
MCP project_id / list_project_executions |
chat.project_id.test.ts, projects.test.ts (execute tools against a fake client) |
chat.ts, projects.ts, client.ts |
✅ |
Product fit (Step 6.6)
| check | verdict | evidence |
|---|---|---|
| Approved (not incubating) | ❓ | ent#1105 has labels priority-p2, type-feature, theme-devex, status-incubating (added 2026-11-05) |
| Scope ↔ issue | ✅ | Runs tab, per-agent cost and queue age, MCP list tool all map to the issue title. Loop attribution is deferred and named in the body |
| Open-core tier | Not on record in OSS_VS_ENTERPRISE.md. The shape is right: the OSS seam is inert and refuses 422, and the attributor lives in the private module |
|
| Doctrine | ✅ | No line found that breaks it |
| Bar 7–11 | ✅ |
Question for the operator: ent#1105 is still status-incubating. Is it approved to ship, so the label should move to ready, or should this PR wait?
Cross-surface drift (§5.5)
| line the block printed | answer |
|---|---|
src/backend/routers/schedules.py: no first-line # mcp: header (the file already lacked one on dev). The PR touches chat.ts, executions.ts, projects.ts |
The changed route is GET /{name}/executions/{id} (get_execution, which adds project_id). It is covered by executions.ts get_execution_result (client.ts:2468), and this PR updates that tool to pass project_id through. Add the header anyway, e.g. # mcp: executions.ts (get_execution_result → GET /{name}/executions/{id}) + schedules.ts (...) |
| Inv #5 twins | none. agent_server/models.py and routers/chat.py only share a basename (not byte-identical) and no declared mirror names a changed file |
chat.py / fan_out.py |
Headers name chat.ts, which this PR updates |
Issues Found
Critical (Block Merge)
- Tier 1
regression diffis red with one new failure:test_ent875_exec_control_routes::test_every_router_read_of_an_execution_row_has_a_viewer_decision. The newdb.get_execution(request.execution_id)inrouters/internal.py::execute_task_internal(added for the scheduler-row attribution) is a router read of an execution row that is not in the ent#875READ_SITEScensus. Message:[('routers/internal.py', 'execute_task_internal')]. The fix is one entry intests/unit/test_ent875_exec_control_routes.pyREAD_SITES, e.g.("routers/internal.py", "execute_task_internal"): "internal shared-secret router (scheduler -> backend); reads the scheduler-created row only to offer it to the attribution seam, returns none of it". CI base 41044/0 failed, head 41088/1 failed.
Warnings (Review Required)
- ent#1105 is
status-incubating(product question above). - No
/reviewis posted on the PR. - No requirements or feature-flow update for a new capability.
schedules.pyhas no# mcp:header.- Merge order from the body still applies: merge after ent#1247, then bump the pin. feat(projects): GitHub refs on project tasks — read path, MCP fields, task modal (abilityai/trinity-enterprise#1240) #4490 conflicts on
projects.test.ts.
Suggestions (Optional)
/chatand/task:report()addsproject_attribution: "failed"to the response dict afteridempotency_service.complete()has stored the snapshot, so an idempotent replay of that request comes back without the field. This is minor, and only reachable when an edition attributor's write fails.- Add a
Journey Impact:line to the body (the gate passes, but the template asks for one).
Recommendation
REQUEST CHANGES. The seam, MCP and UI are well built and well tested, and every suite the rider named is green at head. Tier 1 is red, though, because of a real regression in the ent#875 viewer-decision census. The fix is one allowlist line. Separately, the incubating label needs an operator ruling.
This PR requires the following changes before merge:
- [ ] Add ("routers/internal.py", "execute_task_internal") with a reason to READ_SITES in tests/unit/test_ent875_exec_control_routes.py, and get `regression diff` green
- [ ] (operator) rule on ent#1105's status-incubating label
Please address these items and request re-review.
PR #4492 — REQUEST CHANGES — merge gate: ❌ (regression diff) · Run ID: chain-ent1236
…1105) Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Validation Report — round 2PR: #4492 — feat(executions): project attribution seam + project Runs tab (abilityai/trinity-enterprise#1105) C1 —
|
| check | evidence |
|---|---|
| Fix commit diff | 38c52d3 changes only tests/unit/test_ent875_exec_control_routes.py, +1/-0: it adds ("routers/internal.py", "execute_task_internal") to READ_SITES, with a reason |
| The reason is accurate | At head, execute_task_internal (internal.py:375) reads db.get_execution(request.execution_id) (≈L524) only to pass it to execution_attribution.record_row(created_row), inside try/except that degrades to None. Both return paths (accepted and result_payload) return none of the row's fields. The entry's text, "reads the scheduler-created row only to offer it to the attribution seam, returns none of it", matches the code |
| Same class as its neighbours | It sits beside the three existing routers/internal.py entries (shared-secret router). No new viewer-decision surface is introduced |
| Guard goes red without it (negative control) | Round 1 at 57b5cb1, which lacked this line, failed this exact test: [('routers/internal.py', 'execute_task_internal')]. At 38c52d3, which adds only this line, regression diff is green |
| No collateral | Single-line test-allowlist addition, no deletions in tests/, no product code touched in this commit |
Merge gate (Step 6.5), read on the PR head and dev
- Tier 1:
regression diff✅,pytest (head, seed 12345)✅,Analyze (python)✅,Analyze (javascript-typescript)✅,schema-parity✅,verify-non-root✅,gitleaks✅,journey-impact✅,lint✅,build✅ - Lane C on the PR:
journey-smoke✅,e2e✅,prod-image-smoke✅ dev-cion dev: success ("all Tier 2 workflows green")- Skipped jobs are conditional ones: auto-merge, clear-needs-fix, base inline fallback, push absolute, report
- mergeStateStatus is BLOCKED. That comes from required review and branch protection; no check is red
Not run in this round (by instruction)
- No unit, integration or e2e suites run locally. Round 1 and the review sweep covered them, and CI on the head is green
- No new mutation run. The negative control is the round-1 red → round-2 green pair, which differs by exactly this line
- §4.x security greps, §5.5 drift and Step 6.6 product fit were not repeated. The fix commit touches one test file and adds no product surface
- Round-1 warnings (incl. the issue-label ruling) are already with the operator and are not repeated here
Recommendation
APPROVE (C1 closed; the round-1 warnings stay with the operator). The status-needs-fix label is removed.
PR #4492 — APPROVE — merge gate: ✅
PR Validation Report: round 2 (delta), run
|
| check | evidence |
|---|---|
| The entry names the read round 1 flagged | ("routers/internal.py", "execute_task_internal"). The read is routers/internal.py:524 created_row = db.get_execution(request.execution_id). Its only consumer is execution_attribution.record_row(created_row), and nothing from the row is returned. The census reason is accurate |
| The census test is green at the new tip | tests/unit/test_ent875_exec_control_routes.py: 173 passed (run locally in job-worktree.sh open --pr 4492) |
| Tier 1 | regression diff pass and pytest (head, seed 12345) pass. The four required contexts, secret-scan/gitleaks and the lints are all pass |
| Lane C PR-side | journey-smoke pass, e2e pass |
dev before merge |
dev-ci: success — all Tier 2 workflows green |
status-needs-fix |
absent (cleared on push) |
The delta is a test file only, and it adds lines without deleting any. §4.1–4.3 has nothing to check, and no other check from round 1 is affected. As the rider asked, the suites that were green in round 1 were not re-run.
Carried from round 1 (not re-litigated)
- ❓ The
status-incubatingruling on ent#1105 is recorded for the merge sitting, together with the pairing with ent#1247 (NEEDS DISCUSSION at583f16e, Gate 1). ⚠️ Non-blocking warnings, unchanged: no/reviewis posted; there is no requirements or feature-flow update;schedules.pyhas no# mcp:header; merge after ent#1247 and then bump the pin; setstatus-in-devon ent#1105 by hand after merge.
Recommendation
NEEDS DISCUSSION. The only code blocker (C1) is closed and Tier 1 is green, so there is nothing left for the author to fix. Merging still depends on the operator's ruling on ent#1105's status-incubating label at the merge sitting, and on ent#1247 landing first.
PR #4492 — NEEDS DISCUSSION (C1 closed; code-side clear) — merge gate: ✅ Tier 1 + lane C PR-side · Run ID: chain-ent1236-1105-validate-2
|
Resolve by running |
|
Resolve by merging |
…xecution-view # Conflicts: # docs/user-docs/integrations/mcp-server.md # docs/user-docs/sharing-and-access/workspace-projects.md # src/mcp-server/src/access.ts # src/mcp-server/src/client.ts # src/mcp-server/src/tools/projects.test.ts # src/mcp-server/src/tools/projects.ts
/validate-pr — round 3 (tip
|
Conflicts kept both sides: ent#1225 continues_execution_id beside the ent#1105 project_id carry in the fan-out router/service and the chat admission's frozen dispatch; registry keeps both new entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
/validate-pr round 4 (delta-only) — APPROVE @ 8929fc7Scope: the merge of Conflict resolutions (
MCP doc header, counted from the code ✅ — Tests run locally (PR worktree)
Merge gate ✅ — 23 pass / 5 skipping / 0 fail on 8929fc7 (Tier 1 plus Not run: MCP node tests (projects.ts and chat.ts did not change in this delta; green in CI); the full unit suite locally (CI Merge order: ent#1247 first, then the gitlink (already pinned at its head), then this PR. The cross-tracker issue is set to
|
…rise to bc492a1 (ent#1247 merged) Co-Authored-By: Claude Fable 5.2 <[email protected]>
trinity-ability
left a comment
There was a problem hiding this comment.
/validate-pr round 5 (delta-only) — APPROVE @ 931e675
Delta since the round-4 approve at 8929fc7: one merge of origin/dev whose only conflict was the enterprise gitlink, resolved to bc492a1 — the squash-merge of ent#1247 on enterprise main (dev's previous pin c10d8c6 is its ancestor). No code hunk was hand-resolved.
- Alembic: OSS 125 revisions / 1 head (0124); enterprise 38 / 1 head (0037_project_executions).
- Local, paired at this head:
test_1105_execution_attribution+test_1163_github_sub_issues67 passed; full enterprise suite 3086 passed, 5 skipped (test_5_two_factordeselected —pyotpnot installed locally). - Tier 1 green; lane C:
journey-smokeande2egreen on the PR.devgreen at its tip before merge. - Merge-order condition met: ent#1247 is merged, and this PR carries the gitlink bump.
PR #4492 — APPROVE — merge gate: ✅
Fixes abilityai/trinity-enterprise#1105
What
Platform half of abilityai/trinity-enterprise#1105: each execution can be attributed to a project, and a project shows its runs.
services/execution_attribution.py, inert unless an edition registers a recorder. Called at every execution creation site before admission (chat,task_execution_service,fan_out_service,schedules,loop_service,skill_gate_service,internal,client_portal,dispatch_admission_service); an explicitproject_idis checked first and refused before anything runs.project_idon chat, task and fan-out;ExecutionResponse.project_id;project_attribution: "failed"when the check passed and the record did not. Gate replay carries the frozen project (2f9de5d3b).project_idonchat_with_agent; newlist_project_executions(task_idup to 64 chars, the backend's bound).ProjectRuns.vue,ProjectPage.vue,stores/projects.js).docs/user-docs/sharing-and-access/workspace-projects.md,docs/user-docs/integrations/mcp-server.md,docs/memory/architecture/execution.md.dev's (a03a9d3); this chain does not stage the bump.Review + security
2f9de5d3b), the MCP bound (6320cb009). The loop path is not built (below)./cso --diff(inline, diff-scoped): nothing at ≥8/10.Tests
tests/unit/test_1105_execution_attribution.py(26),src/mcp-server/src/tools/chat.project_id.test.ts,src/frontend/tests/unit/projectRuns.mount.spec.js;projects.test.tsupdated;tests/registry.json.create_task_executiongreen (fan-out, loop, workspace-model, write params, model validators).test_inter_agent_timeout_unit.pyfails at import ondevtoo — pre-existing.Before merge
src/mcp-server/src/tools/projects.test.ts(and both move the enterprise pin); whichever lands second resolves.devmerged in at57b5cb1d2; the branch is 0 behind.🤖 Generated with Claude Code