Repository navigation
fix(schedule): the Schedule tool on every schedule-capable session (ADR 0076) - #314
Merged
Merged
Conversation
Co-Authored-By: mecatl <[email protected]>
…shaped manager (ADR 0076) The validated create/read/update/fire seam lived on *server.Service as methods reaching into s.cfg. It is in fact STORE-SHAPED — every input it needs (the ScheduleStore type-asserted off the session store, a now-func, the cadence floor, the event-log, diagnostics) is available before buildEngine. Move it verbatim onto a standalone scheduleManager (new schedule_manager.go), constructed from the store + now-func alone, with the scheduler + model inventory as late-bound atomic fields. *Service keeps thin delegating wrappers so the RPC surface (grpc_schedule.go, REST /v1/schedules, the mecatui /schedule overlay) is byte-identical. Composition (app.Build) constructs the manager from the store BEFORE buildEngine and hands it to server.Config.ScheduleManager; the Service adopts it and late-binds its models pointer so SetModels keeps working with no second copy. assets.scheduleManagerFactory is still bound LATE (after NewService) — the eager binding is task 02. This is a pure refactor: zero behaviour change. Pins AC1.1/AC1.3/AC1.4 of the schedule-shared-catalog plan: - TestScheduleSharedCatalog_Scenario1_ManagerIsStoreShaped (AC1.1) - TestScheduleSharedCatalog_Scenario1_ServiceDelegates (AC1.3) - TestScheduleSharedCatalog_Scenario1_FireNowStatesPreserved (AC1.4) All existing schedule tests stay green (schedule_test.go, schedule_e2e_test.go, schedule_validation_test.go, schedule_wire_survives_test.go, internal/app scheduletool tests, TestPerSessionCatalogMatchesSharedCatalog). Co-Authored-By: mecatl <[email protected]>
…ule/ScheduleQuery (ADR 0076, task 02) buildEngine now constructs the store-shaped schedule manager from the session store BEFORE any catalog assembly and buildCatalog binds assets.scheduleManagerFactory onto the assets before the build-time assembleCatalog pass — so registerScheduleTool fires on the SHARED pass and the build-time shared catalog gains Schedule (mutating) + ScheduleQuery (read-only), exactly like the six memory tools (ADR 0073 decision 1). The late bind (assets.scheduleManagerFactory = svc.ScheduleManager after server.NewService) and the stale "chicken-and-egg / legitimately has no Schedule tool" comments are deleted: sessionNeedsPerFactory has no schedule arm, so the default-profile shared-engine fast path (the plain mecatui launch) was schedule-less. Build hands the SAME manager buildEngine returns to server.NewService via server.Config.ScheduleManager (one manager, one truth). The manager crosses composition as the concrete *scheduleManager (the new server.ScheduleManagerImpl alias) with an explicit nil check in the factory — a typed-nil interface would defeat registerScheduleTool's mgr == nil honest-absence gate and nil-panic NewService's setModelsPointer adoption (caught by the full suite). A store with no ScheduleStore keeps the tool honestly absent from BOTH catalogs (never a stub). TestPerSessionCatalogMatchesSharedCatalog now covers the schedule pair with NO carve-out: the pair joins requiredFamilyTools, fullyLoadedCfg backs a ScheduleStore (StoreDir), and the drift guard passes the same eager factory buildEngine performs. registerScheduleTool and scheduleManagerPresent are unchanged (they already no-op on a nil factory/manager). Also adds Config.MockProvider (test-only): a scripted provider seam through a full app.Build — UseMock scripts one fixed text turn and can never emit a tool call, which the AC2.1 pin needs. verify: - AC2.1: TestScheduleSharedCatalog_Scenario2_SharedCatalogHasScheduleTools (store-backed Build; scripted Schedule + ScheduleQuery calls through a default-profile shared-engine session; oracle = the run's own EvToolResult — an unregistered tool comes back "unknown tool"; watched red before the fix and red again with the eager bind planted out) - AC2.2: TestScheduleTool_RegisteredOnlyWhenStoreBacked (green) - AC2.3: TestPerSessionCatalogMatchesSharedCatalog (green, schedule pair in requiredFamilyTools, no carve-out) Co-Authored-By: mecatl <[email protected]>
… 0070/0075, task 03) The shared engine's Deps never got applySchedulePosture — today applied only in the per-session factory (sessionEngineFactory) — so a default-profile, zero-selector session (the shared-engine fast path a plain mecatui launch takes) carried the Schedule tool in its catalog (task 02) but was never TOLD the tool exists (the ADR-0070 affordance gate). buildEngine now applies applySchedulePosture to the shared engine's PromptConfig under the SAME scheduleManagerPresent(assets) gate the factory uses, mirroring the note's registration exactly (a store with no ScheduleStore withholds it). Four Scenario-3 pins prove the end-to-end over a store-backed Build (launch-root workspace → the shared-engine fast path): - AC3.1: TestScheduleSharedCatalog_Scenario3_DefaultSessionHasTool — the shared engine's catalog resolves Schedule + ScheduleQuery (scripted dispatch executes both, no unknown-tool error). - AC3.2: TestScheduleSharedCatalog_Scenario3_SystemPromptCarriesScheduleNote — the shared engine's system prompt carries schedulePostureNote on the Role/StablePrefix layer (asserted against req.System.StablePrefix, not the combined Render); watched RED before the fix (launch-root session → shared engine), GREEN after; a store-less shared engine withholds it. - AC3.3: TestScheduleSharedCatalog_Scenario3_OriginAndDeliveryWired — a schedule created from a shared-engine session stamps OriginSessionID (OriginBinder live), and the production fire path (scheduler.FireNow → makeFireFunc → fireClaimed → deliverFireResult) enqueues the fire's fenced result into the FileDeliveryQueue the shared engine's Step 2a drain records into the origin chat (ADR 0075). - AC3.4: TestScheduleSharedCatalog_Scenario3_RehydratedSessionKeepsTool — a default-profile session persisted then reloaded (a second Build over the SAME store, the restart path) still resolves the Schedule tool on the restored shared engine. The tests create sessions on the LAUNCH-ROOT workspace so sessionNeedsPerFactory is false (the shared-engine fast path); an early draft passed a t.TempDir() workspace and silently exercised the per-session factory, masking the missing shared-engine wiring — caught by watching AC3.2 fail against the launch-root session. Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes the reported bug: in-chat scheduling was unreachable from the default mecatui session. "Schedule a check for new issues in 5 minutes" had no
Scheduletool to call and no prompt note mentioning one — despite the scheduler ticking and the store backing aScheduleStore.Root cause
ADR 0073 decision 1 registers the
Scheduletool "for every session that has a backingScheduleStore, exactly like the six memory tools." The implementation broke that for the shared-engine fast path (a default-profile, zero-selector session — what a plainmecatuilaunch creates):buildEngine→buildCatalog→assembleCatalog, beforeserver.NewServiceexists.port.ScheduleManagerthe tool drives was only late-bound onto the catalog assets afterNewService(the "chicken-and-egg").sessionNeedsPerFactoryhas no schedule arm, andneedsRehydrationrestores a restarted default session onto the shared engine.Root cause was a shape error: schedule capability was treated as Service-shaped (resolvable only after
NewService) when it is store-shaped — every construction input is available beforebuildEngine.The fix (ADR 0076)
scheduleManager(internal/adapter/server/schedule_manager.go): the nineport.ScheduleManagermethods + the validated create-seam moved verbatim off*Service. Constructed from the store + now-func beforebuildEngine; the scheduler + model-inventory are late-set atomic fields.*Servicedelegates — the RPC surface is byte-identical.assets.scheduleManagerFactoryis bound beforebuildEngine, soregisterScheduleToolfires on the build-time pass and the shared catalog gainsSchedule+ScheduleQuery— the same conditional-registration shape as the memory tools. The late-bind + stale comment are deleted.applySchedulePostureapplied to the shared engine under the same gate, so the model is told the tool exists.Every schedule-capable session — shared engine or per-session, on create and on restart-rehydration — now carries the tool. mecated / mecatui / mecak8s (all compose
app.Build) inherit the fix with no flag.Plan + acceptance
docs/acceptance/schedule-shared-catalog.md(landed) — 3 scenarios, 11 ACs, allverify:proofs green undertask ac-trace-strict. New ADR-0076 records the "store-shaped, not Service-shaped" decision + the rejected converge-on-per-session-factory alternative.Panel review
Three-axis panel (Spec / Standards / Domain): 0 ship-blockers. Spec: every AC implemented, no missing/wrong. Standards: no hard violations (layering, diagnostics, ONE-registration-path, typed-nil discipline all hold). Domain: one Medium (architect) — the manager's
now-func and the Service'scfg.Noware independent copies that could diverge if composition ever threads a clock; latent today (no clock is threaded — both default totime.Now), recorded as a judgement call for a futureapp.Config.Nowseam rather than a ship-blocker. Security/reuse/duplication: clean.Gates
task lint✅ ·task test(both modules,-race, engine-standalone) ✅ ·task docs(matlatl strict) ✅ ·task api:check✅ ·task ac-trace-strict✅ ·go run ./cmd/mecademo✅