Skip to content

Lifecycle(feat): Add ownership and server startup - #49

Draft
tony wants to merge 3 commits into
masterfrom
lifecycle-mvp
Draft

tony wants to merge 3 commits into
masterfrom
lifecycle-mvp

Conversation

@tony

@tony tony commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Ordinary copied programs can call Server.Ensure(ctx) to use the configured default endpoint whether a tmux daemon is running or absent. The quick start includes imports and an entry point, uses the ordinary public server type, and leaves teardown to the external example harness. The previous scoped-cleanup program remains as a separate lifecycle example.

LIBTMUX_SOCKET_PATH and LIBTMUX_SOCKET_NAME supply endpoint defaults externally. The harness builds the exact displayed program and runs it twice in each isolated case. Ensure establishes availability without transferring destruction ownership to the caller. Existing daemons retain their sessions and configuration, subject to the documented initialization of the reserved ownership generation when absent.

Startup follows normal tmux configuration. The implementation retains the accepted bootstrap session ID so a rename hook cannot redirect rollback. If configuration removes the private startup marker, it cannot prove whole-server ownership. It then removes only its accepted bootstrap when another session or exit-empty off keeps the server alive; otherwise it retains that detached session for availability. Cancellation and failed initialization retain only the accepted session owner for cleanup retry on this unclassified path. Repeated calls reuse the daemon without adding another bootstrap.

The broader lifecycle change provides Owned[T], adoption of existing server/session/window/pane objects, bounded cleanup through CloseInto(&err), generation-checked destruction, bounded discovery with diagnostics, and find-or-create for each object kind. Explicit ownership remains separate from ordinary availability. Calls derived from one server share cancellation-aware coordination; independent clients remain outside that serialization boundary.

Validation

  • The final startup repair passes the 22 unchanged earlier critic cases (182 assertions), focused Ensure/FindOrCreate race tests on tmux 3.2a and 3.7d, and core/example lint, vet and formatting with cached Go 1.26.9.
  • Fresh independent review passes 28 focused cases (330 assertions) covering startup hooks, lifetime, reuse, cancellation, unrelated starters, retry authority and replacement rejection. It finds no new scoped defect.
  • Eight exact README cases cover tmux 3.2a/3.7d, absent/running daemons and path/name defaults. Each program executes twice; 84 independent assertions pass.
  • Six independent causal-control runs detect the original startup defects and whole-server rollback escalation. The review records 227 accepted process exits before 43 private-root removals.
  • Existing comments, tests, cleanup examples and compatibility files are preserved. The earlier implementation has separate lifecycle, discovery and module evidence; those broader results are not relabeled as full validation of this final startup repair.

Remaining work

This remains a draft. Full module aggregates, the complete 15-version tmux matrix on this repaired source, initial Go 1.26.0 execution, installed-package checks, native documentation-format integration and the nine-dimension acceptance assessment remain open. Earlier observers did not retain the identities of two separate native fixture directories; their removal remains unverified. They were not swept or claimed cleaned.

Markdown, Astro Markdown/MDX, Sphinx reST/MyST and Python doctest remain in the wider example-testing scope. This PR does not establish those integrations, hosted CI results, release latency, IAM or CI-cost acceptance. macOS and benchmarks remain outside scope. MCP source is unchanged; these Go checks do not establish real MCP-client fidelity.

Continues the work and discussion in #47 on the common lifecycle-mvp branch.

@tony tony changed the title Lifecycle(feat): Add owned tmux resource scopes Lifecycle(feat): Add ownership and server startup Oct 10, 2026
tony added 3 commits October 10, 2026 18:19
why: Callers need native deferred cleanup and ordinary examples that an
external harness can redirect without changing their source.

what:
- Capture endpoint and child environment defaults at construction
- Add generation-bound ownership, adoption and acquisition recovery
- Add bounded discovery and explicit created-or-reused results
- Execute ordinary examples under external socket defaults and cover
  cleanup failures, cancellation, replacement daemons and concurrency
why: Completed client failures lost known child IDs, canceled callers
could wait indefinitely for find-or-create coordination, and discovery
changed the meaning of endpoints containing symlink and parent components.

what:
- Retain valid creation receipts before classifying client failures
- Allow queued find-or-create callers to return on cancellation
- Preserve filesystem path components and configured-root deduplication
- Display and execute the complete ordinary README program
- Prove recovery, cancellation and example failure checks with mutations
why: Copied programs need a usable default endpoint without fixture
setup or mandatory ownership and teardown.

what:
- Add Ensure and complete ordinary programs while retaining cleanup
  examples under their own name
- Keep accepted startup IDs through configuration hooks and retain
  only a needed bootstrap when server provenance is unavailable
- Exercise startup, reuse, cancellation and session-only recovery
  through isolated external example runs

This branch has not been deployed

No deployments
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