Interruption Fact Logging & Schedule Replanning #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implement the interruption logging and replanning subsystem (
POST /v1/replansandlife replan --input -), recording explicit user-reported interruption events as append-only timeline facts in SQLitelife_events(evidence_class: "user_report"), calculating remaining working capacity from the interruption timestamp, evaluating impact on scheduled tasks, and generating an updated schedule proposal in SQLite without modifying any calendar events in Radicale CalDAV.Background & Technical Rationale
Real-world execution rarely proceeds without unexpected events. When an interruption occurs (e.g., an urgent production incident, an impromptu meeting, or an urgent family obligation), systems typically fail in one of two ways:
Life resolves this via strict structural separation between timeline facts and remedial proposals:
life_eventswithevidence_class: "user_report".ended_at: null). The engine records the open interruption fact, treats remaining capacity as uncertain, disclosesunknown_estimateand capacity uncertainty in warnings, and refuses to schedule tight work blocks until the end time is clarified or bounded.life proposal apply(Issue #027) before any calendar changes take effect.Exact Technical References & Specifications
1. Workflows Specification (
docs/technical/workflows.md)Section:
## Planning and interruption(lines 24–28):Section:
## Personal policy defaults(line 50):2. Domain Entities Specification (
docs/technical/domain-model.md)Section:
## Entities(lines 7–18):Section:
## Time and work outcomes(lines 39–42):3. CLI and API Route & Payloads (
docs/technical/cli-api.md)Section:
## Command-to-route table(line 44):Section:
## Command payloads and results(line 91):4. Database Schema & Triggers (
docs/technical/timeline-consistency.md)Section:
## Illustrative schema(lines 37–75):5. Verification Scenario W08 (
docs/technical/verification.md)Section:
## Workflow scenarios(line 22):What to build
1. Interruption Event Recorder (
src/domain/timeline/interruption.rs)item_ids: Array of affected scheduled work block IDs or task IDs.occurred_at: Optional tagged instant or ISO-8601 timestamp marking the start of the interruption (left null if omitted; do not invent an actual time, perdocs/technical/timeline-consistency.md:119;recorded_atcaptures reception time).ended_at: Optional tagged instant or ISO-8601 timestamp marking the end of the interruption. May benullif the interruption is ongoing or the end is unknown.reason: Optional human-supplied explanation string (e.g., "Urgent production outage").event_id: Unique prefixed ID (evt_int_...).dedupe_key: Derived from operation ID and event index (op_replan_...:fact:0).schema_version:1.kind:"interruption_logged".evidence_class:"user_report".recorded_at: Current UTC timestamp.occurred_at: The suppliedoccurred_attimestamp.actor:"user".source:"cli_api".after_json: Serialized JSON payload containing{affected_item_ids, occurred_at, ended_at, reason}.provenance_json: Metadata capturing client request ID and user reporting channel.life_events. This insert occurs inside a dedicated transaction that is committed regardless of whether subsequent replan calculation succeeds.2. Remaining Capacity Evaluator (
src/domain/policy/replan_capacity.rs)ended_atis provided, the anchor is\max(\text{ended\_at}, \text{current\_time}).ended_atisnull, the anchor is\text{current\_time}. Calculate remaining time until the end of the configured working window, but mark capacity confidence as uncertain.ended_atis unknown, generate warningunknown_estimateandincomplete_calendarto explicitly disclose that capacity cannot be guaranteed.3. Schedule Re-Sequencer & Proposal Builder (
src/domain/replan.rs)NEEDS-ACTION) withplanned_start: null.step_id,action(update_event,cancel_event,update_task),item_id,collection_id,baseline_etag, andpayload.docs/technical/cli-api.md:104).proposalstable withstate: "pending".4. Axum Route & CLI Interface (
src/api/replans.rs,src/cli/replan.rs)POST /v1/replans:status: "partial", data containinginterruption_event_id, anderrorexplaining proposal generation failure.life replan --input - [--json]Acceptance Criteria
life replaninserts a row intolife_eventswithkind: "interruption_logged"andevidence_class: "user_report"(verifying Scenario W08).ended_at: nullrecords the event withended_atas null and returns anunknown_estimatewarning regarding capacity uncertainty.proposal_id, state"pending", and canonical SHA-256 digest covering ordered steps, baseline ETags, and policy exceptions (docs/technical/cli-api.md:104).occurred_atremains null in the recorded interruption event without inventing an actual time (docs/technical/timeline-consistency.md:119).Notes
journal::record_fact_operation(operations row +life_eventsappend in one transaction, with fingerprint replay detection) — available for #28/#29.status: partial(exit 6).plans::generatewith the anchor's remaining day and the sameceil(remaining × 40%)reserve; the prior proposal row is asserted byte-identical.REPORTrequest assertion and by per-table deltas.Blocked by
Issue #026: Interruption Fact Logging & Schedule Replanningto Interruption Fact Logging & Schedule Replanning