Skip to content

Deeply harden runtime state and lifecycle ownership - #341

Merged
kfiramar merged 8 commits into
integration/consolidate-open-prs-20260711from
agent/deep-runtime-refactor
Jul 11, 2026
Merged

kfiramar merged 8 commits into
integration/consolidate-open-prs-20260711from
agent/deep-runtime-refactor

Conversation

@kfiramar

@kfiramar kfiramar commented Jul 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Replace mutable runtime state with atomic immutable revisions, dual-copy generation arbitration, integrity fingerprints, tombstone fencing, bounded cleanup, and scoped ownership aggregation.
  • Make startup, restart, stop, rollback, worktree cleanup, process-group termination, and port reservations fail closed without losing authority for surviving services or dependencies.
  • Preserve mixed tree owners and shared dependencies across repeated starts and targeted stops; add exact planner-session identity so stale state cannot release a newer identical owner/port lock.
  • Harden PR creation and shipping against duplicate races, existing-PR base drift, stale remote refs, and linked checkouts outside the configured trees directory. Default PR bases are dev, then main, then master.
  • Split oversized ship, inspection, and lifecycle facades into focused owner modules while preserving public APIs and patch points.

Validation

  • Focused handoff gate:
    • planning: 569 passed, 99 subtests passed
    • actions: 546 passed, 33 subtests passed
    • config: 209 passed
    • startup: 428 passed, 8 subtests passed
    • runtime: 1,122 passed, 330 subtests passed, 15 skipped
    • shared and workflow contracts: 286 passed, 164 subtests passed
    • Ruff over every changed Python file: passed
  • Adversarial E2E:
    • 24 simultaneous starts serialized safely with one active owner and correct busy rejection
    • 96-record, 8-writer/3-reader run-index stress with matching primary/backup copies
    • multi-process and multi-thread port allocation/reclamation remained unique
    • mixed Alpha/Beta listeners survived partial stops and repeated fresh starts correctly
    • SIGKILL recovery, main/tree isolation, duplicate history, stale aliases, and process-group teardown passed
    • final sweep across 11 temporary roots: zero active runs, numeric port locks, temp files, pending cleanups, open handles, surviving processes, or test listeners

Notes

  • This is intentionally a draft because the change is broad.
  • The branch is rebased on current main and merge-conflict prediction is clean.

@kfiramar
kfiramar marked this pull request as draft July 11, 2026 14:21
@kfiramar
kfiramar marked this pull request as ready for review July 11, 2026 14:24
@kfiramar

Copy link
Copy Markdown
Collaborator Author

@codex review

@kfiramar
kfiramar marked this pull request as draft July 11, 2026 14:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce242f3272

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

PR #410's self-hosted preview failure is now covered by two envctl hardening commits on this draft PR.

  • 72cec8a8: exports the authoritative engine interpreter as ENVCTL_PYTHON_EXECUTABLE; rejects non-executable command paths; reports spawn failures structurally; classifies exec: python: not found as dependency_missing; and prevents a dead tracked PID from falling through to generic port adoption.
  • cd20552e: makes explicit preview start reconcile even when the Git SHA is unchanged, so changed CI/secret inputs cannot be hidden by stale runtime reuse; routed JSON health responses that say ready:false now fail even with HTTP 2xx.

Validation:

  • Focused startup/runtime/contract suites passed for the interpreter hardening.
  • PR-preview controller suite: 62 passed.
  • Current GitHub CI: Ruff, pytest, and build/shipability all passed.
  • PR remains draft, clean, and mergeable.

@kfiramar
kfiramar marked this pull request as ready for review July 11, 2026 18:55

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd20552eed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

Addressed all four unresolved review findings in 4071b18:

  • plain stop-all now spans active main/tree runs unless the user explicitly scopes a mode;
  • cleanup reports success when a failed process-group call nevertheless leaves the recorded PID gone or replaced;
  • non-strict project state lookup filters matching projects before choosing the newest mode;
  • setup-worktree dependency and service reservations use the effective trees startup mode.

Validation: 114 focused tests passed with 42 subtests, Ruff passed, git diff --check passed, and all three GitHub checks passed.

Copy link
Copy Markdown
Collaborator Author

@codex review

1 similar comment

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4071b18694

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python/envctl_engine/shared/ports.py Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown
Collaborator Author

Addressed the four latest review findings in ce794fae:

  • worktree deletion now loads full mode state and preserves sibling projects/resources;
  • fresh-start replacement is scoped to the requested route/services;
  • resume restoration releases recorded-session port locks with the recorded owner identity;
  • plan-agent runtime-address lookup falls back to unfiltered/base-project state.

Validation: focused regressions (100 passed, 1 subtest), related lifecycle/resume/reuse/address suites (175 passed, 1 subtest), caller-level startup/resume suites (55 passed, 6 subtests), Ruff, compilation, and git diff --check. GitHub pytest, Ruff, and build/shipability checks are green.

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@kfiramar
kfiramar changed the base branch from main to integration/consolidate-open-prs-20260711 July 11, 2026 20:49
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@kfiramar kfiramar closed this Jul 11, 2026
@kfiramar kfiramar reopened this Jul 11, 2026
@kfiramar
kfiramar changed the base branch from integration/consolidate-open-prs-20260711 to main July 11, 2026 20:57
@kfiramar kfiramar closed this Jul 11, 2026
@kfiramar kfiramar reopened this Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Reconciled this branch with the consolidation sidebranch in 45b3100f while preserving #337's linked-worktree fail-closed targeting and all #341 lifecycle/state ownership behavior.

The merge also exposed and fixed a real ship edge case: already-staged tracked deletions are no longer re-added as nonexistent pathspecs. Coverage now distinguishes staged-only changes from unstaged/deleted/renamed paths and includes real-git deletion regressions. The repository wrapper then successfully shipped the exact deletion-bearing merge that had previously failed.

Validation: 86 conflict/action/planning tests + 32 subtests; 32 commit/ship tests + 5 subtests; targeted Ruff/diff checks; full GitHub pytest, Ruff, build, and shipability run 29167963778 green on the combined #336+#337+#341 head.

@kfiramar
kfiramar changed the base branch from main to integration/consolidate-open-prs-20260711 July 11, 2026 21:00
@kfiramar
kfiramar merged commit 2a793d1 into integration/consolidate-open-prs-20260711 Jul 11, 2026
3 checks passed
@kfiramar
kfiramar deleted the agent/deep-runtime-refactor branch July 11, 2026 21:01
kfiramar added a commit that referenced this pull request Jul 12, 2026
Consolidates #335, #336, #337, and #341 after review closure, adversarial E2E validation, and final green local/GitHub gates.
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