Skip to content

fix: copy foreign Agent Matrices when creating teams and preserve provenance #3068

Closed
3 of 3 issues completed

Description

@mblua

Problem

New Team lists agents from all loaded projects, but reduces selected paths to portable basenames before calling create_team. The backend resolves those names only in the destination project. Selecting a foreign agent therefore fails with Agent 'ac-healer' not found; an existing destination homonym can instead be bound silently. The selected source identity is lost.

Confirmed on main 6bff4a5. Prior investigation used 7b4191f; intervening main changes affect only pty/watchers/mod.rs. Relevant evidence: NewTeamModal.tsx portableAgentRef/handleCreate; entity_creation.rs list_all_agents, create_team, normalize_team_config_for_project, resolve_agent_ref.

User-validated behavior

  1. Keep selecting foreign agents in New Team. On successful creation, copy each selected foreign Agent Matrix completely into the destination project and bind the team, coordinator and repository assignments to those destination agents. Preserve the original and make files independent.
  2. During selection/review/repository assignments, show foreign agents as name@sourceProject, with the entire suffix dimmed. Destination-local agents show only their name, with no @ suffix. Classification uses current project membership, not historical provenance. A copied agent is subsequently local to its destination.
  3. Preserve all regular Matrix files/directories, including hidden/unknown files, config, Role, memory/archives, plans, skills, inbox and outbox. Do not rebuild defaults, sanitize selected content or rewrite arbitrary internal paths. Do not read real agents' private state during development; use synthetic fixtures.
  4. Persist the validated source project and copy timestamp inside the copied Matrix. Proposed contract already reviewed for feasibility: root .ac-copy-provenance.json, schemaVersion: 1, ordered copies[] entries containing sourceProjectName, sourceProjectPath, sourceAgentRef, copiedAt (UTC RFC3339, completion of this Matrix copy). This is the deliberate exception to copying that metadata file byte-for-byte; all other files retain their bytes.
  5. A copy of a copy retains every prior event unchanged in order and appends exactly one event for its immediate source. Original A -> copy B -> copy C -> copy D yields histories of 1/2/3 events, retaining identical prefixes. Do not sort, deduplicate, replace old dates or update ancestors. Missing history means only unrecorded history; do not invent creation dates. Invalid/unsupported existing history fails without resetting or overwriting it.
  6. Reject destination homonyms and ambiguous same-name selections without overwrite, merge, automatic rename or silent local substitution. Reject unsupported links/reparse/special entries explicitly rather than silently omitting Matrix content. On copy/metadata/team publication failure, report the error and recover only operation-owned artifacts, preserving pre-existing or externally modified content.
  7. Preserve local-only creation, portable persisted team refs and existing create/reload/close flow. Handle disk work outside the async/UI thread. No snapshot guarantee for actively changing files; failures/observable source changes must not count as successful copies.

Scope and acceptance

Application implementation is now authorized by the user's explicit “avanza”, following acceptance of prototype v4. Earlier prototype comment templates said no implementation; that earlier hold is superseded. Standing authorization permits proceeding after exact-version specialist consensus within this scope.

Scope: New Team and necessary additive Rust/IPC/types support, focused tests. Excludes Edit Team behavior redesign, global import tooling, new app success/filesystem/decision screens, actual private-Matrix operations, release/version bump, installing a build or unrelated cleanup. Prototype result/filesystem panels are explanatory, not new product surfaces. No final build requested.

Acceptance: synthetic multi-project fixtures demonstrate whole-tree byte preservation and independence; three successive copies preserve 1/2/3 histories; source trees remain unchanged; metadata matches immediate source and UTC time; collision/error cases do not clobber existing data; frontend tests cover labels in both wizard steps and repository assignments, preserving source identity in payload and local compatibility. Existing relevant checks and required CI must pass on the delivered commits.

Evidence and related issues

Room 24 has immutable prototypes v1-v4, user decisions and feasibility reports in room-shared/cross-project-agent-evidence and room-shared/cross-project-agent-*. User accepted v4 (SHA256 C6C40068087F36FF688E26CB2C4BF9215A8DA94886F3477CB1920BA00B149974). Architecture proposal rev2 and lineage review are candidates, not an implementation plan; a canonical reviewed plan is still required.

