"""The goalui bundle (moved verbatim from the pre-split web_stack_test.py; see test/harness.py for the shared machinery and the runner).""" from harness import * # noqa: F401,F403 — the shared wire helpers def run(ctx): """Plan 14 workstream B + plan 15 C1: the goal supervision surface. B1 — goal-run control parity (Retry supervision / Requeue-to-resume on the status head, the /tasks/ redirect, no notify-me toggle), B2 — the plan-review remarks queue, B4 — sessions.resume_notice on the task page's session rows + the plan-17 event log page, B5 — page order, effective rules and per-task capability badges, B6 — narrative footnote weights. C1 — the single-row block world: the goal's blocks ARE the run task's rows (answered from every surface through one path; no dual rows, no stragglers, at most one review-kind block per verdict path). C4 — the goal page batch: one muted head activity line, plan between attention and tasks, answered blocks behind an expander, footnote comments. C5 — the dashboard deep-link closure: goal pile cards link the goal page, every surface settles the single row, and no goal-side store exists to hold stragglers. """ auth, fake, fake_id, fake_token = ctx.auth, ctx.fake, ctx.fake_id, ctx.fake_token def run_task_of(goal_id): conn = db() try: return int(conn.execute( "select id from tasks where goal_id = ? and kind = 'goal_run'", (goal_id,)).fetchone()[0]) finally: conn.close() def wait_run(status, timeout=60, what="run status"): return wait_for(lambda: task_state(auth, run_task_of(goal))["status"] == status or False, timeout=timeout, what=what) def pile_questions(): return [b.get("question") for b in slot_public(auth, "/", "dashboard")["pinned"] if b.get("item_type") == "goal"] def plant_live_worker(goal_id, title="Goalui live worker"): """Goal 27 refinements — the parking guard: the goal agent parks only while its goal owns a task that could still fire a terminal transition. The scenes that script it to park plant a BLOCKED live worker first (wakeable, never dispatched).""" conn = db() conn.execute("insert into tasks (project_id, goal_id, kind, title," " status, priority, mode, creator, created_at)" " values (1, ?, 'task', ?, 'blocked', 5, 'implement'," " 'goal', strftime('%s','now'))", (goal_id, title)) conn.commit() conn.close() def open_session(task_id): """The task's newest session row (plan 16 D4: a parked round's row is closed 'parked' — still the record the CLI callbacks, the telemetry pushes and the page surfaces key on).""" conn = db() try: row = conn.execute( "select max(id) from sessions where task_id = ?", (task_id,)).fetchone() return int(row[0]) if row and row[0] else None finally: conn.close() print("== B1: the goal-run task page redirects to the goal ==") fake.goal_script = [("plan", "# Remarks plan\n\n## Steps\n\n1. First move")] act(auth, slot_public(auth, "/goals", "goals")["create"], { "project_id": "1", "title": "Goalui goal", "brief": "Drive the plan-14 goal surface end to end.", "branch_name": "goal/goalui"}) conn = db() goal = conn.execute("select id from goals where title = 'Goalui goal'" ).fetchone()[0] conn.close() act(auth, goal_state(goal)["start"], {}) wait_run("blocked", what="goalui goal agent parks on its plan") # plan review parks blocked run_task = run_task_of(goal) frames = directives("/tasks/%d" % run_task, auth) navigations = [d for d in frames if d.get("type") == "navigate"] check(any(d.get("uri") == "/goals/%d" % goal for d in navigations), "the goal-run task page redirects to /goals/ (navigate directive)") check(slot_public(auth, "/tasks/%d" % run_task, "task")["id"] == run_task, "the redirect still hydrates the task slot (sealed refresh + API readers)") status, page = http("GET", "/tasks/%d" % run_task, headers={ "X-Statum-Slot": "key=%s; as_at=%s" % (auth["key"], auth["as_at"])}, timeout=15) check(status == 200, "the compiled goal-run page serves") act(auth, slot_public(auth, "/tasks", "tasks")["create"], { "project_id": "1", "title": "Goalui worker", "priority": "4", "description": "A plain worker under no goal."}) conn = db() worker = conn.execute("select id from tasks where title = 'Goalui worker'" ).fetchone()[0] conn.close() check(not [d for d in directives("/tasks/%d" % worker, auth) if d.get("type") == "navigate"], "worker task pages render normally (no redirect)") state = goal_state(goal) check("toggle_notify" not in state and state.get("notify") is None, "no notify-me toggle on the goal (goals notify unconditionally)") goal_page = http_get_page(auth, "/goals/%d" % goal) check("Notify me" not in goal_page and "toggle-notify" not in goal_page, "the goal page template ships no notify control") check(state["branch_name"] == "goal/goalui" and state["base_branch"] == "main" and isinstance(state["push_branches"], list) and state["priority"] == 3 and len(state["started_display"]) > 0 and len(state["agent_saddle"]) > 0, "the status head carries the full field set (branch pair, chips list," " priority, timestamps, agent saddle)") check("Retry supervision" in goal_page and "Requeue to resume" in goal_page, "the status head ships the run-control parity buttons") check("status-corner" not in goal_page and "goal complete" not in goal_page and "badge-yeehaw" not in goal_page, "no yeehaw badge remains anywhere (the feature died with the entry stream)") check(goal_state(goal)["current_activity"] == "parked awaiting the plan review", "the head line reads 'parked awaiting the plan review' while one is open") goal_page = http_get_page(auth, "/goals/%d" % goal) # Goal 41 T6 ("actions surface"): a pending plan review LEADS the # acting column as its own card — before the status head, the # blocks and the (history-only) plan card. check(goal_page.index("Plan review") < goal_page.index('class="card goal-head') < goal_page.index("Goal agent blocks") < goal_page.index("

Plan

"), "a pending plan review leads the acting column (status, blocks, history after)") check("data-plan-review" in goal_page and "Approved plan & revisions" in goal_page, "an open review renders expanded beside the collapsed approved-plan expander") print("== B2: the plan-review remarks queue ==") check(goal_state(goal)["status"] == "plan_review" and goal_state(goal)["plan_pending_block"] is not None, "the goal sits in plan review with a pending block") goal_page = http_get_page(auth, "/goals/%d" % goal) review_at = goal_page.index("data-plan-review") check(review_at > 0, "the plan review region is marked for the remarks queue") check(goal_page.index('data-block-id="goal.plan_pending_block.id"') > 0, "the queue keys on the pending goal block id") body_at = goal_page.index('data-plan-body') remarks_at = goal_page.index("data-plan-remarks") check(body_at < remarks_at, "the remarks queue renders at the bottom of the plan body") for marker in ("data-plan-accept", "data-plan-toggle", "data-plan-submit"): check(marker in goal_page, "the remarks queue ships %s" % marker) # The queue ENGINE moved out of the inline page script into the # shared app.js (main.html's