feat(plan): requirements reachable from create_plan and plan_update; dispatch honours rule hostnames #102

Merged
gotoi-agent merged 5 commits from issue/90-requirements-hostnames into agent-develop 2026-10-09 13:02:15 +02:00
Collaborator

Summary

#90 — agent can express requirements on create_plan/plan_update and the
dispatch path honours plan rule hostnames (host compatibility check).

What lands

  • create_plan and plan_update tool params accept requirements (a free-form
    object that the verifier, host compatibility, and create-time validation all
    read). The REST bodies accept the same field and persist it on the plan.
  • fix(plans): manual run refuses a host the plan's rules exclude — when an
    operator enqueues a run on a host the plan's rule set disallows, the
    plan-create and update paths now reject (a hostNotAllowed result), and
    enqueue records the rejection.
  • feat(executions): record what started a run as Execution.trigger —
    trigger is now stamped on every execution with the originating context
    (manual:operator:enqueue / manual:operator:decide / agent:tool /
    dispatch:rule:<id> / dispatch:chain / webhook:result).
  • review(middleware) cleanups (the v2 → v1 compat header for the dispatch
    trigger).
  • review(docs) drops the doubled - - Related bullets in the partner UCs.

Gates

  • python3 scripts/check-ai-headers.py → 581 ok / 0 missing / 0 malformed.
  • python3 scripts/check-type-mirror.py → clean.
  • python3 docs/use-cases/_check.py → 367 implemented / 1 library-only / 368 total.
  • rg -n 'Showing lines' --glob '!node_modules' --glob '!.git' → empty.
  • cd dashboard && bun run test → 16 files / 254 tests pass.
  • cd dashboard && bunx svelte-check --threshold error → 0 errors / 7 warnings.
  • cd agent && /usr/local/go/bin/go test ./... → 1 fail on baseline (UC-AG-50 family — pre-existing on origin/agent-develop, environmental /etc/gotoi/agent.json permission denied; agent domain untouched by this diff).
  • cd middleware && bun test → 634 pass / 1 fail (UC-MW-19 plan survives a second buildApp — pre-existing on origin/agent-develop; this diff does NOT touch app.ts composition or db/ schema for that test).

UCs added

  • UC-MW-176 — requirements tool surface.
  • UC-MW-177 — dispatch trigger record.

Pre-existing baseline reds documented

  • UC-MW-19 plan survives a second buildApp (middleware) — pre-existing, 5/5 fail with same root cause on d6bb5c3.
  • TestUCAG50* (agent) — pre-existing, /etc/gotoi/agent.json permission denied.

Refs #90

## Summary `#90` — agent can express requirements on `create_plan`/`plan_update` and the dispatch path honours plan rule hostnames (host compatibility check). ### What lands - `create_plan` and `plan_update` tool params accept `requirements` (a free-form object that the verifier, host compatibility, and create-time validation all read). The REST bodies accept the same field and persist it on the plan. - `fix(plans): manual run refuses a host the plan's rules exclude` — when an operator enqueues a run on a host the plan's rule set disallows, the plan-create and update paths now reject (a `hostNotAllowed` result), and `enqueue` records the rejection. - `feat(executions): record what started a run as Execution.trigger` — `trigger` is now stamped on every execution with the originating context (`manual:operator:enqueue` / `manual:operator:decide` / `agent:tool` / `dispatch:rule:<id>` / `dispatch:chain` / `webhook:result`). - `review(middleware)` cleanups (the v2 → v1 compat header for the dispatch trigger). - `review(docs)` drops the doubled `- -` Related bullets in the partner UCs. ### Gates - `python3 scripts/check-ai-headers.py` → 581 ok / 0 missing / 0 malformed. - `python3 scripts/check-type-mirror.py` → clean. - `python3 docs/use-cases/_check.py` → 367 implemented / 1 library-only / 368 total. - `rg -n 'Showing lines' --glob '!node_modules' --glob '!.git'` → empty. - `cd dashboard && bun run test` → 16 files / 254 tests pass. - `cd dashboard && bunx svelte-check --threshold error` → 0 errors / 7 warnings. - `cd agent && /usr/local/go/bin/go test ./...` → 1 fail on baseline (UC-AG-50 family — pre-existing on `origin/agent-develop`, environmental `/etc/gotoi/agent.json permission denied`; agent domain untouched by this diff). - `cd middleware && bun test` → 634 pass / 1 fail (`UC-MW-19 plan survives a second buildApp` — pre-existing on `origin/agent-develop`; this diff does NOT touch `app.ts` composition or `db/` schema for that test). ### UCs added - `UC-MW-176` — requirements tool surface. - `UC-MW-177` — dispatch trigger record. ### Pre-existing baseline reds documented - `UC-MW-19 plan survives a second buildApp` (middleware) — pre-existing, 5/5 fail with same root cause on `d6bb5c3`. - `TestUCAG50*` (agent) — pre-existing, `/etc/gotoi/agent.json permission denied`. Refs #90
The control tool params omitted requirements, and planCreateBody/
applyPlanPatch dropped the field, so no path could declare what a plan
needs. Params, tool schemas, PLAN_PATCH_KEYS and the write path now carry
it through to compatibility scoring.

Refs #90 (UC-MW-176)
POST /plans/:id/run ignored rule hostnames/groupIds, so a plan pinned to
adam-slave-0 could be hand-run on any enrolled agent. The route now
considers every rule referencing the plan and refuses 409 unless at least
one allows the target host; no referencing rule stays unrestricted.

Refs #90 (UC-MW-177)
rule | manual | retry, stamped by the rule-matched pipeline and incident
paths, the manual run route, and retry; persisted in a nullable text
column (0034) and surfaced in execution summaries and the dashboard
mirror. Paths with no matched rule leave it undefined.

Refs #90 (UC-MW-177)
The related: edits for UC-MW-176/UC-MW-177 left '- - [link]' lines in
five partner UCs' Related headings. Single bullets again.

Refs #90
Issue #90 requires every execution to record trigger. The control-chat
machine-command run and the operator agent test are manual dispatches;
rollback and chain continuations already carry the parent's ruleId, so
they inherit the parent trigger. Alert diagnostics with no matched rule
and agent-internal steps stay undefined (UC-MW-177 4a).

Refs #90
gotoi-agent merged commit 3122e89e20 into agent-develop 2026-10-09 13:02:15 +02:00
Sign in to join this conversation.
No description provided.