Repository navigation
refactor(engine): introduce execution environments - #503
Conversation
757ce3f to
4434cbe
Compare
jhrozek
left a comment
There was a problem hiding this comment.
Panel review — execution-environment seam (issue #462)
Ran a 5-chunk, multi-agent panel review (Spec / Standards / Domain axes) and reconciled it against a second independent single-pass review of the same diff. Two findings are confirmed by both efforts and should block merge; the rest are cross-confirmed cleanup with varying urgency. Full report available on request — this review posts the actionable subset inline.
Blocking: the CreateTeam panic (#1) and the duplicated secret-scrub construction site (#2).
Note on the ACP finding below: my first pass flagged ACP losing Bash as a ship-blocking regression; on rereading ADR 0105 §4 this is an intentional, documented design decision, not a bug. Downgraded accordingly — the remaining gap is discoverability (no model-visible posture note) and test coverage, not correctness.
4434cbe to
db2f557
Compare
|
Addressed all nine review threads in
Added targeted regressions for each finding, including alternate-root secret scrubbing, full shell-gate product tables, ACP shell-less request behavior, all Bash no-shell sites, and nil merge/team paths. Full build/lint/test/api/docs/site/demo gates pass, and a fresh three-axis verification panel returned PASS. |
db2f557 to
c16234c
Compare
Rebasing onto origin/main pulled in the execution-environments refactor (issue #503), which changed Tool.Execute's third parameter from tool.Workspace to the new tool.Environment struct and renamed Service.SetSessionWorkspace to SetSessionEnvironment. Update every test call site this branch's own commits added, and reclassify the renamed method. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ules, and delegation (#368) (#501) * docs(plan): define caller-separation acceptance contract Co-Authored-By: mecatl <[email protected]> * docs(plan): bootstrap stacked caller-separation work Co-Authored-By: mecatl <[email protected]> * chore(plan): dispatch ownership core Co-Authored-By: mecatl <[email protected]> * chore(plan): retry ownership core Co-Authored-By: mecatl <[email protected]> * feat(server): bind caller ownership on creation Co-Authored-By: mecatl <[email protected]> * chore(plan): mark ownership core done Co-Authored-By: mecatl <[email protected]> * feat(server): enforce persisted resource ownership Co-Authored-By: mecatl <[email protected]> * chore(plan): mark persisted resources done Co-Authored-By: mecatl <[email protected]> * feat(memory): partition stores by caller Co-Authored-By: mecatl <[email protected]> * chore(plan): mark memory isolation done Co-Authored-By: mecatl <[email protected]> * feat(server): enforce live caller ownership Co-Authored-By: mecatl <[email protected]> * chore(plan): mark live ownership done Co-Authored-By: mecatl <[email protected]> * feat(server): scope system workers and prove driver isolation Distinguish the scheduler's system actor from the schedule's caller-owned resource, deny system principals any operation outside their classified shared-infrastructure scope, and keep posture changes from ever touching ownership enforcement. Skip ownerless schedules under OIDC composition so background workers neither adopt nor retry stranded pre-cutover records, and pin the raw-driver deployment boundary with a NetworkPolicy scoping ingress to the mecak8s agent only. Co-Authored-By: mecatl <[email protected]> * chore(plan): mark system-and-deployment done Co-Authored-By: mecatl <[email protected]> * chore(plan): dispatch classification-guard Co-Authored-By: mecatl <[email protected]> * feat(server): guard caller-ownership access boundaries Add a source-level classification guard (ADR 0102 decision 2) over the designated application-facade, in-memory-registry, event-relay, cache/index, and model-tool access boundaries: every exported *Service and memory.CallerStore method, every registered internal/syscaller.Root, and the model-facing memory/child-observability/team tool family resolve to exactly one caller-owned, derived, shared-infrastructure, or exempt table entry. Shared-infrastructure/exempt entries must carry a concrete, reviewable rationale, so an exemption can never quietly become a caller-owned bypass. Classifying the table surfaced a real gap — CleanupTeam ignored its ctx and was the one team verb with no ownership check — fixed in the same change. Co-Authored-By: mecatl <[email protected]> * chore(plan): mark classification-guard done Co-Authored-By: mecatl <[email protected]> * docs(plan): define schedule-owner-key task A live-cluster probe against a real kind deployment found that CreateSchedule's collision guard leaks cross-tenant existence and rests on an accidental fail-closed guard against a latent same-name clobber, because schedule names are a caller-chosen key that never got memory's owner-namespacing treatment. An architectural review confirmed the fix is scoped to the create path and requires no port/backend change. Co-Authored-By: mecatl <[email protected]> * chore(plan): dispatch schedule-owner-key Co-Authored-By: mecatl <[email protected]> * feat(server): owner-namespace the schedule creation key CreateSchedule's collision guard checked the globally-keyed schedule Name before the create-time owner was resolved, so a name already used by a DIFFERENT owner was rejected with a distinguishing "already exists" error (an existence leak) instead of ADR-0102 decision 1's absence-style behavior — and both storage backends' unconditional upsert-by-name made that rejection the only thing preventing a same-named create from a different owner from clobbering the original. The schedule manager now computes an owner-namespaced physical store key (mirroring memory.CallerStore's owner-digest scheme) for every name-keyed verb (Create/Get/List/Update/Delete/Pause/Resume/GetFire/ListFires/ FireNow), translating back to the caller's literal name on every returned value. port.ScheduleStore's interface and both backends are unchanged; only the manager decides which physical string is the key. Two different owners may now use the identical schedule name without collision or leak; a same-owner reuse is still rejected. With no verifier wired the key stays byte-identical to today (a single flat namespace). Also wire cmd/mecak8s's OwnershipEnforced (mirroring cmd/mecated): the k8s binary attributed schedule/session/team ownership correctly but never enforced it, the same class of "enforcement silently not applied" bug. Co-Authored-By: mecatl <[email protected]> * chore(plan): mark schedule-owner-key done Co-Authored-By: mecatl <[email protected]> * docs(plan): track preserved-fork LRU partitioning as a follow-up An adversarial pass over this plan found the process-wide preserved-fork LRU is unpartitioned by caller (availability/DoS only, no confidentiality break). Recorded as a deferred, non-blocking follow-up rather than folded into this plan's scope. Co-Authored-By: mecatl <[email protected]> * docs(plan): add AC3.6 for the live-subscription ownership gap An adversarial pass found Service.Subscribe took no context and made no ownership decision at all; its sole caller is the untrusted gRPC StreamSessionLive handler, not the trusted in-process embed its stale doc comment claimed. A go-architect review confirmed the fix (mirror StreamSessionEvents, reclassify the guard's Subscribe row) and the test shape (a new Scenario 3 AC, reusing the existing live-subscription harness). Co-Authored-By: mecatl <[email protected]> * docs(plan): define live-subscription-owner-check task Co-Authored-By: mecatl <[email protected]> * chore(plan): dispatch live-subscription-owner-check Co-Authored-By: mecatl <[email protected]> * feat(server): enforce ownership on the live event subscription Service.Subscribe made no ownership decision at all: it took no context.Context and registered a live event channel keyed purely on the raw wire-supplied session ID, so any OIDC-authenticated caller who knew another caller's session ID could stream that session's live events indefinitely (StreamSessionLive is an untrusted gRPC boundary, not the trusted in-process caller its stale doc comment claimed). Subscribe now takes a ctx and returns an error, gating a GetSession ownership check on OwnershipEnforced (mirroring StreamSessionEvents exactly); the gRPC StreamSessionLive handler passes stream.Context() and maps a refusal via the existing toStatus (ErrNotFound covers both absence and owner mismatch by design, so the RPC stays a non-oracle). Reclassifies Subscribe from KindDerived (false rationale) to KindCallerOwned, and strengthens the classification guard to fail when a KindCallerOwned entry's method has no leading context.Context parameter -- exactly the shape that let this bug ship unnoticed. Co-Authored-By: mecatl <[email protected]> * chore(plan): mark live-subscription-owner-check done Co-Authored-By: mecatl <[email protected]> * docs(plan): extend AC3.3 for the Subagent resume ownership gap An adversarial pass found AC3.3 was implemented at half strength: InspectSubagent/InspectMember correctly authorized inspection, but the Subagent tool's resume: <agentId> argument loaded a persisted child session by id with no ownership check at all -- worse than a read leak, since resume replays the ENTIRE foreign transcript into the resuming caller's model and persists the resuming caller's turns back onto the foreign owner's stored session. A go-architect review confirmed the fix (reuse teaminspect.go's existing callerOwnsTranscript helper, fall into the existing not-found branch) and the test shape. Co-Authored-By: mecatl <[email protected]> * docs(plan): define subagent-resume-owner-check task Co-Authored-By: mecatl <[email protected]> * chore(plan): dispatch subagent-resume-owner-check Co-Authored-By: mecatl <[email protected]> * feat(agent): enforce ownership on Subagent resume engine/agent/subagent.go's resolveResumeSession (the load path for the Subagent tool's `resume: <agentId>` argument) made NO ownership check: it loaded a persisted child session from t.store purely by id and never compared its Owner against the calling principal. AC3.3 ("a model given another caller's subagent or team handle cannot inspect its transcript or act on it") was implemented at half strength -- InspectSubagentTool/ InspectMemberTool correctly authorize inspection of the same store by the same kind of id, but resume, the "act on it" half, did not. This is worse than a read leak: InspectSubagent returns a bounded (40 messages/1000 runes/8000 total) transcript in one ToolResult, while resume replays the foreign owner's ENTIRE conversation into a child engine the resuming caller's own model-authored prompt then drives, with no clamp. Worse still, resume MUTATES the foreign owner's persisted record -- issue #38's resume-start persist re-saves the loaded snapshot BEFORE the child drives, so the resuming caller's turns get appended to the foreign owner's stored session even when the child drive itself later fails. Fix: reuse teaminspect.go's existing callerOwnsTranscript(ctx, sess) verbatim, checked immediately after the Load and before the resume-start persist, falling a foreign-owned load into the EXISTING not-found branch (never a second, distinguishing error message -- that would itself be the leak this closes). Both call sites (foreground prepareChildSession, background startBackground) funnel through this one function, so one fix covers both. Also fixes internal/adapter/server/classification.go: adds the missing "Subagent" row to ModelToolBoundaries/modelToolAccessTable, and corrects InspectSubagent's rationale, which wrongly said "resumes" (that verb belongs to Subagent; InspectSubagent only reads). Two follow-ups noted, not fixed here: a ctx-vs-session-owner divergence on the scheduler fire path (documented in docs/acceptance/caller-separation.md's Deferred decisions section), and a doc-comment note on inheritOwner that its "resumed child already carries this owner" assumption is now an enforced invariant. verify: TestCallerSeparation_Scenario3_SubagentResumeIsOwnerChecked Co-Authored-By: mecatl <[email protected]> * chore(plan): mark subagent-resume-owner-check done Co-Authored-By: mecatl <[email protected]> * test(e2e): derive caller-separation journeys from the live-cluster probe Written after hand-driving the equivalent curl journeys against a real kind cluster (real Dex tokens, real mecak8s pods built from this accumulator) and observing the actual responses -- the two real gaps found that way (cmd/mecak8s never wiring OwnershipEnforced, and the schedule collision guard leaking cross-tenant existence) are both fixed upstream of this commit and exercised here. Flip caller_identity_test.go's Story 3/4, per their own inline "when #368 lands, FLIP this" instructions: a caller's session list is now scoped to their own rows, and a foreign prompt is refused absence-shaped instead of permitted. New caller_separation_test.go covers the surfaces those stories don't: two owners sharing a schedule name without collision or leak (AC6.1/6.3), same-owner reuse still rejected (AC6.2), a foreign schedule load/delete staying absence-shaped and non-mutating (AC2.4), and a foreign session fork/carryover source being refused without disturbing the source (AC1.6). Co-Authored-By: mecatl <[email protected]> * docs(user-docs): reflect caller-separation enforcement in mecak8s.md Issue #368 shipped application-level ownership enforcement for mecak8s-oidc; this doc previously described the overlay as attribution-only ("records who acted, refuses nothing", "Isolation: None"), which is no longer true and would actively mislead an operator deciding whether this meets their tenancy needs. Update the caller- identity section, the raw-driver NetworkPolicy note, the actor-vs-owner example (a foreign prompt is now refused, so the scheduler's own system-principal fire is the illustrative case instead), and the "what this does not give you" table's isolation row. Co-Authored-By: mecatl <[email protected]> * docs(user-docs): drop issue numbers and doc-history narration An operator reading deployment docs doesn't need internal issue numbers or a note about what an earlier revision of this doc used to say -- keep the ADR links (this doc's existing convention for citing the why) and drop the rest. Co-Authored-By: mecatl <[email protected]> * fix(server): normalize schedule not-found errors to the caller-visible name GetSchedule/UpdateSchedule/PauseSchedule/ResumeSchedule/ListFires/FireNow were returning the raw store error verbatim on a miss, which for a redisstore-backed schedule store embeds the owner-namespaced physical key (the SHA-256 owner digest) in the error text instead of the literal name the caller supplied — an absence-shaped-error violation and an internal-implementation-detail leak. scheduleNotFoundErr normalizes every such error to name only the caller-visible literal identifier. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix: reconcile post-rebase API drift against origin/main Rebased acc/caller-separation's #368-specific commits onto origin/main (dropping the 5 stale #367/spike-authn-wiring commits this branch had carried since it forked from an earlier snapshot of that work, now superseded by the merged, submodule-extracted version). The rebase itself was clean save for a handful of additive conflicts; these are the follow-up fixes needed because origin/main independently evolved some of the same call surfaces after the fork point: - Engine.Run's signature moved from a bare (ctx, sess, ws, string) to (ctx, sess, ws, RunRequest{Text: ...}) upstream; two call sites (engine/agent/subagent_resume_owner_test.go, added by this branch's own subagent-resume-owner-check task) still used the old shape. - Service.Subscribe gained a third (error) return value here (the ownership-check task); four pre-existing calls in subscription_test.go still used the old two-value shape. - Service.Subscribe's early-return path (a subscriptionsClosed guard added independently upstream — origin/main already fixed the same close-vs-send race this branch's own security audit flagged as a separate finding) was missing the new third return value. - classification.go's reflection-checked systemAccessTable didn't yet know about syscaller.RootModelCatalogRefresh, a new internal root origin/main added for the startup live-model-catalog refresh; classified it KindSharedInfrastructure (a one-shot, caller-free, process-wide catalog fetch, same shape as RootJWKSRefresh). task lint && task test are green on both modules; go run ./cmd/mecademo still produces a clean offline session. Note: docs/adr/README.md and engine/CHANGELOG.md carry a flagged ADR number collision (this branch's 0102/0103 vs origin/main's own 0102/0103) inherited from the merge — needs a renumbering pass before this ships, noted inline where the collision was resolved. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(server): enforce schedule ownership at manager boundary Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(server): correct stale rationale strings after e81e4b24 GetFire's rationale still described the pre-e81e4b24 GetSchedule-delegating path; the manager now loads the fire's parent schedule directly by its stored physical key and compares owners. The model-facing Schedule tool's rationale borrowed GetFire's new wording even though the tool never calls GetFire (that's a separate gRPC/REST-only boundary) — restate it in terms of the verbs the tool actually drives. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(scheduler): run fires as captured owner Scheduler bookkeeping (Claim/RecordFire*/diagnostics/event-attribution) keeps the syscaller system context; only the run-entry-adjacent calls (StartRunContent, the fire-timeout watchdog's Cancel, the delivery driver's GetSession/StartRunContent/fireFinalText) receive a context carrying the schedule's own already-captured owner via the new schedulerOwnerContext helper, so ownsResource resolves against the real owner instead of denying every fire once OwnershipEnforced is on. Ownerless schedules correctly stay on the system context and fail closed. server.LiteralScheduleName keeps the owner-namespaced physical key out of minted fire/session IDs and lifecycle-event/metric payloads. Amended to close a gap the review found: fireFailed's create-time failure fallback (reached when CreateSessionWithProfile itself fails, before a session exists) still minted its fire id from the raw physical schedule name -- LiteralScheduleName's fix only covered the success path. Also folded in two related cleanups the same review surfaced: LiteralScheduleName is a total, self-guarding function (identity on any non-namespaced key), so gating its use on an ownershipEnforced bool was dead weight inconsistent with the delivery driver's own unconditional call -- dropped the parameter (and the matching build.go gate around SetPresentScheduleName) so there is one policy, not three copies of it. LiteralScheduleName's hex-digit validation now uses encoding/hex.DecodeString instead of a hand-rolled per-rune loop. Co-Authored-By: mecatl <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(authz): enforce team transcript ownership InspectSubagentTool/InspectMemberTool shared callerOwnsTranscript, which treated an absent principal in the tool's OWN ctx as proof that ownership enforcement is off deployment-wide -- a category error: a nil caller means "no verified principal reached this call," not "this deployment has no verifier." Any path where the tool's ctx lacked a principal would let it return ANY persisted child/member transcript to ANY caller, in an enforced deployment. Fixed by threading the deployment's actual cfg.OwnershipEnforced flag into both tools at construction (new NewInspectSubagentToolWithOwnership/NewInspectMemberToolWithOwnership, wired in internal/app/catalog.go; old constructors kept, defaulting to unenforced for existing embedders) and gating on it explicitly via the new callerOwnsTranscriptWhenEnforced, rather than inferring the deployment's posture from context state. Amended to close a gap the review found: callerOwnsTranscriptWhenEnforced's disabled branch returned true unconditionally, which is MORE permissive than the callerOwnsTranscript it's meant to stay backward-compatible with -- the old predicate still denied a present-but-foreign VERIFIED caller regardless of any flag. An identity-recorded-but-not-enforced deployment would have silently lost that check. The disabled branch now falls back to callerOwnsTranscript instead of blanket-allowing, and the "legacy compatibility" test was corrected to distinguish a genuinely absent principal (still permissive, as intended) from a verified foreign caller under an unenforced-constructed tool (now denied, matching the predicate it replaces). The identical category-error shape still exists, unfixed, in resolveResumeSession (engine/agent/subagent.go)'s use of the untouched callerOwnsTranscript for the Subagent{resume:...} path -- confirmed not currently exploitable (SubagentTool is never registered on team-member or forked-child catalogs, and every production ctx is stamped with a real principal), but left as a structural landmine with no explicit enforcement flag to catch a future drift. Tracked as a follow-up, not fixed here. Co-Authored-By: mecatl <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(authz): harden subagent resume ownership Authorize persisted subagent resumes before consulting the shared in-flight registry, and require a verified matching caller when ownership enforcement is enabled. Amended to close two gaps the review found: - A confirmed task lint failure: the new pre-guard check pushed (*SubagentTool).run's cyclomatic complexity to 21 (threshold 20). Fixed by moving the "if resuming" branch inside authorizeResumeLookup itself (a no-op when not resuming), so run() carries one branch here instead of two nested ones. - Cross-confirmed duplication: the load-then-ownership-fold-then- error-branch block was now written out a second time, verbatim, inside authorizeResumeLookup and resolveResumeSession. Extracted the shared read-only fold into loadOwnedResumeSession, called by both. Each caller still performs its OWN fresh Load at its OWN point in time -- the pre-guard Load (no exclusion, before tryAcquireChildID claims the id) is never threaded into resolveResumeSession's later, authoritative Load (which runs only after a successful claim, under that id's exclusion, on a session about to be Reopen/Interrupt/Recover'd and re-persisted, and on the background path resolved later on a detached goroutine) -- doing so would turn a benign snapshot read into a stale write input. Threading the loaded session forward was considered and rejected for exactly this reason; the fix shares the CHECK LOGIC only, never the loaded data, and the new doc comment says so inline. Also corrected callerOwnsTranscriptWhenEnforced's doc comment, still describing itself as "the persisted-inspection predicate" from when only the two Inspect tools consumed it -- it now gates a third, non-inspection caller (Subagent's resume path) too. Co-Authored-By: mecatl <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]> # Conflicts: # engine/CHANGELOG.md * chore: post-rebase housekeeping after rebasing onto origin/main Rebasing acc/caller-separation onto the latest origin/main (which independently added two more ADRs both numbered 0104, on top of this branch's own 0104-schedule-origin-run-context.md) left the ADR README's index listing only one of the three same-numbered entries -- a rebase merge artifact, not data loss; all three files were intact on disk. Added the two missing index entries with the collision flagged inline, matching this repo's existing tolerated-duplicate- number convention (0100/0101/0103 already have precedent). go.work.sum gained the checksum entries go build/test naturally produces for the module-graph shift from origin/main's dependency bumps; a pure-additive sync, nothing removed or changed. Co-Authored-By: Claude Sonnet 5 <[email protected]> * docs(acceptance): drop the never-authored caller-identity-e2e plan link matlatl's strict docs gate caught a broken relative link introduced in this branch's very first plan commit: docs/acceptance/README.md pointed at caller-identity-e2e.md, a companion e2e-verification plan doc that was referenced but never written — its intended scope (real IdP, real cluster, owner-survives-failover) ended up covered directly inside caller-separation.md's live-cluster-probe section instead. Regenerate llms.txt to match. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(scheduler): make schedule creation atomic create-only CreateSchedule was check-then-upsert: a Load followed by a separate Save, racing across two store calls. Two concurrent same-owner creates could both observe absence and one would silently overwrite the other. Add the OPTIONAL port.ScheduleCreator seam (mirroring the existing ScheduleOneShotReArmer type-assertion pattern) with an atomic Create that returns ErrScheduleAlreadyExists on collision. memschedulestore, jsonlstore, and redisstore all implement it under their existing single-lock/single-EVAL discipline; the manager routes through it when available and falls back to the pre-existing check-then-Save otherwise (documented residual TOCTOU on that path only). Adds conformance coverage (concurrent-create-one-winner) run against every backend, plus manager-level tests for both the atomic and fallback paths. Review finding 5 (docs/acceptance/caller-separation.md, ADR 0102). Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(scheduler): require a verified caller on every public schedule verb ownerScheduleNamespace mapped a missing principal to a shared "schedule/none\x00" bucket instead of rejecting, so under ownership enforcement any call path lacking a verified principal could create or operate on shared ownerless schedules alongside every other unauthenticated caller. Add requireCaller, checked first by every public ScheduleManager verb (Create/Get/List/Update/Delete/Pause/Resume/FireNow/GetFire/ListFires): it is a no-op when enforcement is disabled, and rejects fail-closed when enforcement is enabled and ctx carries no principal. Read/mutate verbs on an existing name get the same absence-shaped not-found a genuinely-missing schedule produces; Create gets a generic refusal; Delete stays an idempotent no-op. The shared-bucket fallback inside ownerScheduleNamespace is now unreachable from any of the guarded verbs (the tick/fire path never calls them — it drives the raw ScheduleStore directly) and stays only as an internal fail-safe. Review finding 4 (docs/acceptance/caller-separation.md, ADR 0102). Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(scheduler): reject a foreign schedule origin under ownership enforcement validateScheduleOrigin loaded OriginSessionID and returned its owner without comparing it to the verified caller. Create/Update adopted that owner verbatim, so a caller who merely knew another caller's session id could name it as a schedule's origin — every fire's delivery path (deliverFireResult / deliverFireStarted) then trusted spec.Owner to enqueue content into that foreign session. Under ownership enforcement, require the origin session's owner to match the verified caller (an ownerless origin also fails — it is invisible to every caller, the same rule GetSession already applies). Both the missing-session and the existing-but-foreign-owner cases now produce the byte-identical "origin_session_id %q must reference an existing session" message via one constructor, so the error can't be used as an existence/ownership oracle. Non-enforced deployments are unaffected (ADR 0100's origin-wins-over-caller attribution is unchanged there). The check runs at validation time, before anything is saved, so a rejected create never reaches the delivery path. Review finding 1 (docs/acceptance/caller-separation.md, ADR 0102). Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(agent): namespace durable delegation ids by parent session id Subagent/Parallel/Team all derived their durable child session id from ONLY the provider tool-call id, a value the LLM API supplies and does not guarantee unique across independent conversations, let alone across owners. Two different top-level sessions issuing equal or adversarially-chosen call ids would derive the identical child SessionID and silently overwrite each other's persisted transcript before any inspect/resume authorization ever ran. parentCaps now carries the parent session's own id (already collision-safe across owners via the existing atomic session-creation enforcement) alongside its owner; SubagentTool.childSessionID, ParallelTool.childSessionID, and TeamTool.run's teamID derivation all thread it in as a namespace segment ("subagent-<parentID>-<callID>", "parallel-<parentID>-<callID>-<i>", "<parentID>-<callID>" for MemberSessionID). A caps-less drive (plain Execute/ExecuteObserved, no parent session threaded) keeps the pre-fix call-id-only id — unaffected outside real dispatch. Every prefix-only consumer (resume parsing, InspectSubagent/InspectMember, the childgc prefix list) is unaffected; only assertions of the exact derived id needed updating across the test suite. Adds equal-call-id collision tests across two different parent sessions for all three delegation families. Review finding 2 (docs/acceptance/caller-separation.md, ADR 0102). Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(agent): update the remaining namespaced-id call sites and gofmt Two more places assumed a delegation id was derived from the call id alone (review finding 2, issue #368): mecademo's background-subagent demo scripts the SubagentStatus collection call against a pre-computed child id, and the gRPC Converse per-member-cancel e2e asserted a hardcoded MemberSessionID. Both now compute the expected namespaced id (parent session id + call id). Also picks up a gofmt fix on schedule_manager_create_test.go flagged by `task lint` (gci import grouping). Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(authz): classify the stale-session sweep's new Service methods Rebasing onto origin/main pulled in SessionStale/LeaseSweepDisabled/ SettleIfStale (#475's crash-orphan sweep), added independently of the classification guard this branch introduces. All three are composition- owned process-wide maintenance, never a caller-facing verb. Co-Authored-By: Claude Sonnet 5 <[email protected]> * docs: regenerate llms.txt after second rebase onto origin/main Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix: adapt to the execution-environments refactor (tool.Environment) Rebasing onto origin/main pulled in the execution-environments refactor (issue #503), which changed Tool.Execute's third parameter from tool.Workspace to the new tool.Environment struct and renamed Service.SetSessionWorkspace to SetSessionEnvironment. Update every test call site this branch's own commits added, and reclassify the renamed method. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: mecatl <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]> Co-authored-by: mecatl <[email protected]>
…classification) - Track #503/#514 execution-environment seam: Run/ResumeApproval take tool.Environment (agent.EnvForWS), fakeTool exec keeps the Workspace contract (Execute bridges via env.Workspace()); blocking-steer test stubs take tool.Environment. - Track #368 caller separation: Steer/CancelSteer authorize via GetSession before touching the run registry / run-entry funnel (foreign = absence-equivalent), and register both in serviceAccessTable (ADR 0102 decision 2) — closes the cross-caller steer-injection gap the classification invariant surfaced. - gci-format model.go post-merge. Co-Authored-By: mecatl <[email protected]>
…classification) - Track #503/#514 execution-environment seam: Run/ResumeApproval take tool.Environment (agent.EnvForWS), fakeTool exec keeps the Workspace contract (Execute bridges via env.Workspace()); blocking-steer test stubs take tool.Environment. - Track #368 caller separation: Steer/CancelSteer authorize via GetSession before touching the run registry / run-entry funnel (foreign = absence-equivalent), and register both in serviceAccessTable (ADR 0102 decision 2) — closes the cross-caller steer-injection gap the classification invariant surfaced. - gci-format model.go post-merge. Co-Authored-By: mecatl <[email protected]>
Summary
Second implementation phase of #462:
session.EnvironmentRefand minimaltool.EnvironmentTool.Execute,Engine.Run, approval resume, dispatch, Subagent, Parallel, and TeamCommandRunner/CommandStreamerto one environment namespace; remove per-call working directoriesWorkspaceForker/ForkMergerwithEnvironmentForker/EnvironmentMergerVerification
task buildtask linttask testtask api:checktask docstask site:buildgo run ./cmd/mecademogit diff --checkPart of #462