Skip to content

fix(hooks): identity-match team-name detect-and-align (v4.4.31)#993

Merged
michael-wojcik merged 6 commits into
Synaptic-Labs-AI:mainfrom
michael-wojcik:fix/team-name-detect-align
Jun 19, 2026
Merged

fix(hooks): identity-match team-name detect-and-align (v4.4.31)#993
michael-wojcik merged 6 commits into
Synaptic-Labs-AI:mainfrom
michael-wojcik:fix/team-name-detect-align

Conversation

@michael-wojcik

Copy link
Copy Markdown
Collaborator

What

Identity-match team-name detect-and-align. get_team_name() resolves the REAL platform team by matching config.json['leadSessionId'] == session_id, correcting a non-empty-but-wrong persisted SSOT — a computed session-<id8> name when the platform provisioned a full-UUID team dir (Desktop 2.1.177 child / rename-skip), or a stale name after --resume. The bootstrap marker hook writes the aligned name back to the context file and the (exists-guarded) CLAUDE.md Team line; session_init and heal_context_if_missing converge on the aligned name so all writers agree.

Security — fail-closed preserved (Option B)

An empty SSOT stays fail-closed: get_team_name short-circuits to "" BEFORE identity-match, preserving the deliberate test_empty_ssot_team_fails_closed_both_modes gate. Identity-match recovers only a non-empty-but-wrong SSOT (exactly what this targets). The resolver is pure, FS-read-only, never-raises (bare except Exception → persisted/computed default), keys on the persisted (lead's) session_id — not the acting frame's, preserving the dual-mode SSOT contract — and path-safety-checks the matched dir name before returning it.

Verification

  • 48-test comprehensive matrix: both-modes merge gate, full-UUID fixture, fail-safe totality (NUL// session_id, teams_dir=None, HOME-unresolvable, config-is-a-dir), crash-recovery via heal, full-UUID caller sweep, two-file context-first write-back.
  • Full suite: 9231 passed / 0 failed / 0 errors.
  • Two independent design verifications (adversarial workflow, verdict revise_minor → proceed) + an auditor GREEN-VERIFIED pass against git diff ground truth.
  • Import-closure drift (the new write-back imports growing bootstrap_gate/bootstrap_marker_writer closures) caught by the live-probe drift-detector and fixed; no L3 live-probe re-cert needed (both hooks are fail-closed/L2-only).

Closure

Implements the #989 get_team_name detect-and-align fix. Closure pending a post-install live-probe in a divergent-launch (Desktop full-UUID) session — verifying the fix auto-resolves the divergence end-to-end (this session has been hand-correcting the context repeatedly, which the fix is designed to eliminate). v4.4.29 → v4.4.31.

…heal

get_team_name() resolves the real platform team by matching config.json.leadSessionId == session_id, correcting a non-empty-but-wrong persisted SSOT (a computed session-<id8> name when the platform provisioned a full-UUID team dir, or a stale name after resume). An empty SSOT stays fail-closed (deliberate security gate — identity-match does not recover from an unknown team). The bootstrap marker hook writes the aligned name back to the context file and the exists-guarded CLAUDE.md Team line; session_init and heal_context_if_missing converge on the aligned name so all writers agree. The resolver is pure, FS-read-only, and never raises (bare except -> persisted/computed default).
…riter

The identity-match write-back added resolve_project_claude_md_path (claude_md_manager) and update_session_info (session_resume) imports to bootstrap_marker_writer, pulling those plus transitive pin_caps and staleness into the live import closures of both bootstrap_marker_writer and bootstrap_gate (which imports it). Update the _SEAM_HOOK_HELPER_CLOSURE drift-detector literal to record the real closure. No live-probe re-certification needed: both hooks are fail-closed/fail-loud (L2-only), not in L3_LIVE_PROBE_HOOKS.
…n matrix

48 tests across a new test_team_name_detect_align.py plus one divergent end-to-end leg in the standing both-modes gate. Covers identity-match across full-UUID/session-<id8>/pact-<id8> dir names (no prefix shortcut); half-formed window; fail-safe totality (NUL/slash session_id, teams_dir=None, HOME-unresolvable, config-is-a-dir -> never raises); is_safe_path_component skip; empty-SSOT fail-closed both modes; resume-revert upgrade; cold-start; heal crash-recovery (absent-context -> aligned); both-modes resolver + dispatch-gate legs; _aligned_cache memoization + reset_for_tests isolation; full-UUID caller sweep; two-file context-first write-back. Non-vacuous via paired intact/neutered monkeypatch proofs.
Peer-review fold for PR Synaptic-Labs-AI#993. (1) Corrected _resolve_aligned_team_name docstring: session_id is only string-compared to leadSessionId, never composed into a path, so it cannot raise; the genuine bare-except raise sources are Path.home (RuntimeError), Path(teams_dir) (TypeError), and per-entry config.json read (OSError/JSONDecodeError). (2) Re-pointed the NUL/slash session_id tests to assert the real no-match-returns-default behavior (non-vacuous: seeded matchable dir + counter-proof). (3) Added a memoization test for the empty-SSOT short-circuit. (4-5) Clarifying comments: context-first write ordering, same-OS-user TOCTOU mitigation. (6) Expanded the no-match scan-cost PERF note.
Completes the docstring correction: the outer except-block comment still cited 'a path-unsafe raw session_id (ValueError)' as a totality source, contradicting the corrected docstring (session_id is string-compared, never path-composed). Cite the genuine raise sources (Path.home RuntimeError, Path(teams_dir) TypeError) instead. Comment-only; caught by the verify-only re-review.
@michael-wojcik michael-wojcik merged commit c46e333 into Synaptic-Labs-AI:main Jun 19, 2026
1 check passed
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