Put work items in the state store, and bind the log to them (M1.1)
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m14s
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m14s
Development Plan M1.1, as discussed. - Schema v4: a work_items table (id, scope, title, status, outcome, position, data) and an agent row whose active_item points at one (NULL: idle). Canonical events and intents carry their work item, and events their actor. Older stores are refused with a clear message: there was no production data, so no migration (the mechanism stays). - The log is reached through a Transcript bound to one work item and one actor: store.transcript(item, actor) reads only that item and writes with both. The planner, executor, delegation and expert desk get one per call from the orchestrator instead of holding the store, so a component can neither read another task's events (the planner read every earlier task's, #78) nor write without attribution. store.all_events() is kept for readers that span items (evaluation capture, dumps). Intents are begun through the transcript or with work_item=, so each belongs to its item. - The orchestrator opens a work item on 'use', closes it with its outcome (completed or abandoned), and carries what the operator said while idle into the new item as copies with their origin, so a task sent before 'use' is still planned from (D1). control.py keeps its state machine through get_state()/transition(), now over the active work item, until M2.6 retires it. - nisse_dev.dump shows work items and each event's item and actor. Tests: test_work_items.py (scoping, attribution, intent ownership, restart, outcomes, carried messages, a second task never seeing the first); the suites updated for the per-call transcript. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
This commit is contained in:
1 parent
3cf4cefacd
commit
83804fe02a
40 files changed
+1026
-363
No files matched your search
@@ -21,7 +21,7 @@ from nisse_dev.state import StateStore
|
||||
store = StateStore(sys.argv[1])
|
||||
store.transition("EXECUTING", cause="test", project="demo", data={"milestone": 2})
|
||||
store.begin_intent("push_branch", {"branch": "milestone-2"}, cause="test")
|
||||
store.append_event(UserMessage(text="start milestone 2", source="m:1"))
|
||||
store.transcript("t", "operator").append(UserMessage(text="start milestone 2", source="m:1"))
|
||||
os._exit(1) # die without closing anything, as a power cut would
|
||||
"""
|
||||
|
||||
@@ -48,5 +48,5 @@ def test_state_survives_process_death(tmp_path: Path) -> None:
|
||||
[pending] = store.pending_intents()
|
||||
assert pending.payload == {"branch": "milestone-2"}
|
||||
|
||||
[stored] = store.read_events()
|
||||
[stored] = store.all_events()
|
||||
assert stored.event.text == "start milestone 2"
|
||||
@@ -45,11 +45,13 @@ def build(
|
||||
def test_delegate_completes_a_scoped_subtask(
|
||||
tmp_path: Path, passthrough: AnthropicPassthroughClient, live_model: str
|
||||
) -> None:
|
||||
delegation, repo, _store = build(
|
||||
delegation, repo, store = build(
|
||||
tmp_path, Caps(turns=12, wall_clock_s=300.0), passthrough, live_model
|
||||
)
|
||||
|
||||
result = delegation.run(brief=BRIEF, branch="live/delegation-1")
|
||||
result = delegation.run(
|
||||
store.transcript("t", "helper"), brief=BRIEF, branch="live/delegation-1"
|
||||
)
|
||||
|
||||
assert result.usable, f"delegation did not hand back: {result.status} {result.note}"
|
||||
assert (repo.root / "slugify.py").exists()
|
||||
@@ -75,11 +77,13 @@ def test_a_cap_breach_discards_the_work(
|
||||
) -> None:
|
||||
# One turn cannot finish the brief, so this exercises the abort path
|
||||
# against a real model rather than a scripted one.
|
||||
delegation, repo, _ = build(
|
||||
delegation, repo, store = build(
|
||||
tmp_path, Caps(turns=1, wall_clock_s=120.0), passthrough, live_model
|
||||
)
|
||||
|
||||
result = delegation.run(brief=BRIEF, branch="live/delegation-2")
|
||||
result = delegation.run(
|
||||
store.transcript("t", "helper"), brief=BRIEF, branch="live/delegation-2"
|
||||
)
|
||||
|
||||
assert not result.usable
|
||||
assert result.status == "capped"
|
||||
|
||||
@@ -26,7 +26,7 @@ def desk(tmp_path: Path, litellm: LiteLLMClient, live_model: str):
|
||||
store = StateStore(
|
||||
tmp_path / "state.db", oplog=OpLog("nisse-dev", io.StringIO())
|
||||
)
|
||||
return ExpertDesk(litellm, store, roles, budget=budget), store
|
||||
return ExpertDesk(litellm, roles, budget=budget), store
|
||||
|
||||
return make
|
||||
|
||||
@@ -35,8 +35,9 @@ def test_live_consult_parses_against_the_local_schema(desk) -> None:
|
||||
expert, store = desk()
|
||||
|
||||
answer = expert.ask(
|
||||
store.transcript("t", "expert"),
|
||||
"For a single-process agent storing a few thousand rows of task state, "
|
||||
"is SQLite sufficient, or is PostgreSQL warranted? Answer briefly."
|
||||
"is SQLite sufficient, or is PostgreSQL warranted? Answer briefly.",
|
||||
)
|
||||
|
||||
assert answer.confidence in {"high", "medium", "low"}
|
||||
@@ -48,7 +49,10 @@ def test_live_consult_parses_against_the_local_schema(desk) -> None:
|
||||
|
||||
|
||||
def test_live_budget_stops_a_circling_caller(desk) -> None:
|
||||
expert, _ = desk(budget=1)
|
||||
expert.ask("Name one advantage of WAL mode in SQLite. Be brief.")
|
||||
expert, store = desk(budget=1)
|
||||
expert.ask(
|
||||
store.transcript("t", "expert"),
|
||||
"Name one advantage of WAL mode in SQLite. Be brief.",
|
||||
)
|
||||
with pytest.raises(BudgetExhausted):
|
||||
expert.ask("And another?")
|
||||
expert.ask(store.transcript("t", "expert"), "And another?")
|
||||
@@ -72,10 +72,10 @@ def test_plan_approve_execute_produces_a_real_file(
|
||||
orchestrator = Orchestrator(
|
||||
store,
|
||||
transport,
|
||||
LLMPlanningAgent(client, store, roles),
|
||||
LLMPlanningAgent(client, roles),
|
||||
operators={"don"},
|
||||
roles=roles,
|
||||
executor=LLMExecutor(client, store, roles, workspace, max_turns=10),
|
||||
executor=LLMExecutor(client, roles, workspace, max_turns=10),
|
||||
)
|
||||
orchestrator.start()
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ pytestmark = pytest.mark.integration
|
||||
def store_with(tmp_path: Path, *events) -> StateStore:
|
||||
store = StateStore(tmp_path / "state.db", oplog=OpLog("nisse-dev", io.StringIO()))
|
||||
for event in events:
|
||||
store.append_event(event)
|
||||
store.transcript("t", "helper").append(event)
|
||||
return store
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ def test_passthrough_completes_a_plain_turn(
|
||||
tmp_path, UserMessage(text="Reply with exactly: pong", source="live")
|
||||
)
|
||||
result = passthrough.complete(
|
||||
store.read_events(), None, live_model, system="Be terse."
|
||||
store.transcript("t", "helper").read(), None, live_model, system="Be terse."
|
||||
)
|
||||
texts = [e.text for e in result if isinstance(e, AssistantText)]
|
||||
assert texts and "pong" in texts[0].lower()
|
||||
@@ -53,7 +53,7 @@ def test_passthrough_round_trips_a_tool_call(
|
||||
)
|
||||
client = passthrough
|
||||
produced = client.complete(
|
||||
store.read_events(),
|
||||
store.transcript("t", "helper").read(),
|
||||
EXECUTOR_TOOLS,
|
||||
live_model,
|
||||
system="Use a tool. Do not answer in prose.",
|
||||
@@ -64,11 +64,13 @@ def test_passthrough_round_trips_a_tool_call(
|
||||
# Feed the result back: the follow-up render must be accepted, which is
|
||||
# what proves tool_result placement is right for this vendor.
|
||||
for event in produced:
|
||||
store.append_event(event)
|
||||
store.append_event(
|
||||
store.transcript("t", "helper").append(event)
|
||||
store.transcript("t", "helper").append(
|
||||
ToolResult(call_id=calls[0].call_id, result="app.py\ntests/", success=True)
|
||||
)
|
||||
follow_up = client.complete(store.read_events(), EXECUTOR_TOOLS, live_model)
|
||||
follow_up = client.complete(
|
||||
store.transcript("t", "helper").read(), EXECUTOR_TOOLS, live_model
|
||||
)
|
||||
assert follow_up, "the vendor rejected or ignored the tool_result turn"
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ def test_live_planning_turn_returns_a_tool_action(
|
||||
model = live_model
|
||||
roles = RoleMap(executor=model, planner=model, helper=model, expert=model)
|
||||
store = StateStore(tmp_path / "state.db", oplog=OpLog("nisse-dev", io.StringIO()))
|
||||
store.append_event(
|
||||
store.transcript("t", "operator").append(
|
||||
UserMessage(
|
||||
text=(
|
||||
"Project 'hello-cli': a Python script that prints a greeting. "
|
||||
@@ -36,12 +36,12 @@ def test_live_planning_turn_returns_a_tool_action(
|
||||
source="live-test",
|
||||
)
|
||||
)
|
||||
agent = LLMPlanningAgent(litellm, store, roles)
|
||||
agent = LLMPlanningAgent(litellm, roles)
|
||||
|
||||
action = agent.plan("arch", "hello-cli")
|
||||
action = agent.plan(store.transcript("t", "planner"), "arch", "hello-cli")
|
||||
|
||||
assert isinstance(action, SubmitPlan | AskHuman)
|
||||
text = action.content if isinstance(action, SubmitPlan) else action.question
|
||||
assert text.strip(), "tool call carried empty content"
|
||||
# The turn must be durable regardless of what the model said (L8/L7).
|
||||
assert len(store.read_events()) > 1
|
||||
assert len(store.transcript("t", "planner").read()) > 1
|
||||
Reference in new issue
Block a user