Skip to content

feat(driver): remote schedule registry via ScheduleStoreService driver protocol (#257) - #404

Merged
JAORMX merged 3 commits into
mainfrom
issue-257-schedule-store-driver
Aug 6, 2026
Merged

JAORMX merged 3 commits into
mainfrom
issue-257-schedule-store-driver

Conversation

@JAORMX

@JAORMX JAORMX commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #257. Adds a ScheduleStoreService (+ ScheduleOneShotReArmerService) to the driver protocol (contracts/proto/mecatl/driver/v1/) so the scheduled-tasks registry can be remote — consistent with the other driver stores (SessionStoreService, EventLogService, SessionLeaseService). Part of #189 (scheduled tasks); the mechanical mirror deferred out of #256.

Built with the dev pipeline: architect plan → 3 implementation waves → panel review (spec + standards + security + architecture + duplication + library-reuse) → QA test-adequacy review → iteration.

What lands

Wave 1 — wire protocol + grpcdriver wrappers

  • contracts/proto/mecatl/driver/v1/schedule_store.proto: the 13-RPC ScheduleStoreService (the issue listed 11; RecordFireStart/RecordFireProgress from Scheduled tasks: expose in-flight fire state, progress, and wall-clock timeout #386 are included — the conformance suite exercises them) + the 1-RPC ScheduleOneShotReArmerService. Schedules/fires cross as opaque format-tagged JSON envelopes (schedule-json/1, the SessionSnapshot precedent) the driver round-trips verbatim; Claim/ClaimNow/ReArmOneShot atomicity is implemented server-side by the driver (the harness client can't fence over the wire) — the same trusted-peer posture SessionStoreService takes.
  • internal/adapter/grpcdriver/schedulestore.go: thin client (port.ScheduleStore + port.ScheduleOneShotReArmer over the wire; NOT_FOUND → ErrScheduleNotFound, UNIMPLEMENTED → ErrScheduleUnsupported, mis-keyed-driver + unknown-format guards) and fail-closed server wrappers (every RPC validates before touching the backend; top-level key vs decoded-payload mismatch → INVALID_ARGUMENT).

Wave 2 — composition + operator flag

  • --schedule-store-url on mecated: a dedicated, independent override (the --event-log-url precedent; ADR 0059 decision ACP: accept image/audio prompt content blocks #5's "an independent override wins" arm). One resolveScheduleStore shared by the scheduler tick loop, the fire path, and the delivery-queue gate; dials through the shared driverConns cache (equal URLs share one connection, once-guarded close); fails loud on dial error. Unset = byte-identical store-accessor discovery. Operator-tier only (ACP-excluded; no project-tier influence).
  • Docs flipped: PRODUCTION-READINESS ✅, architecture/observability/usage + user-docs.

Wave 3 — no split-brain

  • server.ScheduleManagerConfig.ScheduleStore: the in-chat Schedule tool's manager takes the same resolved store, so tool + tick loop + fire path share ONE registry (otherwise the tool stayed absent with an accessor-less session store, or managed a different registry than the tick loop fired from).

Testing

  • Integration test (the ask): TestGRPCScheduleStoreConformance runs the full scheduleconformance suite (28 subtests) over the real gRPC wire via bufconn — client → wire → server wrapper → memschedulestore — proving Claim/ClaimNow/ReArmOneShot atomicity, RecordFire idempotency, Due filtering, and the sentinel mappings hold through the remote path (the same suite the in-process backends pass).
  • 26 wrapper unit tests: every error-classification arm (not-found/unsupported/ctx-cancel), every server-side validation arm (blank ids, bad envelopes, key mismatches — backend never called), mis-keyed-driver guards for both LoadSchedule and LoadFire, driver-NOT_FOUND-tolerant Delete, the re-arm happy path and its UNIMPLEMENTED → ErrScheduleUnsupported degrade.
  • Composition tests: override resolution arms, Schedule-tool wiring with an accessor-less store, scheduler-start under the override, and the split-brain guard (override shadows an accessor-ful store).

Verification

task lint · task test (root + engine + provider modules, -race, engine-standalone) · task docs (matlatl strict: 0 broken/orphan/unreachable) · task api:check — all green. go run ./cmd/mecademo prints a full offline session.

Review notes

Panel review (spec/standards/security/architecture/duplication/library-reuse) found no ship-blockers: layering holds (no server ← grpcdriver edge), the driver-conn rides the existing driverConns inventory row, the proto/generated/docs conventions hold. A QA test-adequacy pass drove the error-path test additions in wave 1's iteration (fire-envelope validation, LoadFire guards, delete tolerance, blank-scalar table). One pre-existing gap noted for follow-up (NOT this PR's scope): a driver serving only ScheduleStoreService makes the scheduler's re-arm path WARN per tick rather than sticky-disable — the sticky-disable flag only exists on the Due path (internal/adapter/scheduler/scheduler.go:851); worth its own issue if we care.

JAORMX added 3 commits August 6, 2026 11:11
…iver protocol (#257)

Add the remote schedule-registry seam to the driver protocol so a
deployment can run its schedule store in a separate driver process,
consistent with SessionStoreService/EventLogService/SessionLeaseService.

- contracts/proto/mecatl/driver/v1/schedule_store.proto: the 13-RPC
  ScheduleStoreService (Save/Load/Delete/List/Due/Claim/ClaimNow/
  SetEnabled/RecordFire/RecordFireStart/RecordFireProgress/LoadFire/
  ListFires) + the 1-RPC ScheduleOneShotReArmerService (ReArmOneShot).
  Schedules and fires cross as opaque format-tagged JSON envelopes
  (schedule-json/1) the driver round-trips verbatim; the atomic
  Claim/ClaimNow/ReArmOneShot advance is implemented server-side by the
  driver (the harness client cannot fence over the wire) — the same
  trusted-peer posture SessionStoreService takes for snapshot opacity.
- internal/adapter/grpcdriver/schedulestore.go: the thin client wrapper
  (port.ScheduleStore + port.ScheduleOneShotReArmer over the wire;
  NOT_FOUND -> ErrScheduleNotFound, UNIMPLEMENTED -> ErrScheduleUnsupported,
  mis-keyed-driver and unknown-format guards) + the fail-closed server
  wrappers (every RPC validates before touching the backend; top-level
  key vs decoded-payload mismatch is INVALID_ARGUMENT).
- Validated by scheduleconformance.Run over bufconn (client -> wire ->
  server wrapper -> memschedulestore), incl. the Claim/ClaimNow/ReArmOneShot
  atomicity and RecordFire idempotency subtests, plus 20 wrapper unit
  tests covering the error-classification and validation arms.
…le registry (#257)

Compose the wave-1 driver into the deployment: a dedicated, independent
--schedule-store-url flag (the --event-log-url precedent; ADR 0059
decision #5's 'an independent override wins' arm) pointing the durable
schedule registry at a remote ScheduleStoreService driver.

- internal/app/build.go: resolveScheduleStore is the ONE resolution the
  scheduler tick loop (buildScheduler), the fire path (startScheduler's
  fireStore), and the delivery-queue gate (buildDeliveryQueue) all
  share; the override dials through the shared driverConns cache
  (equal URLs share one connection, once-guarded close) and fails loud
  on dial error (an explicitly-configured driver that won't dial is an
  operator misconfiguration, never a silent no-scheduling degrade).
  Unset keeps the byte-identical store-accessor discovery.
- cmd/mecated: the operator-tier flag + ACP-common-help exclusion
  (server-boundary surface, never a project-tier knob).
- Docs: PRODUCTION-READINESS flips the driver ScheduleStoreService from
  deferred to shipped; architecture.md/observability.md/usage +
  user-docs gain the flag and the two-service driver surface.
…stry for tool + tick loop (#257)

Close the split-brain the wave-2 override would otherwise open: the
in-chat Schedule tool's manager discovered its store ONLY by
type-asserting the session store, so --schedule-store-url + an
accessor-less session store left the tool absent while the tick loop
ran remote (and with an accessor-ful store the two would manage
DIFFERENT registries).

ScheduleManagerConfig gains an OPTIONAL explicit ScheduleStore that
wins over the accessor discovery (composition passes the one
resolveScheduleStore result); nil keeps the byte-identical accessor
path, and nil-from-both keeps the honest absent-manager semantics.
Pinned by the override tests (override shadows an accessor-ful store;
byte-identical arms unchanged) and the composition-level
TestBuild_ScheduleStoreOverrideWiresScheduleTool /
TestBuild_ScheduleStoreOverrideStartsScheduler.
@JAORMX
JAORMX merged commit 6addc98 into main Aug 6, 2026
15 checks passed
@JAORMX
JAORMX deleted the issue-257-schedule-store-driver branch August 6, 2026 08:31
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.

Scheduled tasks — Driver ScheduleStoreService (remote registry via driver protocol)

1 participant