Repository navigation
fix(memory): keep 0.7.0 pre-release member tasks and schedules working - #16269
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check before merge: the next snapshot permanently drops the pre-release task rows from What this change shipsInventory (8 items) — 8 justifiedIntent: an operator upgrading from 0.7.0-insider.1–.5 keeps their task runner and their crew members' schedules working without editing files. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 2632d56 Description read[DESCRIPTION-READ] 3712a3c97e5cdb07f49db87d5985de45ea838c4e64e8722cb7d6fdbf6982e49d That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that a [DESIGN-REVIEWED] 2632d56 Description read[DESCRIPTION-READ] be32d8825e1ab922fb7e8542bf88b74762a123ab1c83ff0a2567149d929ad942 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
575b1b0 to
e6af73f
Compare
|
|
e6af73f to
2c47dd0
Compare
|
|
|
|
2c47dd0 to
3d2d71e
Compare
|
|
|
|
3d2d71e to
805a2d3
Compare
|
805a2d3 to
8db1259
Compare
…es working Leave pre-release private task references out of the restored registry, and capture pre-identity member schedules once at start, keeping any named agent and reconciling the old cron session record first.
8db1259 to
2632d56
Compare
buluoray
left a comment
There was a problem hiding this comment.
LGTM. I checked this at head 2632d564f5.
Attribution never guesses a member. attribute_legacy_member (execution_context.py:934-965) requires the store's owner_member_id to be exactly one configured member, the record to name that member's alias or id, and that member to still resolve to the same store. Each failed step raises its own LegacyMemberAttributionRefused subclass, so a pre-identity schedule is never routed into another member's private store or into Global. resolve_cron_memory (cron_service/identity.py:121-125) refuses any legacy member schedule that has not been captured yet instead of deriving one at dispatch, so the dispatch path fails closed too. The session write-back CAS checks memory_store, agent, persistent mode and app before touching a cron:<id> record.
Idempotent and lock-consistent. Already-captured records are skipped, and a retry after a session write that landed but a crons.json write that did not falls into the current == execution branch. The migration runs under cron_store_lock, the same .crons.lock CronService uses, before the scheduler arms.
Mutation checks. Removing each of these reddens a named test: the named not in (alias, owner_member_id) check (test_legacy_member_schedule_naming_another_member_is_refused and 4 others), the store-binding check (...[rebound-LegacyOwnerBoundElsewhere]), the skip-if-captured check (test_pre_identity_member_schedules_are_captured_once), the uncaptured-dispatch refusal (test_an_uncaptured_legacy_member_schedule_never_dispatches), each of the four CAS conditions (test_a_session_the_capture_cannot_vouch_for_is_left_as_it_is[another-store|another-member|app-owned|restricted]), and the exact legacy task-row shape (test_any_other_private_payload_row_still_refuses_the_registry[row3]). The four related test files pass (268) at head; the full suite is left to CI, which is green.
Non-blocking follow-ups
- The title says member tasks keep working, but legacy
private_payloadtask rows are dropped from recovery and have to be recreated (taskrunner.md says so). Worth rewording the title/commit so main's history matches the behaviour. - In
migrate_legacy_member_schedules, onlylegacy_member_cron_executionand the reconcile call have per-recordtry. An unexpected exception elsewhere for one record makes the outerexceptskip capture for the whole batch. It is fail-closed (dispatch refuses and asks for a restart), but wrapping each record would stop one bad entry from holding back the rest. - The migration runs before
apply_pending_member_restores, so a member restored by a pending restore gets its schedules captured only on the second start. Fail-closed; worth one line in the spec.
Problem / Motivation
Goal: An install upgraded from 0.7.0-insider.1 to .5 keeps its tasks and its crew members' schedules working without the operator having to edit any files.
Two kinds of records written by those pre-release builds stop working on today's build:
runs.jsonholds a{"task_id": ..., "private_payload": true}row. Today's reader refuses the whole registry over that row. TaskRunner restores no runs and fences every snapshot write, and this repeats on every restart, so the operator has no way out.execution_context. Every fire raisesmemory_unavailablebefore dispatch, so the job fails forever and the dashboard's session registry refuses the job's member scope.Why it matters
Anyone who ran a 0.7.0 pre-release with crew members hits this on upgrade. The task runner stays fenced, so no task state persists across restarts. Member schedules never run again, and nothing tells the operator why or what fixes it.
Not a goal
memory_unavailablerefusal, and its error names the repair.What changed (motivation → approach → change)
Task registry. The registry is refused only because of rows this build cannot run.
workflow_memory.read_task_snapshotnow picks out rows of exactly the pre-release shape.TaskRunner._load_runsleaves them out, restores the other runs, and logs one warning naming their task ids. Writes are not fenced, so the next snapshot rewrites the registry without those rows. The hidden payload sidecar is not touched. Any otherprivate_payloadrow still refuses restore, as before.Member schedules. A pre-identity schedule can be attributed once the store upgrade has given its store an owner. Attributing it again on every fire would give readers a record they could disagree on. So
cron_service/identity.migrate_legacy_member_schedulescaptures each such schedule once. It runs from the gateway's memory worker (slack/gateway_runtime/memory_lifecycle.py), afterrepair_legacy_member_storesand before the scheduler arms. The capture is a compare-and-set undercron_store_lockthat writesexecution_context, the permanentmember_id, and the template. A namedagent_idis kept and becomes the captured template, as for a schedule created today, since 0.7.0-insider.5 already ran that agent. Before each schedule is captured, thecron:<id>session record the old build left is brought into agreement by a compare-and-set, because dispatch refuses a record that disagrees. If that step fails, the schedule stays uncaptured and the next start retries it. Attribution shares one helper,attribute_legacy_memberinsrc/kiro_crew/execution_context.py, with the existing chat backfill, and nothing is guessed. Dispatch never derives an uncaptured schedule.resolve_cron_memoryraises a typedLegacyScheduleRefused, amemory_unavailableerror that names the repair and is recorded as an ordinary failed run.Backwards compatibility
Compatible: every record main accepts is read exactly as before. Only rows and records that main already refuses (the pre-release task row, the uncaptured member schedule) are handled differently.
Reader: src/kiro_crew/taskrunner.py:TaskRunner._load_runs -- release -- restores the remaining rows with writes unfenced; test_legacy_private_reference_is_left_out_and_writes_are_not_fenced
Reader: src/kiro_crew/workflow_memory.py:read_task_snapshot -- release -- any other private_payload row refuses as before; test_any_other_private_payload_row_still_refuses_the_registry
Reader: src/kiro_crew/cron_service/store.py:_job_from_record -- cron -- reads the captured record like any new schedule; test_pre_identity_member_schedules_are_captured_once
Reader: src/kiro_crew/dashboard/handlers/_shared.py:_cron_execution_from_registry -- crew page -- resolves the captured member; test_pre_identity_member_schedules_are_captured_once
Reader: GET /api/crons and cron_list (member_id, agent_id) -- crew page -- report the permanent id and the captured template, as for a schedule created today
Tests
test/test_workflows_startup_recovery.py: a pre-release row is left out, the other runs restore, writes are not fenced, the warning names the task id, and a restart with the same row is fine. Any otherprivate_payloadshape still refuses the registry.test/test_execution_context.py: attribution by alias or by id. Each refusal names its repair: another member, an unattributed store, a deleted member, a lost declaration, a bad slug, a string version. V1 stores are left alone. The capture runs once, is idempotent, rewritesmember_id, keeps a namedagent_idas the captured template, reconciles the oldcron:<id>session record before capture and retries after a failed write, shares one attribution helper with the chat backfill, is readable by the dashboard registry, and never raises.test/test_cron_gateway_integration.py: a refused pre-identity schedule is an ordinary failed run whose error names the repair. Other refusals before dispatch still raise. An upgraded member schedule naming an agent fires twice through the real callback.test/test_workflows_private_diagnostics.py: passes the now-requiredlegacy_references.test/test_member_memory_upgrade.py: the memory worker captures schedules after the store upgrade and before restores.Manual verification
N/A: the unit tests build the 0.7.0-insider record shapes directly (checked against the
v0.7.0-insider.1and.5tags) and drive the real TaskRunner restore, the real capture over acrons.json, and the gateway cron callback.Related Issues
Follow-up to #12103, which upgraded pre-identity member stores.
Pattern harvest
Not generalizable: these are one-time readers for the record shapes of one pre-release range, and each one is keyed on that exact shape.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)learn-cron-dashboard,taskrunnerandmemory-skills-hooksspecs