Skip to content

Harden Phase for v0.1.0 release - #2

Merged
zekageri merged 22 commits into
mainfrom
agent/phase-v0.1.0-hardening
Jul 15, 2026
Merged

Harden Phase for v0.1.0 release#2
zekageri merged 22 commits into
mainfrom
agent/phase-v0.1.0-hardening

Conversation

@zekageri

Copy link
Copy Markdown
Contributor

Summary

Implements the v0.1.0 release-hardening work tracked in #1.

Runtime safety

  • replaces the task-exit completion race with an explicit worker-exit handshake
  • ensures end() returns only after the worker has stopped accessing PhaseImpl
  • rejects end() from lifecycle callbacks and other Phase-task callbacks instead of deadlocking
  • safely defers PhaseImpl destruction when a Phase object is destroyed from its own callback
  • snapshots change-event message and pause-reason text for the full callback invocation
  • keeps callbacks outside the internal recursive mutex

Deterministic lifecycle execution

  • freezes and resolves the dependency graph before async boot
  • preallocates node, dependency-index, validation, and lifecycle-order storage
  • removes allocating std::string, dependency-vector, and std::function runtime snapshots
  • keeps boot, readiness, rollback, stop, and deinit paths allocation-free
  • preserves dependency-ordered init/start and reverse stop/deinit
  • documents stop/deinit callback failures as best-effort and observable through onChange()

Diagnostics and release gates

  • fixes stack high-water-mark reporting to remain byte-valued
  • adds a host FreeRTOS simulation and blocking behavioral tests
  • tests ordering, rollback, optional failures, pause/resume, pointer lifetime, self-end() rejection, cancellation/restart, teardown, and zero lifecycle allocations
  • makes host tests a prerequisite for all ESP32 example-build jobs and release creation
  • adds strict manifest/tag version validation
  • updates library.json, library.properties, and README status to 0.1.0

Root cause

The previous implementation published task completion before the FreeRTOS worker had fully stopped using its owner, copied allocating STL objects during lifecycle execution, and exposed pointers into mutable callback state. Compilation-only CI could not detect these behavioral and concurrency failures.

Validation

Locally executed with warnings as errors:

g++ -std=c++20 -pthread -Wall -Wextra -Werror \
  -Itests/host/stubs -Isrc \
  src/Phase.cpp \
  tests/host/semaphore_stubs.cpp \
  tests/host/task_stubs.cpp \
  tests/host/test_phase.cpp \
  -o phase-host-tests

./phase-host-tests

Result: Phase host tests passed.

The draft PR CI will additionally compile every example with PIOArduino and Arduino CLI for ESP32, ESP32-S3, ESP32-C3, and ESP32-P4.

Review notes

Phase.cpp remains a single translation unit. Its implementation is split into internal .inc fragments to make the state machine and public control paths easier to review without changing library linkage or exposing new public headers.

Addresses #1.

@zekageri zekageri mentioned this pull request Jul 15, 2026
57 tasks
@zekageri
zekageri marked this pull request as ready for review July 15, 2026 09:41
@zekageri
zekageri merged commit 6b12516 into main Jul 15, 2026
24 checks passed
@zekageri
zekageri deleted the agent/phase-v0.1.0-hardening branch July 26, 2026 17:55
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