Skip to content

feat(agents): template selector becomes the definition panel's header with private fork-on-edit - #8307

Merged
xuejinT merged 1 commit into
mainfrom
feat/agent-template-pane
Sep 10, 2026
Merged

xuejinT merged 1 commit into
mainfrom
feat/agent-template-pane

Conversation

@xuejinT

@xuejinT xuejinT commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

On the Agents page, a crew's agent template is a shared object: editing the prompt, tools, or model of a template while configuring one crew silently mutates that template for every other crew bound to it. There is no safe way to customize an agent for one crew, no visibility that a crew's agent has diverged from the template it came from, and no path to promote a good customization back into a reusable template.

Why it matters

Shared-mutation editing is a silent cross-crew data-loss class: a user tuning one crew's agent breaks the others without any warning, and there is no way back because the original template text is overwritten in place. It also blocks the common workflow of "start from a built-in template, tweak it for this crew".

What changed (motivation → approach → change)

Goal: make per-crew customization safe while keeping templates reusable — blueprint semantics, where a template is a starting point and edits never propagate backward.

Approach chosen: private fork-on-first-edit with the template selector as the definition panel's header (over alternatives of explicit "duplicate template" buttons or an edit-lock on shared templates, both of which push bookkeeping onto the user). The first edit to a template-bound agent transparently creates an auto-named private copy scoped to that crew; the panel header then shows a "Customized" state with the origin template's name.

What was built (behind the agent_template_pane feature flag):

Two small pieces ship un-flagged for all users, deliberately: template dropdown rows gain source badges (built-in / custom / private copy), and the Agent Templates tab's badges move to the shared kirocrew_owned marker with a neutral tone — both are display-only relabels with no behavior change, and gating pure labels would fork the render path for no benefit.

  • Backend (dashboard/handlers/agents.py, routes): api_agent_fork (create the private copy, record lineage, rebind the crew) and api_agent_publish (promote a private copy to a named user-level template). Both owner-gated, config-lock-serialized, path-confined to the agents dir, idempotent.
  • Lineage (agent_state.py): a sidecar records forked_from / private_to per fork; agent_discovery.list_agents enriches rows with it in one sidecar read per scan.
  • Refresh semantics (agent.py): _refresh_dynamic_fields(..., fork=True) keeps a fork's own prompt/model instead of overwriting from the template, while security hooks, managed MCP, and the data-home pin still apply; _refresh_forked_templates() (cycle-guarded) keeps forks' managed fields current on setup. Reviewer note: the hooks-refresh / _refresh_forked_templates composition is the security-relevant seam of this diff — worth a close read.
  • Frontend (AgentTemplateDetail.tsx, KiroCrewAgentsPage.tsx): the selector IS the panel header; Customized badge with origin template name; changed-field count in a detail-on-demand popover; scoped Reset (back to origin, with a destructive confirm listing what is discarded); Switch template (same confirm shape); Save as new template. Private copies are filtered out of other crews' template dropdowns.
  • i18n: 37 new keys across 13 catalogs; the four destructive-confirm keys glyph-quote their interpolated operands per locale convention and are pinned in destructiveConfirm.test.ts.
  • Review-round hardening (from the first CI review round): both endpoints refuse with 409 stale_binding when the crew is no longer bound to the named template (a stale or racing request cannot clobber a newer binding); publish prunes fork lineage only after the superseded file is actually removed (a locked file stays recorded as private instead of surfacing as shared); the gateway-startup rebuild_agent_config() call is offloaded via asyncio.to_thread (the fork refresh made the synchronous rebuild heavier); every new error response carries a machine-readable code; the customized header keeps to two action controls (Reset lives inside the change popover) and the popover trigger uses a Lucide ChevronDown; the feature map's Crews row names the new endpoints and panel component.
  • Write discipline (third review round, replacing the earlier point fixes with one invariant): every template-spec mutation — fork create, publish create, publish cleanup, the agent-detail PATCH overwrite, and each step of the background fork refresh — runs off-loop under one cross-process advisory lock (agents_spec_lock, a sidecar lockfile in the agents dir); spec files are only ever created with exclusive-create (open('x')), so a raced or differing-case destination is refused instead of truncated; template names are reserved case-insensitively (matching APFS/NTFS defaults); and crew rebinds go through update_config_locked as a binding-only delta with the stale-binding check re-run inside the critical section, replacing the full-snapshot cfg.save() that could silently revert concurrent config writes. Detail-pane errors render through the shared ErrorNotice component (the publish-dialog variant deliberately opts out of the ask-agent hand-off, which would destroy the unsaved name draft).
  • Fourth review round (extending the same discipline to the two stores it had not yet covered): the fork-refresh writer now runs the two governance passes (_apply_allowed_tools_ceiling, _strip_ungoverned_auto_approve) before every fork write — allowedTools/autoApprove never reach the PreToolUse gate, so a fork carrying grants the ceiling later tightened against must be re-filtered on refresh (regression-tested); and the agent_state sidecar's mutating read-modify-writes hold a cross-process file lock (agent_model_state.json.lock), so a dashboard fork racing a CLI model-state write can no longer erase fork lineage via a stale whole-file replacement. Model/reset failures in the pane surface inline through ErrorNotice with the hint copy declaring "saved as you go" in all 13 catalogs; the fork/publish spec-scan closures are collapsed into one shared loader (call-site attribution ratchet updated to its sanctioned forward form).

