Skip to content

Add maintain commands for deployed-app items - #62

Merged
raghubetina merged 5 commits into
mainfrom
maintain-command
Nov 24, 2026
Merged

raghubetina merged 5 commits into
mainfrom
maintain-command

Conversation

@raghubetina

@raghubetina raghubetina commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the firstdraft maintain group for the maintenance service (firstdraft/firstdraft#1290, #1296), and the
2026-11-21 report pieces for it. Draft until the service that files GitHub issues is deployed and the live test of
issue filing passes.

  • firstdraft maintain [--environment NAME] [--page N] reads the account (GET /v1/account), then one page of open
    items for the Project in .firstdraft/state.json (GET .../environments/:name/items?page=N). --environment
    defaults to production. Each item carries issue_url, the GitHub issue First Draft files and keeps current for
    it, or null, and resolution_cause.
  • firstdraft maintain show ID [--environment NAME] reads one item with evidence and done_when.
  • firstdraft maintain resolve ID --reason REASON --cause CAUSE [--detail TEXT] [--environment NAME] posts
    {reason, cause, detail?}. A reason other than pull_request, host_change, not_a_bug, duplicate, or
    stopped_occurring, or a cause other than generated_code, later_code, configuration_or_host, data,
    dependency, not_a_bug, or unknown, is invalid_arguments (exit 2) before any request.

All three accept --staging, use the pinned origin, and print the validated response on stdout. They run from the
generated application's root, where they read the Project's state archived at .firstdraft/design as the report
commands do, or from the Project's directory. Validation is
exact-key, like compilation cancel: the Project ID, Environment name, and item ID must match the request, index
items must be open with no reason or cause, and a resolution must come back resolved with the sent reason and cause.
The CLI prints a fresh copy, so evidence.untrusted and evidence.note reach the agent unchanged. The service files
issues itself through the GitHub App, so the CLI has no issue command.

The commands run through the same service session as the other network commands, so they send FirstDraft-Client,
check FirstDraft-API-Contract, and stop with rate_limited, update_required, or api_contract_unsupported like
the rest.

Reports during maintenance (second commit)

From B7 of the 2026-11-21 install and collection decision:

  • The resolution's cause, above.
  • report failure --kind deployed_error --item <item-id> sends maintenance_item_id and refuses --message,
    because an item's evidence can hold end users' text. Another kind with --item is invalid_arguments.
  • The fixed sentence: only when the account answers {"reports": "on"}, firstdraft maintain writes
    MAINTAIN_REPORTS_ON_LINE from src/agent-sentences.js on standard error, after the items. Standard error keeps
    the JSON on stdout parseable; the update line already goes there for JSON commands. As with start, the agent of a
    person who said no hears nothing about reports. When the account read fails, the index reads no items and ends with
    account_unavailable or invalid_server_response.

Third commit (owner direction, 2026-11-24)

  • unknown joins the cause list, for an agent that looked and still cannot tell; the cause stays required.
  • The maintain commands find the Project with readPinnedProject, so they also run from an adopted application's
    root. The issue text in firstdraft/firstdraft#1349 tells the reader to run firstdraft maintain show <id> in the
    app's folder, which needs this.

Choices the decision note leaves open, for review: a dedicated deployed_error kind rather than an item ID on the
four existing kinds, whose names describe setup-time failures; the cause is required for every reason, with unknown when the agent
cannot tell; and the account read
comes first, so the index costs two requests.

New handled errors, in docs/errors.md:

  • maintain_rejected: a validated problem (environment_not_found, item_not_found, invalid_resolution_reason,
    invalid_resolution_cause, item_already_resolved), with response.
  • maintain_unavailable: network failure, timeout, 408/5xx, or an error with no problem body. The Service refuses a
    second resolution while the item stays resolved, so a repeat cannot resolve it twice; after an unconfirmed
    resolution, run maintain show before resolving again, because a recurrence may have reopened the item.
  • invalid_maintain_response: a success response that breaks the contract.
  • The index also reports account_unavailable and invalid_server_response, as account and start do.

Version and contract

On main at 0.10.0, which is not yet published, so maintain joins the 0.10.0 changelog entry. The accepted range
stays main's >= 0.9.0 < 0.10.0; the Service's unreleased 0.9.0 contract includes the maintenance routes, and its
cause and deployed_error change is in firstdraft/firstdraft#1341. Production still serves 0.8.1.

maintain ships in the coordinated 0.10.0 release only if the live test of issue filing passes before that release is
cut. Otherwise this entry moves to the next version's heading in CHANGELOG.md, and that release's version pull request
changes package.json, package-lock.json, and release/compatibility.json as usual.

Sibling changes

  • firstdraft/firstdraft: firstdraft/firstdraft#1341 adds the cause and the deployed_error report to the service.
  • firstdraft/skills: Add a Skill for maintaining a running app skills#191 adds src/commands/maintain.js to packedFileAllowlist and the
    Skill's maintain guidance, which copies the fixed sentence; it bundles this CLI when it is released.

Docs: updated docs/commands.md (intro, command map, Maintain section with the fixed sentence, report failure's
deployed_error, Service endpoints), docs/errors.md (Maintenance recovery and the Error index rows), and CHANGELOG.md
(0.10.0 entry).

Review: Codex, approve (3 rounds, 5 findings fixed, 2 rejected), over the whole branch from main. Earlier, Codex
approved the first commit before its rebase (4 rounds, 2 findings fixed).

Validation

  • npm run check: passes (398 tests, typecheck, lint, format, pack check, packed smoke including maintain and
    maintain resolve --cause).

Observed (2026-11-24), at 9b052e4: against a local service on firstdraft/firstdraft#1341 with a stub Project for
raghubetina/dunbar150-hosted, plan init, plan push, maintain (account read, then items), and maintain show
behaved as documented, and the fixed sentence appeared on standard error only while the local owner's reports
answer was yes. In the live test of issue filing on that repository, maintain listed each item's issue_url, and
maintain resolve --reason ... --cause ... resolved items whose GitHub issues the service then closed, reopened
on a recurrence, and closed again. report failure --kind deployed_error ended with compilation_not_recorded
there, because the stub Project has no Compilation.
Observed (2026-11-17), before the rebase: against a local service polling learn's production GlitchTip data,
maintain, maintain show, maintain resolve, and a repeated resolve (409) behaved as documented.

@raghubetina
raghubetina force-pushed the maintain-command branch 4 times, most recently from cfcbf02 to dab476c Compare November 17, 2026 07:44
@raghubetina
raghubetina force-pushed the maintain-command branch 3 times, most recently from 30d3418 to 4eab83d Compare November 17, 2026 18:27
The maintenance service (firstdraft/firstdraft#1290) gives the owner's
agent a queue of open items for each deployed Environment. The agent
needs to read that queue, see one item's evidence, and record how it
was resolved, so this adds firstdraft maintain, maintain show, and
maintain resolve.

First Draft files and keeps a GitHub issue current for every item, as
Rollbar's and Honeybadger's GitHub integrations do. Summaries carry
`issue_url`, so the agent can link the issue from its pull request
without managing the issue itself.

Each response is checked against the exact contract and printed as a
fresh copy, so nothing unvalidated reaches stdout, while the
evidence's untrusted list and note pass through unchanged for the
agent. The Service refuses a second resolution with
item_already_resolved, so a repeat is safe and an unconfirmed
resolution is maintain_unavailable, not request_outcome_unknown.

Only reads are called safe to retry. A recurrence can reopen an item
between a lost resolution response and its retry, so after an
unconfirmed resolution the agent rereads it with `maintain show`.

The commands share the other commands' service session, so they send
FirstDraft-Client and stop at a limit or on another API contract the
same way.
The 2026-11-21 install and collection decision (B7) has a resolution
say what caused the error, and has the agent send a failure report
with the item's id when that cause is code First Draft generated and
the person said yes to reports. The service accepts both on its
unreleased API 0.9.0 (firstdraft/firstdraft, "Record a maintain
item's cause and its report").

- `maintain resolve` needs `--cause`, one of six values, and checks
  that the resolved item names it as `resolution_cause`.
- `report failure --kind deployed_error --item <item-id>` names the
  item and refuses `--message`, because an item's evidence can hold
  end users' text.
- `firstdraft maintain` reads the account first. Only when reports
  are on does it print the fixed sentence that says when to send that
  report, on standard error, so the JSON on standard output still
  parses. As with `start`, the agent of a person who said no hears
  nothing about reports.
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
The 2026-11-21 install and collection decision (B7) has each
resolution say what caused the error, and has the agent send a failure
report with the item's id when the cause is code First Draft generated
and the owner said yes to reports. The CLI in firstdraft/cli#62 now
requires `--cause` and prints the `Reports are on:` line on standard
error only for an owner who said yes, so the Skill says what each cause
means, when to send `report failure --kind deployed_error`, and to keep
an item's evidence out of every report and note.

The same decision (A3, A4) makes `firstdraft start` the first step and
lets the agent start the device login, so this Skill no longer sends
the owner to a terminal to log in. It follows the authoring Skill's
wording in #195, and no longer describes the helper's
search order, which that release changes.
The owner added `unknown` to the cause list on 2026-11-24, so an agent
that looked and still cannot tell what caused an error says so instead
of guessing; the service accepts it in firstdraft/firstdraft#1341.

The issues First Draft files now tell the reader to run `firstdraft
maintain show <id>` in the app's folder. In an app the Compiler wrote
into its root, the Project's state is archived at .firstdraft/design,
which the maintain commands did not read, so that advice would have
ended in local_input_unreadable. They now find the Project the way the
report commands already do, with readPinnedProject.
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
The owner added `unknown` to the cause list on 2026-11-24 for an agent
that looked and still cannot tell what caused an error. The Skill
allows it only after reading the evidence and the code, so it does not
become a shortcut past the other six, and never in place of
`generated_code`, which would otherwise send a failure report.

The CLI in firstdraft/cli#62 now runs the maintain commands from an
adopted application's root, as the issues First Draft files say, so
the Skill no longer sends the agent to the planning directory first.
Review found that the fixed sentence sent the agent to the generated
application's root for `report failure --kind deployed_error`. After
`plan compile --output`, the Project's state stays in the planning
directory, so the report ended in local_input_unreadable. The sentence
now names the directory where the agent ran `firstdraft maintain`,
which found the same Project.

The same review found that a staging test meant for the maintain
commands selected the report and note commands by index, which had
shifted; it now selects them by name. The docs now give the index's
other account-read failures, list what the maintain requests carry,
and name deployed_error among the 0.10.0 failure kinds.
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
The CLI's review found that `report failure --kind deployed_error`
fails from the generated application's root after `plan compile
--output`, because the Project's state stays in the planning
directory. firstdraft/cli#62's fixed sentence now names the directory
where the agent ran `maintain`, and the Skill says the same.
The re-review found that the request table gave `maintain show` a page
in its path. Only the index sends `?page=N`; `show` sends the Project,
Environment, and item IDs.
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
Review of the Skill against firstdraft/cli#62 and the service found
instructions an agent could follow into a wrong result:

- It never read `.firstdraft/maintain.yml`, so a stricter policy there
  could lose to the 24-hour default.
- It kept only the `untrusted` fields out of pull requests, although a
  request path can hold an end user's identifier; all evidence now
  stays out, and tests use made-up values.
- It ran `start` and the login without the Project's staging origin.
- It required `Refs #N` for items whose issue is not filed yet, said
  every issue closes, and allowed one line on standard error.
- It resolved on deploy without checking that the error had not
  already recurred on the fixed release.
- Its report example demanded a spec and a fix that a duplicate does
  not have, and did not say how to name another Compilation.
@raghubetina
raghubetina marked this pull request as ready for review November 24, 2026 08:15
@raghubetina
raghubetina merged commit 1cb189e into main Nov 24, 2026
6 checks passed
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
The 2026-11-21 install and collection decision (B7) has each
resolution say what caused the error, and has the agent send a failure
report with the item's id when the cause is code First Draft generated
and the owner said yes to reports. The CLI in firstdraft/cli#62 now
requires `--cause` and prints the `Reports are on:` line on standard
error only for an owner who said yes, so the Skill says what each cause
means, when to send `report failure --kind deployed_error`, and to keep
an item's evidence out of every report and note.

The same decision (A3, A4) makes `firstdraft start` the first step and
lets the agent start the device login, so this Skill no longer sends
the owner to a terminal to log in. It follows the authoring Skill's
wording in #195, and no longer describes the helper's
search order, which that release changes.
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
The owner added `unknown` to the cause list on 2026-11-24 for an agent
that looked and still cannot tell what caused an error. The Skill
allows it only after reading the evidence and the code, so it does not
become a shortcut past the other six, and never in place of
`generated_code`, which would otherwise send a failure report.

The CLI in firstdraft/cli#62 now runs the maintain commands from an
adopted application's root, as the issues First Draft files say, so
the Skill no longer sends the agent to the planning directory first.
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
The CLI's review found that `report failure --kind deployed_error`
fails from the generated application's root after `plan compile
--output`, because the Project's state stays in the planning
directory. firstdraft/cli#62's fixed sentence now names the directory
where the agent ran `maintain`, and the Skill says the same.
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
Review of the Skill against firstdraft/cli#62 and the service found
instructions an agent could follow into a wrong result:

- It never read `.firstdraft/maintain.yml`, so a stricter policy there
  could lose to the 24-hour default.
- It kept only the `untrusted` fields out of pull requests, although a
  request path can hold an end user's identifier; all evidence now
  stays out, and tests use made-up values.
- It ran `start` and the login without the Project's staging origin.
- It required `Refs #N` for items whose issue is not filed yet, said
  every issue closes, and allowed one line on standard error.
- It resolved on deploy without checking that the error had not
  already recurred on the fixed release.
- Its report example demanded a spec and a fix that a duplicate does
  not have, and did not say how to name another Compilation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant