Skip to content

feat(protocol,lifecycle): 6-task sprint — hooks, proto schema, drain, tracking, tests - #44

Merged
4 commits merged into
devfrom
feat/protocol-lifecycle-sprint
Apr 9, 2026
Merged

4 commits merged into
devfrom
feat/protocol-lifecycle-sprint

Conversation

@explosivebit

Copy link
Copy Markdown
Contributor

Summary

Executed as parallel sprint via TeamCreate (6 teammates + team-lead). All 6 tasks completed with no conflicts thanks to careful file ownership planning.

Tasks

# Agent Task Files
1 hook-renamer Broker hook aliases (Node.js compat) middleware/base.py, broker.py
2 proto-extender PacketHeartbeat proto schema extension proto/packets.proto, pb2, protobuf.py
3 tracking-configurator TrackingConfig in Settings settings.py
4 connection-drainer Connection drain on stop transit.py, broker.stop()
5 tracker-integrator ContextTracker auto-register broker.init
6 test-author Protocol lifecycle test suite tests/unit/protocol_lifecycle_test.py

Protocol compliance improvements

  • Hook aliases: Node.js middleware using started/stopping now works with MoleculerPy
  • Heartbeat schema: seq/instanceID/memory/cpuSeq now preserved via ProtoBuf (was silently dropped)
  • Graceful shutdown: INFO(services=[]) broadcast before DISCONNECT eliminates race with remote routing
  • Tracking config: declarative ContextTracker middleware via Settings.tracking
  • 12 new integration tests covering all 5 changes end-to-end

Evidence

Check Result
ruff format + check ✅ 0 errors
mypy --strict ✅ 0 errors
pytest unit+e2e 2396 passed (+18 new)
demo_matrix ✅ 28/28 OK
demo_comprehensive ✅ 90/90 OK

Test plan

  • Unit tests: 2396 passed
  • Demo matrix: 28/28 OK
  • Demo comprehensive: 90/90 OK
  • mypy strict: 0 errors

🤖 Generated with Claude Code

explosivebit and others added 4 commits April 7, 2026 14:25
Release v0.14.21:
- Redis Cacher production-ready (start/stop lifecycle, 16 integration tests)
- seq/instanceID heartbeat checks (Node.js parity)
- 10 audit findings fixed (3 CRITICAL: instanceID persistence,
  payload guard, logger fallback + 4 HIGH + 3 MEDIUM)

Evidence: 2374 tests, 28/28 demo matrix, 90/90 comprehensive, mypy 0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Version: 0.14.21 (supersedes 0.14.20)
CHANGELOG: both 0.14.20 and 0.14.21 entries preserved

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Release v0.14.21 — Redis Cacher + seq/instanceID heartbeat + audit fixes
…rallel

Sprint executed via TeamCreate with 6 teammates coordinated by team-lead.
Node.js parity fixes for protocol + graceful lifecycle.

## Tasks completed

1. **Broker hook rename with aliases** (hook-renamer)
   - middleware/base.py: added short aliases starting/started/stopping
   - broker.py: _call_middleware_hooks invokes both long + short names
   - Backward compatible — existing broker_* middleware works unchanged
   - Skipped `stopped` alias due to collision with existing no-arg cleanup hook

2. **PacketHeartbeat proto schema extension** (proto-extender)
   - serializers/proto/packets.proto: added fields 4-7 (seq, instanceID, memory, cpuSeq)
   - Regenerated packets_pb2.py
   - protobuf.py: _HEARTBEAT_MAX_FIELDS 4 → 8
   - ADR-heartbeat-schema.md documenting the decision
   - Wire-compatible with Node.js (ignores unknown fields)

3. **TrackingConfig in Settings** (tracking-configurator)
   - settings.py: TrackingConfig dataclass (enabled=False, shutdown_timeout=5.0s)
   - Validation in Settings._validate()
   - Exported via moleculerpy/__init__.py

4. **Connection drain on broker stop** (connection-drainer)
   - transit.py: send_disconnect_info() broadcasts INFO(services=[]) before disconnect
   - broker.stop(): calls send_disconnect_info() BEFORE transit.disconnect()
   - Matches Node.js service-broker.js:531-539 pattern
   - e2e test with 2 memory brokers verifies remote node drops math.add before DISCONNECT

5. **ContextTracker auto-registration** (tracker-integrator)
   - broker.py __init__: auto-append ContextTrackerMiddleware if settings.tracking.enabled
   - Converts float seconds → int ms for middleware
   - e2e test: slow action in-flight, stop() waits for completion

6. **Protocol lifecycle test suite** (test-author)
   - tests/unit/protocol_lifecycle_test.py (12 tests, ~270 LOC)
   - System-level integration tests for all 5 changes above

## Evidence

- ruff format + check: clean
- mypy --strict: 0 errors
- pytest: **2396 passed** (2378 baseline + 18 new)
- demo_matrix: 28/28 OK
- demo_comprehensive: 90/90 OK

Refs: Protocol gap audit report

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Apr 7, 2026

Copy link
Copy Markdown

@explosivebit explosivebit closed this pull request by merging all changes into dev in 49f570b Apr 9, 2026
@explosivebit explosivebit mentioned this pull request Apr 9, 2026
4 tasks
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