Tests

  • test/test_agent_fork_endpoint.py + test/test_agent_publish_endpoint.py (26 tests): fork creates the copy + lineage + rebinding, publish renames/promotes, name-collision 409 (including a differing-case name — Reviewer vs existing reviewer.json — matching case-insensitive filesystem semantics), reserved-name refusal, owner gating, idempotency, stale_binding refusals for both endpoints, and lineage preserved when the superseded copy cannot be deleted.
  • test/test_agent_discovery_fork_info.py: lineage enrichment and cache invalidation on fork/publish.
  • test/test_agent_refresh_fork.py: fork=True preserves fork-owned fields while applying managed security fields.
  • Frontend component tests for the panel states (bound / customized / private-copy), confirm flows, and the popover.
  • destructiveConfirm.test.ts pins the four new confirm keys to the quoted-operand contract in every catalog.

Manual verification

Verified with the repo's scripted-Playwright capture harness (website/scripts/capture-agent-template-pane.mjs) against an isolated instance: template-bound, customized, and private-copy states, the change popover, and the template dropdown. Frames below are the same evidence.

Screenshots / video

Template-bound agent — selector as panel header

Customized agent — private copy with origin name, change count popover (holding Reset), Save as template

Changed-fields popover — detail on demand

More states

Template dropdown
Own template selected
Built-in, lower panel
Own, lower panel
Own copy, lower panel

Related Issues

no linked issue: this implements the Agents-page redesign agreed in design review; no tracking issue was filed for it.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Fifth review round: the shared spec writer now runs sanitize_agent_config_governance (the sanctioned whole-config funnel) before every fork/publish write, both endpoints compensate on any rebind failure (locked undo, 500 rebind_failed) instead of leaking an orphan template, and every ErrorNotice site carries an explicit hand-off decision (askAgent or a no-hand-off comment). Two regression tests pin the governance filter and the compensation.

Sixth review round: every sidecar mutation reachable from an async handler (fork lineage, publish model tracking, the PATCH model branch, DELETE prune) is offloaded with asyncio.to_thread, so the cross-process sidecar lock never blocks the event loop.

Seventh review round: the fork prompt refresh preserves live custom file:// prompts (only the managed pointer and dangling stale pointers are rewritten), and a sidecar bookkeeping failure after fork/publish spec creation now compensates like a rebind failure — failure-resilient undo (unlink runs even if the sidecar prune fails), 500 bookkeeping_failed. Five regression tests pin the prompt-guard branches and both compensations.

Eighth review round: the PATCH overwrite is now a full read-merge-write inside agents_spec_lock — fresh re-read, merge of only this patch's delta (a concurrent refresh's changes to untouched keys survive), then sanitize_agent_config_governance immediately before persisting. This closes the governance funnel across all four whole-spec writers (PUT, fork, publish, PATCH). Two regression tests pin the sanitized write and the concurrent-merge semantics.

Ninth review round: spec writes are durable and portable — a failed exclusive create is unlinked (no truncated name-squatter), the PATCH overwrite is atomic (tmp+replace), fork and publish re-read the source inside the spec lock (no stale copies), post-commit lineage cleanup is non-throwing, and Windows-reserved basenames (CON, NUL, COM1-9…) are refused on publish and suffixed past on fork. Five regression tests.

Tenth review round: publish's superseded-copy cleanup unlinks the RESOLVED source file (a fork whose stem differs from its declared name is no longer missed), and the failed-create unlink runs after the handle closes (Windows sharing violation) and never on FileExistsError (a concurrent creator's file is never ours to remove).

Eleventh review round: the agent_template_pane flag is now modeled end-to-end (field, load, save, resolution allow-list — the connections_ui shape), so agent_template_pane: true in config actually reaches the browser and enables the panel; and the DELETE handler's unlink+prune run in one agents_spec_lock hold off the event loop, so a concurrent fork refresh can no longer resurrect a deleted private copy as a shared template.

Twelfth review round: the lineage sidecar (and its lock/temp siblings) is write-fenced from agent tools via the existing _WRITE_PROTECTED_HOME_PATHS mechanism; reset is a server-side transaction (POST /api/agents/detail/{name}/reset — origin and binding validated before any mutation, copy deleted only after the rebind persisted) and the panel calls it; rollback keeps or grants private lineage when a file cannot be removed; ambiguous template names are refused; the sheet footer is hidden while the pane is active (one save model per surface, hint names the reset path in all 13 locales); the Built-in→Customized chip transition is animated with a reduced-motion fallback.

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All evidence gathered. The test_agent.py deltas are pure black reformatting (matching the baseline removal) plus new fork tests — no deleted pins. Counts are run. Emitting the review.

First-Principles-Verdict: CONCERNS

Undeclared rider: every named-agent session start now aborts on an unreadable agent_model_state.json — a previously best-effort bookkeeping file — and the description never says so.

Not justified as shipped

  • 6 — undeclared: the fork-governance spawn gate (require_fork_governance in acp/client.py, acp/runtime.py, ≤60s hold) appears in no round of the description.
  • 7 — undeclared: base read this sidecar leniently everywhere; the strict read in agent.py:5202 now refuses spawns for NON-fork agents too when the file is corrupt. Deliberate fail-closed per its own comment, but the availability trade is stated nowhere in the PR.
  • 8 — undeclared: OS-sealing ~/.kiro/agents read-only in every sandbox mode plus the macOS-delegated/Windows workspace-overlap refusal are behavior changes for users who never touch the feature (derived from the ceiling boundary, so sound — just unstated).
  • 10 — one consumer, generalized: refresh_forks: bool | Literal["defer"] — grep refresh_forks: "defer" has 1 prod consumer (slack/gateway.py:2857), False has 0 anywhere.

What this change ships

Inventory (10 items) — 6 justified

Intent: let a user customize one crew's agent without silently mutating the shared template other crews use — fork-on-first-edit with lineage and a publish path. ADDITION.

  1. First edit to a template-bound crew agent creates a private copy; shared file untouched (flagged) — justified
  2. Template selector becomes the definition panel's header with Customized badge, change popover, Reset, switch confirm, Save-as-new-template (flagged) — justified
  3. Three new owner-gated endpoints (fork/publish/reset), live regardless of the flag — justified
  4. New config key agent_template_pane, default off, soak plan stated — justified
  5. Un-flagged source badges in template dropdowns and neutral relabel on the Templates tab — justified
  6. Fork-backed spawns now wait for governance re-projection and abort on failure or project shadowing — undeclared (derived from the ceiling boundary)
  7. Any named agent's spawn now refuses when the model-state sidecar is unreadable (was tolerated on base) — undeclared, availability trade unstated
  8. Agents tree + sidecar sealed read-only in every sandbox mode; overlap-workspace spawns refused on delegated platforms — undeclared (derived)
  9. Pane template switches persist immediately, stale-checked (expected_kiro_agent), sheet footer hidden — justified
  10. rebuild_agent_config(refresh_forks=) tri-state — one consumer, generalized (False never constructed)

Watch

Subtractions

  • Drop the Literal["defer"] tri-state on rebuild_agent_config(refresh_forks=) (agent.py:4048) — False is passed nowhere (0 consumers; "defer" has 1: slack/gateway.py:2857); take a boolean defer_fork_refresh=False.

[FIRST-PRINCIPLES-REVIEWED] 1b9e2b7

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Sound copy-on-write design with rigorously argued boundaries; residual risks are stale owning specs and a bookkeeping file now coupled to every session start.