Related but distinct: #76 tracks older coordinator/portable-reference normalization; #357 tracks CLI-created team member matching in Edit Team. This issue addresses foreign-Matrix import and provenance, without expanding either older issue's scope.

Activity

  1. mblua commented on Oct 17, 2026

    @mblua
    OwnerAuthor

    Technical score

    Category Score Anchor and evidence
    Scope footprint 8 A few Rust/IPC/frontend files and focused tests, below the coherent-module anchor 10.
    Diagnosis difficulty 2 Cause already verified: source identity dropped before local-only resolution, close to stated-cause anchor 1.
    Domain knowledge required 8 Agent Matrix and portable team-reference rules, below subsystem anchor 10.
    Solution-space ambiguity 6 Candidate copy/provenance contract and visuals already established; still needs exact integration decisions, below 10.
    Blast radius and reversibility 10 Shared create-team path and writes of copied user state; collision/cleanup ownership matters, matching shared-path anchor 10.
    Dependency and integration load 6 Additive Rust/IPC/frontend contract within one repo; no new external dependency.
    Verification difficulty 10 New meaningful fixture and component tests supported by existing harnesses; must prove copying independent bytes, preserved sources and history.
    State, data and compatibility 12 New persisted provenance schema and additive wire shape; preserve all pre-existing data and local compatibility.
    Concurrency and timing 10 Async command, blocking disk work, destination reservations and cooperative mutation guard with clear ownership.
    Environment and tooling 6 Windows filesystem identity/reparse behavior with cross-platform Rust; ordinary repo toolchains.

    Raw sum: 78. Final: round((78 - 10) / 190 * 99) + 1 = 36/100.

    Excluded ceremony: issue/branch/PR creation, messaging, consensus rounds, CI waiting, merge/cleanup, versioning and final-report overhead.

    Band 26-55. Delivery path Full because it changes an IPC contract and persistence across Rust/frontend. Category vetoes: state >=10, concurrency >=10 require architect contract; verification >=8 requires review of meaningful proof. Author: ac-architect-v5. Reviewers: owning Rust/frontend devs, Rust Grinch and architecture Grinch, exact matching digests and phase-executable verdicts where partitioned. No final build requested. Standing authorizations applies within user-approved scope; no extra human gate after consensus unless a real scope exception arises.

  2. mblua commented on Oct 17, 2026

    @mblua
    OwnerAuthor

    I3068 round 1: no consensus

    Rejected candidate v1: D:/0_repos/AgentsCommander_iac/.ac/plans/3068-cross-project-agent-copy/plan-v1-cross-project-agent-copy.md (epic.md identical).
    Root SHA256: 2F9C3EAB0AD295F9D04C3D6DC87756077A984DC947BC2CC23B6997E8675EA0D0.
    Phase hashes remain as independently verified in each report. No implementation authorized from this candidate.

    Author: NEEDS_ANOTHER_ROUND. Rust dev, UI dev, Rust Grinch and architecture Grinch: CHANGES_REQUIRED. Approval count: 0/4 reviewers. Round 1 is comparison baseline.

    Reports: room-shared/i3068-round1-ac-dev-rust-v5-review.md, i3068-round1-ac-dev-webpage-ui-v5-review.md, i3068-round1-ac-dev-rust-grinch-v5-review.md, i3068-round1-ac-architect-grinch-v5-review.md. Author workflow contrast in messaging/20261017-155011-room24-ac-architect-v5-to-room24-ac-tech-lead-v5-workflow-review.md.

    Consolidated material corrections for next candidate:

    1. P02/root must define exclusive final publication and conventions creation that preserves external files appearing inside the reserved directory. Existing write_file_atomic replaces and cannot satisfy no-clobber. Include deterministic insertion hook and real-core test. Rust dev's finding overrides the other reviewers' general approval of publication.
    2. P01/P02 need exact usable platform identity for created files/directories before cleanup, with conservative failure. Rust Grinch shows std Windows file_index unavailable; architect must choose concrete mechanism and prove replacement scenario, not leave implementation choice open. Unix and Windows behavior explicitly decided using existing dependencies.
    3. P01 must settle one-read validation/verification and one-write creation of provenance, avoiding generic DFS create_new collision, TOCTOU and stale output-inventory digest. Preserve existing history and unknown fields; test source-history change before final verification.
    4. P01 must decide permissions/attributes/readonly behavior and its compatible cleanup/test contract. No unexplained choice left to implementer.
    5. P03/root must permit context-alert test fixture identity and additive envelope update while preserving assertions. Reuse existing ipc.transport.test.ts envelope coverage if equivalent, rather than duplicate infrastructure. Arithmetic correction: original six files minus new IPC test plus two existing tests is SEVEN total, not six. Use full exact inventory; never weaken validation or assertions to force a count.
    6. Readiness/workflow: full snapshot shared, SHA B3A2BDA0CDF929942F6EFDDCB0329D1D17BA17139CD1B843B6161B175EE269C3. Candidate READY is author completeness certification before independent votes; consensus is external. v2 must include source and correct status, full phase handoffs and immutable mapping/approval identity, cold-purge gates per phase. Author already identified these corrections. No circular gate requiring votes before a candidate may be reviewed.

    Optional comments do not become blockers: merging P01/P02 only if partition contract permits; extra local clippy where CI already covers it. Architect owns choices. Existing Full partition has three phases because persistence/IPC/frontend ownership are distinct contracts; no need to invent another exception. Preserve exact required participants and all accepted behavior. Reuse valid PRE/candidate evidence not affected by corrections. No new product screens, private Matrix access or final build.

    Next round: receive completed reports (all received), verify idle peer set, dry-run and real room purge, cold author new immutable version, then all original reviewers independently vote exact new digest set. No vote transfer. User-visible failed-round report published before this next gate.

  3. added
    EpicLarge cross-cutting work item
    on Oct 17, 2026
  4. mblua commented on Oct 17, 2026

    @mblua
    OwnerAuthor

    Plan v2 approved under standing user authorization

    All original participants reviewed the same immutable v2 set: architect certified READY; Rust dev, UI dev, Rust Grinch and architecture Grinch returned PLAN_APPROVED. Round 1 had 0/4 approvals; round 2 has 4/4. All six consolidated corrections resolved, no new blockers. User explicitly instructed “avanza”; no additional routine approval needed.

    Canonical root: D:/0_repos/AgentsCommander_iac/.ac/plans/3068-cross-project-agent-copy/plan-v2-cross-project-agent-copy.md
    Plan-SHA256: 664D6CD1FB4EC3FD0E63E24514F0510E85ED2B66C1A2616A187F4916A9F9E9BF

    Phase Child Owner Class Allowed files Depends on Phase-SHA256
    P01 #3071 ac-dev-rust-v5 design-bearing 1 none DC587078B57D17736B338A4494510B13AF2D139C4211A7F454224137A415A54B
    P02 #3072 ac-dev-rust-v5 design-bearing 1 P01 9ED82885109FF9BFB8243BD0D15B971BDBEC3946B9D1E70405EB46288C78B459
    P03 #3073 ac-dev-webpage-ui-v5 design-bearing 7 P02 BFDD6FB6B8027A261105ABEE4DEB2B3515A724EC7B530E194468FB574062FBF2

    Native sub-issue links verified. Mapping/immutable authorization receipt are separate from frozen Markdown; no plan bytes changed to add issue numbers. Implement sequentially from synchronized main after dependency merges. No final distributable build requested. Prototype explanation/result/filesystem panels remain out of product scope.

  5. mblua commented on Oct 17, 2026

    @mblua
    OwnerAuthor

    P01 delivered through PR #3075, merged at 08bb43a71dc4f3e0903ce18e2072e97904aa6120. #3071 is closed; #3068 remains open.

    Adds private complete/independent Matrix-copy helpers, cumulative provenance and conservative owned-output cleanup. Source and prior lineage are preserved. No IPC or New Team activation in this phase: that follows in #3072 and #3073.

    Validation: independent Rust and architecture reviews passed; Windows local full suite at integrated parent passed (6354 library tests, 26 ignored), all 16 focused tests passed on final head, strict Clippy/cognitive checks passed, and full module pair/SCC comparison preserved the existing topology. Full remote CI 39055434901 is green for final head 05510e15, including Windows/Linux/macOS, frontend, portable snapshots, smoke, guards, Sonar and security checks. The single Windows reader-demand timeout did not recur in the bounded check; no root cause or unrelated repair is claimed.

    Local repo is clean on main, equal to origin/main at the merge SHA; feature branch is removed. No distributable build was requested. Next authorized work: P02/#3072, additive source identity and copy integration in create_team; then P03/#3073 for external-project labels and payload.

  6. mblua commented on Oct 17, 2026

    @mblua
    OwnerAuthor

    Delivered P02 via PR #3082, merged at 2026-10-17T23:50:16Z.
    Merge/main SHA: e86896d. Reviewed/tested PR head: b7033fb.

    create_team now accepts optional source identity, validates and copies foreign Matrices before exclusive team publication, preserves cumulative provenance and local-call compatibility, and rolls back only owned unchanged output. Discovery reports canonical project identity/locality. The frontend consumer remains the next phase.

    Evidence: both independent code/integration reviews PASS; local Rust format/check/strict Clippy/cognitive wrapper, all 29 focused tests, 9 layering tests, full suite 6717 passed/0 failed/32 ignored. PRE/POST pairs and SCCs unchanged. Exact-head CI run39076334013 attempt2 SUCCESS; all required/triggered checks green, reconciled against ruleset15279066.
    The initial ProjectPanel frontend assertion failure did not reproduce in the one authorized same-head recurrence; original logs retained, cause unknown. Earlier lost local execution receipt is likewise preserved as UNKNOWN, with successful recovery and later independent exact-head validation recorded.

    Incoming Settings/container UI (#3077) and message archive (#3090) deltas were independently classified as unrelated and documented on the PR. Inherited Markdown line breaks in upstream release documentation remain explicitly recorded; P02-owned whitespace checks passed.

    Post-merge cleanup verified: clean main equals origin/main at the merge SHA; feature local/remote/tracking refs removed. The feature fetch refspec added by the requested git-chequear-rama-principal skill was removed before the post-deletion fetch, preserving main's refspec.
    No final distributable build was requested.

    Epic #3068 remains open. Remaining child: #3073/P03, New Team labels and source-identity payload, starting after the required safe handoff/clear and per-phase cold gate. Frozen plan v2 and approved mapping are unchanged.

  7. mblua commented on Oct 19, 2026

    @mblua
    OwnerAuthor

    Delivered in three merged phases:

    The team now binds selected foreign agents to independent destination copies, preserving regular Matrix content and appending immediate-source/time provenance without rewriting previous history. Synthetic fixtures cover whole-tree bytes/independence, three successive 1/2/3-event histories, unchanged sources, collision/error recovery, labels/source identity and existing local/context-alert behavior. Local agents retain name-only labels, including agents copied previously.

    Final P03 merge/main: 0f953c5b88606da75a1d3bc9ec9025231f2407be. All three phase merge commits are ancestors; all three native child issues are closed. P03 has exactly seven approved paths over its merge target and each matches the validated feature file; the final Git tree matches the expected clean merge of the independently reviewed target and validated head.

    The exact P03 feature head dc4b998cd54772e73d3ac9cace9e1f188265fdd6 passed full CI run 39179217461: all 14 required contexts, all 23 check runs and the Snyk status succeeded, including required Windows/Linux/macOS and portable-terminal coverage. Local corrected frontend: 274 files/4,178 tests plus all frontend guards PASS. Independently qualified Rust verification: 6,729 passed/0 failed/32 ignored, all required layering guards, cargo check and structural checks PASS. Both source/final-proof reviews passed.

    Newer target deltas from PR #3115 and #3066 were independently classified as unrelated, documented on PR #3102, and the exact green head was retained under the landing policy. This does not relabel earlier failed/cancelled executions or claim a new Rust execution on the eventual merged tree. Existing best-effort discovery/reload behavior remains as documented on the PR.

    Post-merge cleanup is verified: clean local main == origin/main, feature branch/ref removed, main-only fetch configuration restored. Every delegated report and command settled; eight room peers are closed; final purge dry-run returned dry_run_ready/exit 0 and real purge returned purged/exit 0. No final distribution build, installation, release or version bump was requested. No remaining work in this epic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EpicLarge cross-cutting work itembugSomething isn't workingdeveloped-windowsDeveloped on Windows.enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions