Skip to content

Add J detach-coordinator-to-top-level in the native Hera view#814

Merged
anutron merged 1 commit into
masterfrom
argus/hera-detach-coordinator
Jun 25, 2026
Merged

Add J detach-coordinator-to-top-level in the native Hera view#814
anutron merged 1 commit into
masterfrom
argus/hera-detach-coordinator

Conversation

@anutron

@anutron anutron commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Problem

In the native Hera view, J on a coordinator could only nest it UNDER another coordinator (ReparentCoordinator). There was no inverse — a coordinator accidentally nested as a sub-coordinator had no escape hatch back to top-level. This PR adds one.

Key insight

A coordinator C nests under parent P via a worker "link role" in P bound to C's coordinator argus TASK (a bridge / multi-binding) — never a parent pointer on C. So detach-to-top-level is exactly ReparentCoordinator's BUG-026 teardown minus the recreate: end every live parent-link binding, then delete every distinct parent-link role (any binding of C's coord task on a role other than C's own coordinator role) so its bindings cascade. C's own coord role/binding are never touched.

Changes

  • internal/tui/hera/adopt.go — extracted the teardown into a single-source teardownParentLinks(taskID, coordRoleID, reason) helper; ReparentCoordinator now calls it (no duplication). Added exported DetachCoordinator(childOrchestratorID) (*DetachResult, error) + DetachResult + EndReasonDetached. Detach is idempotent (already-top-level ⇒ clean no-op, LinksRemoved==0, not an error). Genericized coordRoleOf's wording (now shared). Logs via uxlog.Log("[hera-view] detach: ...") on success and the no-op skip.
  • internal/tui/heraactions.go — UI approach: reuse J. The coordinator picker prepends a pointer-identity sentinel row — Detach (make top-level) —; picking it detaches instead of opening a re-parent target. No new keybinding → no help-modal / README keybinding churn. The coordinator picker now always opens (detach always offered), so the "no eligible target" bail is freelancer-only.
  • TestsDetachCoordinator un-nests a nested coord (link gone, coord role + binding intact, top-level again); idempotent no-op on an already-top-level coord; dormant-coord resolution via latest ended binding; unknown-orch + no-coord-role guards; ReparentCoordinator BUG-026 regression still holds (shared teardown unbroken); UI smoke tests for detach-through-picker and the updated re-parent row offset.
  • OpenSpec — change add-hera-detach-coordinator authored (proposal + hera-view delta + tasks), merged into the hera-view base spec, and archived in the same PR per CLAUDE.md.
  • Docs — gotcha bullet in context/knowledge/gotchas/hera-view.md (bridge-binding nesting model; detach = teardown-without-recreate) + index count bumped.

Verification — make pre-pr

  • build ✅ · vet ✅ · fmt-check ✅ · lint-pr ✅ (0 issues, golangci-lint v2.11.4) · test-cover-gate ✅ (filtered 89.5% ≥ 88; internal/tui/hera 91.9%)
  • make vuln finds only stdlib crypto/x509 CVEs (go1.26.3 → fixed 1.26.4); advisory only — CI runs vuln as continue-on-error and none are in our code.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

In the native Hera view, `J` on a coordinator could only nest it UNDER
another coordinator (re-parent). There was no inverse — an accidentally
nested coordinator had no escape hatch back to top-level. Add one.

Detach-to-top-level is exactly ReparentCoordinator's BUG-026 teardown
without the recreate: end every live parent-link binding + delete every
distinct parent-link role (all bindings of the coord task on roles other
than the coordinator's own coord role), recreating no link.

- adopt.go: extract the teardown into a single-source `teardownParentLinks`
  helper; `ReparentCoordinator` now calls it. Add exported
  `DetachCoordinator`/`DetachResult` + `EndReasonDetached`. Detach is
  idempotent (already-top-level => clean no-op, LinksRemoved==0). Genericize
  `coordRoleOf` wording (now shared).
- heraactions.go: the `J` coordinator picker prepends a pointer-identity
  `heraDetachSentinel` row ("— Detach (make top-level) —"); picking it
  detaches instead of re-parenting. Reuses `J` — no new keybinding, no
  help-modal/README churn. The coordinator picker now always opens (detach
  always offered), so the "no eligible target" bail is freelancer-only.
- Tests: detach un-nests; idempotent no-op; dormant-coord resolution;
  unknown-orch + no-coord-role guards; re-parent regression intact; UI smoke
  tests for detach-through-picker and the updated re-parent row offset.
- OpenSpec change add-hera-detach-coordinator authored, merged into the
  hera-view base spec, and archived in the same change.
- gotcha + index updated.

make pre-pr: build/vet/fmt-check/lint-pr(0 issues)/test-cover-gate(89.5%>=88)
all green; vuln finds only stdlib crypto/x509 CVEs (advisory, CI
continue-on-error, not in our code).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/drn/argus/internal/tui 83.97% (-0.02%) 👎
github.com/drn/argus/internal/tui/hera 91.92% (-0.22%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/drn/argus/internal/tui/hera/adopt.go 76.98% (-0.02%) 126 (+26) 97 (+20) 29 (+6) 👎
github.com/drn/argus/internal/tui/heraactions.go 77.63% (-0.25%) 438 (+4) 340 (+2) 98 (+2) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/drn/argus/internal/tui/hera/adopt_test.go
  • github.com/drn/argus/internal/tui/heraactions_test.go

@anutron anutron merged commit 2bface4 into master Jun 25, 2026
1 check passed
anutron added a commit that referenced this pull request Jun 26, 2026
…low-up) (#816)

#814 added "Detach (make top-level)" to the J coordinator picker, but it could
not be triggered on the exact case it was built for: an already-nested
sub-coordinator. A nested sub-coordinator renders as a headerless worker
"bridge" row in its parent (Role.Kind == worker), so heraCoordReparentTarget
returned false for it and heraOpenAdopt fell through to the "select a
freelancer or a coordinator" statusbar error. You could NEST a top-level coord
(selected as its orch header) but not UN-NEST it.

Fix: heraCoordReparentTarget now qualifies a THIRD shape — a non-archived
worker row whose Selection.BridgeChildOrchID is non-zero (the SAME field the
Ctrl+D cascade already reads). The rail stamps the bridged CHILD orchestrator
id there; that worker row IS the child's coordinator, so it routes the existing
heraAdoptCoordinator path (detach sentinel + DetachCoordinator, and
ReparentCoordinator for symmetry) against the CHILD orch. Only a bridge row
qualifies (BridgeChildOrchID != 0) — a plain worker is never misclassified, and
cycles are still rejected by ReparentCoordinator. Inert in remote mode.

No op-layer change (DetachCoordinator/ReparentCoordinator already resolve
everything from the child orch id). No new keybinding; help modal / README
unchanged.

OpenSpec: fix-detach-nested-bridge (archived in-PR; hera-view delta merged into
the base spec). Tests: TestHeraCoordReparentTarget bridge subtests +
TestSmoke_HeraDetachNestedBridgeThroughPicker /
TestSmoke_HeraReparentNestedBridgeThroughPicker. Gotcha added to hera-view.md.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
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.

1 participant