Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions loopx/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
from typing import Any

from .control_plane.runtime.time import now_local_iso
from .control_plane.todos.handoff_mode import (
HANDOFF_MODE_LEGACY,
goal_handoff_mode,
)
from .control_plane.todos.active_state_editing import (
TODO_SECTION_HEADINGS,
insertion_anchor,
section_bounds,
)
from .control_plane.todos.next_action_runtime import bind_next_action_to_todo
from .control_plane.todos.handoff_mode import (
HANDOFF_MODE_LEGACY,
goal_handoff_mode,
)
from .execution_profile import (
build_execution_profile,
compact_execution_profile,
Expand Down Expand Up @@ -376,14 +377,15 @@ def apply_onboarding_todos_to_state(
else None
)
if action:
add_todo_to_lines(
added = add_todo_to_lines(
lines,
role="agent",
text=action["text"],
task_class=action["task_class"],
action_kind=action["action_kind"],
updated_at=updated_at,
)
bind_next_action_to_todo(lines, todo_id=str(added["todo_id"]))
return "\n".join(lines) + "\n"
lines = text.splitlines()
if accept_onboarding_agent_todos:
Expand Down
1 change: 1 addition & 0 deletions loopx/control_plane/effect_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"effect_runtime_handlers.ts",
"effect_runtime_io.ts",
"effect_runtime_server.ts",
"todos/next_action.ts",
"turn_driver/turn_journal.ts",
"turn_driver/turn_journal_effects.ts",
"turn_transaction_contract.json",
Expand Down
2 changes: 2 additions & 0 deletions loopx/control_plane/effect_runtime_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
type TurnJournalInspectionRequest,
} from "./turn_driver/turn_journal.ts";
import { commitTurnJournal } from "./turn_driver/turn_journal_effects.ts";
import { transitionTodoNextAction } from "./todos/next_action.ts";

type EffectRuntimeHandler = (params: JsonObject) => unknown | Promise<unknown>;

Expand Down Expand Up @@ -261,6 +262,7 @@ export function createEffectRuntimeHandlers(
(params) => interpretTurnJournal(turnJournalInspectionRequest(params)),
],
["turn_journal.write", commitTurnJournal],
["todo.next_action.transition", transitionTodoNextAction],
[
"effect.program_from_ordered_steps",
(params) => effectProgramFromOrderedSteps(
Expand Down
43 changes: 43 additions & 0 deletions loopx/control_plane/todos/line_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,49 @@ def link_generated_successor_todo_ids(
return metadata_updated


def link_superseding_todo_id(
lines: list[str],
*,
update_result: dict[str, Any],
role: str | None,
successor_todo_ids: list[str],
) -> bool:
"""Persist supersede lineage after generated successors are materialized."""

if not successor_todo_ids:
return False
block_match = find_todo_block(
lines,
todo_id=str(update_result.get("todo_id") or ""),
role=role,
)
if not block_match:
return False
_resolved_role, _section, _start, _end, block = block_match
merged_successor_ids = merge_todo_id_lists(
update_result.get("successor_todo_ids"),
successor_todo_ids,
)
metadata_updated = upsert_todo_metadata(
lines,
block,
metadata_line_for_todo_block(
block,
{
"superseded_by": successor_todo_ids[0],
"successor_todo_ids": merged_successor_ids,
},
),
)
update_result["metadata_updated"] = bool(
update_result.get("metadata_updated") or metadata_updated
)
update_result["superseded_by"] = successor_todo_ids[0]
update_result["successor_todo_ids"] = merged_successor_ids
update_result["changed"] = True
return metadata_updated


def apply_todo_update_to_lines(
lines: list[str],
*,
Expand Down
Loading