Skip to content

fix: stop listing a linked panel template that cannot render - #36732

Merged
bolichen97 merged 1 commit into
mainfrom
fix/36120-panel-template-symlink
Nov 17, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/36120-panel-template-symlink

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A panel template linked into the override folder from outside it is no longer offered, so the crew named after it publishes with the default template instead of failing.

available_templates() lists every *.html entry whose Path.is_file() is true, and is_file() follows a symlink. resolve_template() refuses an override whose link leaves the override directory. So a template linked in from outside is listed, template_for_crew() hands it to the crew of the same name, and publishing it raises PanelError("unknown_template").

Why it matters

Linking a template into the override folder from a dotfiles repo is a common stow or chezmoi layout. resolve_template refuses such a link, yet the template list still offers it, so the crew named after that template fails every default panel_publish with unknown_template, and the templates route advertises an id that cannot render. The only way out is to know to pass template="default".

Not a goal

  • Serving a template whose link leaves the override folder: the containment check in resolve_template stays as it is.
  • Changing how a linked override folder itself is refused (panel_dir_is_a_symlink).
  • Changing which templates ship, or how a crew name picks its template.

What changed (motivation → approach → change)

A crew named after a template linked in from outside the override folder failed every panel publish with unknown_template. That template is no longer listed, so the crew gets the default template and its panel publishes.

The template list and the template reader used two different rules. The list kept any *.html entry for which is_file() is true, and is_file() follows a link. The reader (resolve_template) checks one more thing: the link's target must stay inside the folder. So the list offered ids the reader refused.

src/kiro_crew/agent_panel.py puts that one containment rule in a small helper, _contained(root, candidate), and both functions call it. resolve_template behaves exactly as before. available_templates lists an entry only when it is a .html file and the helper accepts it; an entry the helper cannot resolve is skipped, like an unreadable folder already is. A link to a file inside the folder is still listed and served.

Backwards compatibility

Compatible: the only id that leaves the list is one resolve_template never served, so every id that publishes today still publishes.

Reader: src/kiro_crew/agent_panel.py:template_for_crew -- crew page -- a crew named after an outside-linked template gets default instead of an id that refuses to publish; test_a_template_linked_from_outside_its_directory_is_not_offered
Reader: src/kiro_crew/dashboard/handlers/agent_panel_publish.py:api_agent_panel_templates -- crew page -- GET /api/agent-panel/templates stops advertising an id that cannot render, and its default comes from template_for_crew above; test/test_agent_panel_routes.py passes unchanged
Reader: src/kiro_crew/mcp_panel.py:_call_tool_inner -- chat -- the kirocrew-panel MCP templates tool reads that route over HTTP and lists what it returns, so it no longer suggests the unrenderable id

Tests

  • test/test_agent_panel_store.py::test_a_template_linked_from_outside_its_directory_is_not_offered (new): an override bespoke-crew.html linked to a file under tmp_path is not in available_templates(), template_for_crew("bespoke-crew") == "default", and publishing with that choice succeeds. Control in the same test: an override linked to a real file inside the override directory stays listed, and resolve_template returns its body. With the fix reverted it fails on assert 'bespoke-crew' not in [...]. Its contract is a real file symlink, so test/requires-real-symlinks.txt names it, and the suite skips it only on a host that cannot create one.

Proof: PROVEN test/test_agent_panel_store.py::test_a_template_linked_from_outside_its_directory_is_not_offered (head a0d53646a53f)

Manual verification

Run on Ubuntu 24.04 (Linux, Python 3.12.3), against the store that the publish and templates routes call, each time with a fresh isolated data home (KIROCREW_HOME=$(mktemp -d)). Reaching it over HTTP would take a gateway plus an internal-secret caller, and that caller ends up making this same function call.

Before (base 529da1ee2), the issue's script:

listed: True
chosen: bespoke-crew
publish: unknown_template

After (a0d53646a53f, this patch on that base), the same script:

listed: False
chosen: default
publish: ok

Happy path on the same commit: a plain override my-board.html, and an override symlink inner-link.html pointing to inner-target.html in the same directory:

available: ['default', 'inner-link', 'inner-target', 'kirocrew-conductor', 'kirocrew-pipeline-conductor', 'my-board']
my-board listed: True
my-board publish: ok
inner-link listed: True
inner-link publish: ok

Related Issues

Closes #36120

Sibling sweep

Swept: git grep -nE "is_file()|is_relative_to|.resolve()" -- src/kiro_crew/agent_panel.py src/kiro_crew/dashboard/handlers/agent_panel_publish.py src/kiro_crew/mcp_panel.py (available_templates and resolve_template are the only listing/serving pair; both call _contained)
Sibling: src/kiro_crew/agent_panel.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/agent_panel_publish.py -- not affected -- it only relays available_templates() and template_for_crew() and runs no file check of its own
Sibling: src/kiro_crew/mcp_panel.py -- not affected -- it reads the templates route over HTTP and never opens the directory

Pattern harvest

Not generalizable: two hand-written copies of one containment rule inside a single module; the fix makes both call one helper, and no lint can tell a listing from the serving path it should match.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 53abdb9143f920e21d96b7f8c7d4aadbc6ff3ed4 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 53abdb9143f920e21d96b7f8c7d4aadbc6ff3ed4 — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. The list and the reader now share one containment rule, so the cause is fixed and no second rule remains.

What this change ships

Inventory (4 items) — 4 justified

Intent: a crew named after a template that is symlinked into the override folder from outside should publish with the default template instead of failing. This is a FIX.

  1. A template linked into the override folder from outside it no longer appears in the templates list or the GET /api/agent-panel/templates route — justified
  2. A crew named after such a template now gets default, so its panel publish succeeds instead of failing with unknown_template — justified
  3. The containment check resolve_template ran inline is now one private helper, _contained, that the template list also calls — justified
  4. A template listing skips an entry whose resolve raises OSError, the same way an unreadable folder is already skipped — justified

[FIRST-PRINCIPLES-REVIEWED] 53abdb9

Description read

[DESCRIPTION-READ] 7ff907b6d58a1ae82d97965057b9c7b04b3a6d5623da2efb6b0f0f8889c77eb0

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 53abdb9143f920e21d96b7f8c7d4aadbc6ff3ed4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the template list now uses the same containment rule as resolve_template, so it only offers ids that can render, and the only id removed is one the reader never served.

[DESIGN-REVIEWED] 53abdb9

Description read

[DESCRIPTION-READ] c4bde0838d4a3f2c951aa4ebbd1976550362ab7e981b9c2f3b322dd478baee22

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 53abdb9143f920e21d96b7f8c7d4aadbc6ff3ed4 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 53abdb9

Verdict parsed from the review's SHA-scoped output markers for commit 53abdb9143f920e21d96b7f8c7d4aadbc6ff3ed4.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 53abdb9143f920e21d96b7f8c7d4aadbc6ff3ed4 false-positive: <reason, 20 to 500 characters>

@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 16:20
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 53abdb9143f920e21d96b7f8c7d4aadbc6ff3ed4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 53abdb9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 53abdb9143f920e21d96b7f8c7d4aadbc6ff3ed4 false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 7% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

available_templates() now applies the same containment rule resolve_template() already enforced, through a shared _contained helper, so an override linked from outside its folder is no longer listed and the crew named after it falls back to the default template. resolve_template's behaviour is unchanged (same resolve and is_relative_to check, same exception handling). The listing filter covers both the shipped and override folders, matching the serving path. The only ids removed are ones that could never render, so no regression for the template route, template_for_crew or the MCP relay. The new test fails without the fix, includes an inside-link control, and is registered in requires-real-symlinks.txt.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit eca8a7524e · 51 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@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 Nov 13, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve on eca8a75. The template list now uses the same containment rule as the template reader, through one shared helper. A template linked in from outside the override folder is no longer offered, so the crew named after it publishes with the default template instead of failing. Every id that rendered before still lists and renders, and a saved panel that names a hidden id behaves exactly as before, because the reader already refused it. The new test fails without the fix. One follow-up: no test pins the reader's own refusal of an outside link. Decisive lines: src/kiro_crew/agent_panel.py:397-401, src/kiro_crew/agent_panel.py:444-451, src/kiro_crew/agent_panel.py:473-476, test/test_agent_panel_store.py:379-401

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The one red on this head is not this change. Backend Tests (3.12, 7) failed on test/test_denied_commands_security_cost.py::TestSelfModuleIndexIsLinear::test_the_scan_is_linear_not_quadratic with AssertionError: 2k tokens took 0.514s against a 0.5 s wall-clock bound (job). Coverage Gate and PR Readiness are red only because they fail closed on that shard.

This diff touches src/kiro_crew/agent_panel.py and its test; it does not touch the denied-command scan. The same node id fails on unrelated heads across the repository, including docs-only pull requests, and the line itself carries a flake-ok note describing the 0.5 s backstop as pre-existing. Flake ledger: #28212. The fix in flight is #28293, which reads these ceilings on thread CPU time instead of the wall clock.

Recorded on the ledger, then rerunning the failed jobs once. Every review lane is green on this head (Design PASS, First Principles PASS, GPT and Opus with no findings), there are no unresolved threads, and auto-merge is already armed.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The one red on this head is still not this change, and it is a different red from the one in my earlier comment.

Backend Tests (3.12, 7) attempt 2 timed out four tests in src/kiro_crew/apps/builtins/design_critique/tests/test_ssrf_guard_fail_closed.py - TestInstallSsrfGuardRuntime::test_resolves_with_route_websocket, ::test_rejects_without_route_websocket, TestGetPlaywrightVersionGate::test_usable_cache_is_returned and ::test_stale_cache_is_not_returned - each Failed: Timeout >120.0s (job). The shard reported peak memory in use: 15011 MiB of 15738 MiB and those four tests were its four slowest calls, at 121.3s each. Coverage Gate and PR Readiness are red only because they fail closed on that shard.

This diff touches src/kiro_crew/agent_panel.py, its test and one line of test/requires-real-symlinks.txt. It touches nothing under src/kiro_crew/apps/, so no test in that file can reach it. The same four node ids have been reported red today on many unrelated heads, docs-only pull requests included, and the same shard also fails on main's own push runs in the same windows. The ledger entry is #36261 and the runner-memory fix is #36653.

This occurrence is recorded on #36261. That flake has far more than two ledger reports in the last 14 days, so it does not get another rerun here: this pull request waits for #36653 to land and then rebases onto it. Auto-merge stays armed, and every other check and every review lane is green on eca8a7524ebf.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] This PR still needs one rebase, and it waits for #37254 before taking it.

The red on this head is Backend Tests (3.12, 7): main's shard-7 memory ceiling (#36261). Its fix, #36648, is on main now, so the branch has to be rebased to pick it up; a rerun would test the old merge base again.

Current main has a red of its own, though. test/test_conductor_agent.py::TestConductorInstaller::test_back_to_back_rounds_keep_a_spend_bound fails on main since #37030 (#37243): the test fails when the skill text contains at most 6, and that text now says at most 600 characters. A rebase today would swap one main red for another, so the fix for that, #37254, goes first. Once it merges I rebase onto main, re-run the gates and push. That push will need a fresh approval.

available_templates() kept every *.html entry whose is_file() was
true, which follows a symlink, while resolve_template() refuses an
override whose link leaves the override directory. A template linked
in from outside (a stow or chezmoi dotfiles layout) was therefore
listed, template_for_crew() picked it for the crew of the same name,
and every default publish failed with unknown_template.

Both functions now share one containment helper, so a listed id is
always one resolve_template serves. The refusal itself is unchanged;
a link to a file inside the override directory stays listed.

Closes #36120

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/agent_panel.py, test/requires-real-symlinks.txt, test/test_agent_panel_store.py since this head went green (c22557c -> 6dd5dac); CI re-running.

This is the rebase my earlier comment said was waiting: the new base carries main's shard-7 memory fix (#36648) and the conductor-test fix (#37254). The change itself is the same set of changed lines as before. The push clears the earlier approval, so this head needs a fresh one.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/36120-panel-template-symlink branch from eca8a75 to 53abdb9 Compare November 17, 2026 13:03
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 17, 2026
@bolichen97
bolichen97 merged commit c7cf72d into main Nov 17, 2026
98 checks passed
@bolichen97
bolichen97 deleted the fix/36120-panel-template-symlink branch November 17, 2026 14:34
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 17, 2026
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.

Panel template list offers a linked override that resolve_template refuses

3 participants