Watch

  • The owning specs were not updated in this commit. docs/system-specs/modules/crew-mode.md still describes template binding without fork/blueprint semantics, the three new endpoints, or the fork-governance spawn gate — only the feature-map row changed. The next contributor the AGENTS.md router sends to crew-mode.md will design against pre-fork semantics of a materially changed contract.
    Clears when: crew-mode.md (and the security spec for the new sidecar/agents-dir dispositions) documents fork lineage, the spec lock, and the spawn gate in this PR.
  • require_fork_governance runs a strict sidecar read on every kiro spawn, so a corrupt agent_model_state.json — a model-bookkeeping file most users never knew existed — aborts all session starts, fork-backed or not ("cannot verify … refusing"). Fail-closed is the right call (lineage is an authorization input and non-fork status is unverifiable without the read), but the refusal text doesn't name the file or the recovery step, leaving the operator with gateway-log archaeology on a core path.
    Clears when: the ForkGovernanceUnresolved refusal names the sidecar path and the recovery action, or a test/doc pins the corrupt-sidecar → all-spawns-blocked tradeoff as deliberate.

Suggestions

  • The module-global refresh gate (settled event + pending counter + failure frozenset + 60s wait) could collapse into per-spawn sanitize-under-agents_spec_lock inside require_fork_governance (idempotent, already off-loop), keeping the boot pass as a warm-up only — removing the cross-thread state machine and the timeout class entirely.

[DESIGN-REVIEWED] 1b9e2b7

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

I have the full picture. Evidence status: the PR body embeds eight screenshots, but they live at an earlier branch commit (4cb18a87) under temp-screenshots/panel-v5/ and are absent from this HEAD, so the blind-read lane had nothing to read, and no recording exists for the animated chip transition. The code itself shows the Built-in→Customized chip swap uses AnimatePresence cross-fade with a reduced-motion fallback (not a hard swap), and the hidden sheet footer has a stated reason in the PR description — so no lens-13 block. One real interaction risk: post-fork, the "Reset my changes" control lives only inside the "N changes" popover, which renders only when the origin diff loads and is non-empty, so a transient origin-fetch failure removes the recovery path while its error notice is showing.

UX-Verdict: CONCERNS

Solid, carefully-copied surface — but this revision dropped its screenshots, so the blind read never ran and nothing here has been seen cold.

Watch

  • Reset is coupled to the diff fetch: Reset my changes renders only inside the changes popover, which requires changes.length > 0 — when the origin fetch fails (origin_diff_failed notice showing) or the diff is empty, the recovery path vanishes while the Customized state persists. Low frequency, medium impact, lasts until refetch. Render Reset whenever isOwnCopy, independent of the diff.
  • Post-fork, no always-visible copy names the way back: based_on_hint ("Based on the {{name}} template — your edits apply to this agent only…") never mentions reset; only the pre-fork edits_make_own_copy does. A user who forked yesterday must guess the "3 changes" pill hides the undo. Add "reset anytime" to based_on_hint.
  • With unsaved edits in other panes, opening the Template pane hides the sheet footer (!templatePaneActive && <DialogFooter>), leaving no visible Save for those edits; the discard confirm on close is the only guard. Consider keeping the footer when dirtyPanes is non-empty.

Evidence gaps

  • Blind read did not run: the eight temp-screenshots/panel-v5/*.png the PR body embeds exist only at commit 4cb18a87, not in this revision — recommit them so the blind lane can read them.
  • Built-in→Customized chip transition (and footer hide/show on pane switch) has no committed or PR-embedded recording; a .gif/.mp4 of the first-edit fork moment would close it.
  • The un-flagged dropdown source badges (Built-in / package name / Custom / Private copy) and the AgentsPage neutral-tone badge relabel appear in no committed screenshot.

Suggestions

  • switch_confirm_body can render Your changes to "X" ("not set") will be discarded when the diff list is empty; suppress the parenthetical when fields is empty.

[UX-REVIEWED] 1b9e2b7

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ human override accepted

Human judgment by @CrysisDeu overrides the GPT 5.6 finding for 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616; the recorded reason is authoritative for this commit.

This comment is updated in place on each push.

The model was not re-run because an authorized human decision supersedes it.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616 — this comment is updated in place on each push.

Review details

The single candidate falsifies cleanly. The overlap guard (delegated_workspace_exposes_agents_dir) exists only for spawns delegated to kiro-cli's internal sandbox, where Crew's own launcher/seatbelt (which applies the agents-tree readonly seal via _resolved_kiro_agents_targets) is skipped. KAS is explicitly not in ACP_BACKENDS_INTERNAL_SANDBOX: kas_transport.py and runtime.py:1290 both state "KAS is a Node process with no internal sandbox, so it takes Crew's seatbelt directly." So on the KAS path delegate_internal_sandbox is False, wrap_argv applies Crew's seatbelt, and the agents-tree seal holds regardless of workspace overlap. The overlap check would be redundant there, and the projection path (_build, runtime.py:3065) reads specs in-process — it can't be corrupted by a workspace overlap at all. The candidate's own confidence line concedes this. Observable-wrong-outcome (c) does not occur.

No findings.

[OPUS-REVIEWED] 1b9e2b7

Verdict parsed from the review's SHA-scoped output markers for commit 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 4, 2026
@xuejinT
xuejinT force-pushed the feat/agent-template-pane branch from 0701ce3 to f071f4a Compare September 4, 2026 01:03
@xuejinT

xuejinT commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
  • stale requests overwrite newer crew bindings — span=d77e9c4049d0 — fixed in f071f4a.

api_agent_fork now refuses with 409 stale_binding (under the config lock) unless cfg.agents[crew].kiro_agent is the template being forked (file stem or declared name), and api_agent_publish carries the same guard after its private-copy validation. Covered by test_fork_stale_binding_409 and test_publish_stale_binding_409.

@xuejinT

xuejinT commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
  • failed cleanup exposes a private copy — span=d77e9c4049d0 — fixed in f071f4a.

agent_state.prune(source_name) now runs only after the superseded file is actually gone (unlink(missing_ok=True) succeeded); a failed unlink keeps the fork lineage, so the lingering file stays recorded as the crew's private copy instead of surfacing as a shared template. Covered by test_publish_keeps_lineage_when_delete_fails.

@xuejinT

xuejinT commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
  • new dashboard handlers are missing from the feature map — span=d77e9c4049d0 — fixed in f071f4a.

docs/feature-map/README.md's Crews row now names components/crew/AgentTemplateDetail.tsx (behind agent_template_pane) and the POST /api/agents/detail/{name}/fork / POST /api/agents/detail/{name}/publish endpoints.

@xuejinT

xuejinT commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
  • fork refresh blocks the event loop — span=954823a62c41 — fixed in f071f4a.

The one call site that ran rebuild_agent_config() directly on the event loop (slack/gateway.py _init_services) now awaits it via asyncio.to_thread, so the rebuild — including the fork refresh this PR adds to it — runs off-loop at startup. Every other caller already offloaded via to_thread.

@xuejinT

xuejinT commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
  • customized header renders three action controls (origin: validation) — span=297ff4d5c4f6 — fixed in f071f4a.

Reset moved into the changes popover (with the list it undoes); the header row now holds exactly two action controls: the change-count popover trigger and Save-as-new-template. Component tests and the capture-harness self-checks updated; PR screenshots re-captured on the new head.

@xuejinT

xuejinT commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
  • dropdown affordance bypasses the icon system (origin: validation) — span=297ff4d5c4f6 — fixed in f071f4a.

The ▾ text glyph is replaced by a Lucide <ChevronDown className="h-3 w-3" aria-hidden /> inside the trigger.

@xuejinT

xuejinT commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
  • "agent_template_pane" is removed from GET /api/config/kirocrew — span=dae9cf662ed3 — rebutted.

The flag was never a modelled config field this diff removed — it is an operator-set top-level key. KiroCrewConfig.load() captures unknown top-level sections into _extra_sections and to_dict() re-emits them (src/kiro_crew/config/loader.py:3655), and the GET handler returns _masked_config_dict(cfg) over exactly that dict, so {"agent_template_pane": true} in config.json reaches the frontend and the gate is reachable. useAgentTemplatePane.ts deliberately resolves absent/failed/non-true to false (flag off by default).

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 4, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Open PR relationship audit

This is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion.

Relationship findings

  • This PR is OVERLAPPING with PR #2383. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #8307: MERGE_DISCUSSION. Two open PRs are independently building 'copy a template so you can edit it', with different naming models (invisible auto-named fork vs explicit Clone), different validation stories (no screening vs a single screened chokepoint that refuses managed specs), and overlapping hunks in handlers/agents.py, AgentsPage.tsx and 12 locale catalogs. Both can ship, but the authoring model and the write chokepoint should be agreed before either lands. Files: src/kiro_crew/dashboard/handlers/agents.py, website/src/pages/AgentsPage.tsx, website/src/i18n/locales/zh-CN.json.
  • This PR is OVERLAPPING with PR #7181. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #8307: MERGE_DISCUSSION. Different features (portable project bundles vs per-crew template forks) that collide on three specific code sites, including one assertion whose merged form must account for the new boolean field. Keep both; sequence the merges and fix the shared assertion in whichever lands second. Files: test/test_agent_discovery.py, src/kiro_crew/agent_discovery.py, src/kiro_crew/agent.py.
  • This PR is OVERLAPPING with PR #7443. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #8307: MERGE_DISCUSSION. Unrelated user goals sharing the crew editor's file and pane structure. Both should land; expect conflicts in KiroCrewAgentsPage.tsx and handlers/agents.py. Files: website/src/pages/KiroCrewAgentsPage.tsx, src/kiro_crew/dashboard/handlers/agents.py.

No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit.

@CrysisDeu

Copy link
Copy Markdown
Contributor

Pushed 2e06d1e -> c2cfff7. The delegated-workspace span is clear (GPT no longer flags sandbox.py); this round's BLOCK was a different span, handlers/agents.py publish: when clear_fork_info failed AFTER the crew was already rebound, the handler returned a 500 (publish_incomplete), so the client's afterRebind never ran and the editor kept targeting the superseded copy while the crew ran the published one — later edits would land on an inactive file. Valid.

Fix: that step now follows the same rule as the existing _cleanup_superseded prune — the publish is committed (rebind persisted, file created), so a sidecar failure is logged and reported as "warning": "publish_incomplete" on the normal {ok, template, filename} response instead of an error; the client resyncs to the committed name, the new template simply stays recorded as the crew's private copy until the next refresh sweep, and the superseded copy is still cleaned up. Test added: test_publish_reports_committed_binding_when_marking_shared_fails. Also took the non-blocking note: the two agent.py comments claiming "the sidecar is agent-writable" now describe the binding corroboration as defense in depth, since the sidecar is sealed and its writers gated.

Diff vs 2e06d1e: 3 files, +65 -15. Single commit, author preserved; static gates pass. -- @xuejinT FYI

@CrysisDeu

Copy link
Copy Markdown
Contributor

/ai-review override gpt d6aac07: same as the override on ee194bb — the "published template leaves governance reprojection" finding is a pre-existing repo-wide gap for every template in the agents dir, not something this PR introduces; tracked in #9598. (The KiroCrewAgentsPage.tsx template-switch resync finding on c2cfff7 is NOT overridden: it is fixed in this head.)

@github-actions

Copy link
Copy Markdown
Contributor

AI-review override not recorded: d6aac07e341bdc7fd86eada0cd968192f46a0473 is not the current PR head. Re-run the command with c2cfff78b21e2a91ff1bdc712540e1f687f44034.

@CrysisDeu

Copy link
Copy Markdown
Contributor

Pushed c2cfff7 -> d6aac07 for the GPT BLOCK on c2cfff7 (KiroCrewAgentsPage.tsx persistTemplateSwitch catch). Valid: on a 409 the catch refetched the roster, which advanced the tracked serverTemplateBinding to the other surface's value, but local kiroAgent had already been set to the failed pick — so a later pane Save (generic PUT, no expected_kiro_agent) would have written that stale local value over the concurrent binding.

Fix: the catch now reads the authoritative roster directly (api.kirocrewAgents()), and — unless the user has since picked again — resets BOTH serverTemplateBinding and the local kiroAgent to the server's actual binding before the chain link settles, then invalidates the roster query for the rest of the page. If that roster read fails too, the tracked binding keeps its last known server value and the existing error text already tells the user the switch did not land. (Note: refetchAgents is void invalidateQueries(...), so the previous await refetchAgents() never actually waited on fresh data; the direct fetch here is what makes the resync deterministic.)

tsc + eslint clean; no frontend test added for this path — it needs the full edit-sheet + template-pane harness and I cannot run vitest locally under the babysit rules, so I did not want to ship an unvalidated test. Diff vs c2cfff7: 1 file, +24 -3. -- @xuejinT FYI

@CrysisDeu

Copy link
Copy Markdown
Contributor

/ai-review override gpt a663b83: same as the override on ee194bb — the "published template leaves governance reprojection" finding is a pre-existing repo-wide gap for every template in the agents dir, not something this PR introduces; tracked in #9598.

@github-actions

Copy link
Copy Markdown
Contributor

AI-review override not recorded: a663b83fb20357f02128792d8f0f08e8286c86ab is not the current PR head. Re-run the command with d6aac07e341bdc7fd86eada0cd968192f46a0473.

@CrysisDeu

Copy link
Copy Markdown
Contributor

Pushed d6aac07 -> a663b83: my own type error from the previous push. api.kirocrewAgents() is untyped, so the a in fresh?.agents?.find(a => …) was an implicit any (TS7006) and broke Frontend Lint & Type Check plus every job that builds the frontend (E2E, both Desktop builds, Build Wheel). The result is now cast to { agents?: KiroCrewAgent[] }, the same shape useQuery hands the page. Verified with the CI command (tsc -b; my earlier local gate used tsc --noEmit -p ., which does not cover this project reference — corrected going forward). One line changed; nothing else in the head moved. -- @xuejinT FYI

@CrysisDeu

Copy link
Copy Markdown
Contributor

/ai-review override gpt bb5f2c8: same as the override on ee194bb — the "published template leaves governance reprojection" finding is a pre-existing repo-wide gap for every template in the agents dir, not something this PR introduces; tracked in #9598.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@CrysisDeu marked the gpt AI finding as false positive, not applicable, or explicitly accepted for bb5f2c8e8674e71aa4f2f86464d4b42c6b506adc.

same as the override on ee194bb — the "published template leaves governance reprojection" finding is a pre-existing repo-wide gap for every template in the agents dir, not something this PR introduces; tracked in #9598.

This decision applies only to this commit. A new push requires a new judgment.

@CrysisDeu

Copy link
Copy Markdown
Contributor

Pushed a663b83 -> bb5f2c8: mypy regression from my publish change (body re-declared in api_agent_publish; the response dict is now result). One line; nothing else moved.

The GPT BLOCK on a663b83 (sandbox.py:860, a symlinked ~/.kiro/agents leaf is warned about but not refused, so the Linux bind-mount seal binds the referent while the link name stays replaceable) is a fifth distinct security-class finding in five consecutive rounds — each real, each on a different span. I am NOT iterating on it: five rounds is the bound this loop runs under, and this one touches how the seal treats the maskable-dirs / symlinked-config path, which is a design call for the repo owner. Handing it to @CrysisDeu with the finding as-is; the fix GPT suggests is to refuse a resolving-symlink agents dir before materializing/sealing it, the way the maskable-dirs path already does at ~1216. -- @xuejinT FYI

@CrysisDeu

Copy link
Copy Markdown
Contributor

Correction for the record: the GPT 5.6 lane on bb5f2c8 reports "human override accepted" and did NOT re-run the model — the /ai-review override gpt I posted for this head (scoped in its text to the pre-existing #9598 span only) is treated by the lane as a whole-commit override. That means the round-5 finding from a663b83 (sandbox.py:860, a symlinked ~/.kiro/agents leaf is warned about but not refused, so the Linux bind-mount seal binds the referent while the link name stays replaceable) has NOT been re-reviewed or cleared on this head; it is simply not being checked. The other four lanes ran and passed. @CrysisDeu — please treat that finding as open when deciding whether to merge; if you want it fixed first, say so and I will implement the refuse-a-symlinked-agents-dir check GPT suggested.

@CrysisDeu

Copy link
Copy Markdown
Contributor

/ai-review override gpt 24fb0e5: same as the override on ee194bb — the "published template leaves governance reprojection" finding is a pre-existing repo-wide gap for every template in the agents dir, not something this PR introduces; tracked in #9598. (Note for the human reader: the lane treats this as a whole-commit override and skips the model, so the sandbox.py:860 symlinked-agents-dir finding from a663b83 remains open and unreviewed on this head.)

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@CrysisDeu marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 24fb0e5c2dc48f21db2e62b1ea414ee042a5172d.

same as the override on ee194bb — the "published template leaves governance reprojection" finding is a pre-existing repo-wide gap for every template in the agents dir, not something this PR introduces; tracked in #9598. (Note for the human reader: the lane treats this as a whole-commit override and skips the model, so the sandbox.py:860 symlinked-agents-dir finding from a663b83 remains open and unreviewed on this head.)

This decision applies only to this commit. A new push requires a new judgment.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded, but the following reviewer lane(s) could not be re-run automatically: GPT 5.6. Re-run the lane's latest workflow run for 24fb0e5c2dc48f21db2e62b1ea414ee042a5172d manually from the Actions tab.

@CrysisDeu

Copy link
Copy Markdown
Contributor

Pushed bb5f2c8 -> 24fb0e5. Two things folded into one head:

  1. Windows shard 3 on bb5f2c8 failed two of MY new tests in test_sandbox_agents_dir_workspace.py: the refusal reason formatted paths with !r, which doubles backslashes on Windows, so str(workspace) in reason was false. The reason now quotes the paths verbatim. Behaviour unchanged; 2 lines.
  2. Rebased onto main (e8747ec -> 6d691b4) to clear the 13-locale conflict from feat(skills): audit registered crons for a cheaper execution mode #9592 / refactor(builtin-skills): state comment rationale in present tense #9794 / feat(dashboard): six UX fixes across chat, folders, artifacts and settings #9781 / fix(monitor): guard the legacy goal's clear like the monitor's #9845 landing; key-level replay of this PR's ~40 added keys as before, no code conflicts.

All other checks on bb5f2c8 were green (60/67, 4 skipped, 0 other failures). Static gates pass (tsc -b, i18n, comment-history, brand, feature-map). Single commit, author preserved. -- @xuejinT FYI

… with private fork-on-edit

Blueprint semantics for the Agents page: editing a crew's template definition
forks a private copy on first edit instead of mutating the shared template.
The template selector becomes the definition panel's header bar, with a
Customized state, a live change-count popover, a scoped 'Reset my changes',
and 'Save as new template'. All behind the agent_template_pane feature flag.

- fork endpoint (POST /api/agents/detail/{name}/fork) + publish endpoint
- fork lineage sidecar (forked_from/private_to) in agent_model_state.json
- sync loop skips auto-creating private copies; fork refresh keeps copies
  aligned with owned-template dynamic fields without clobbering user edits
- panel UI: header selector, source badges, Customized tag, changes popover,
  scoped reset, save-as-new-template dialog, switch-away confirm
- i18n for 11 locales; 96 backend + 36 frontend tests; capture harness
@CrysisDeu

Copy link
Copy Markdown
Contributor

/ai-review override gpt 1b9e2b7: same as the override on ee194bb — the "published template leaves governance reprojection" finding is a pre-existing repo-wide gap for every template in the agents dir, not something this PR introduces; tracked in #9598. (Lane treats this as whole-commit; the sandbox.py:860 symlinked-agents-dir finding remains open and unreviewed.)

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@CrysisDeu marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616.

same as the override on ee194bb — the "published template leaves governance reprojection" finding is a pre-existing repo-wide gap for every template in the agents dir, not something this PR introduces; tracked in #9598. (Lane treats this as whole-commit; the sandbox.py:860 symlinked-agents-dir finding remains open and unreviewed.)

This decision applies only to this commit. A new push requires a new judgment.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded, but the following reviewer lane(s) could not be re-run automatically: GPT 5.6. Re-run the lane's latest workflow run for 1b9e2b71026ae3777b6c8a0a4b4a94332f63f616 manually from the Actions tab.

@CrysisDeu

Copy link
Copy Markdown
Contributor

Rebased onto main (24fb0e5 -> 1b9e2b7) to pick up #9861, which regenerates settings-registry.generated.json — the cause of the inherited Frontend Tests (3) / Coverage Merge / Coverage Gate reds on the previous head. Clean rebase, no conflicts, no changes to this PR's own diff (61 files vs main, same as before). Static gates pass. The First Principles BLOCK on the delegated-workspace refusal is unchanged and still awaiting @CrysisDeu's decision; nothing in that span moved. -- @xuejinT FYI

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants