Repository navigation
Add maintain commands for deployed-app items - #62
Merged
Merged
Conversation
raghubetina
force-pushed
the
maintain-command
branch
4 times, most recently
from
November 17, 2026 07:44
cfcbf02 to
dab476c
Compare
raghubetina
force-pushed
the
maintain-command
branch
3 times, most recently
from
November 17, 2026 18:27
30d3418 to
4eab83d
Compare
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.
raghubetina
force-pushed
the
maintain-command
branch
from
November 24, 2026 05:59
4eab83d to
3077d83
Compare
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
marked this pull request as ready for review
November 24, 2026 08:15
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
firstdraft maintaingroup for the maintenance service (firstdraft/firstdraft#1290, #1296), and the2026-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 openitems for the Project in
.firstdraft/state.json(GET .../environments/:name/items?page=N).--environmentdefaults to
production. Each item carriesissue_url, the GitHub issue First Draft files and keeps current forit, or
null, andresolution_cause.firstdraft maintain show ID [--environment NAME]reads one item withevidenceanddone_when.firstdraft maintain resolve ID --reason REASON --cause CAUSE [--detail TEXT] [--environment NAME]posts{reason, cause, detail?}. A reason other thanpull_request,host_change,not_a_bug,duplicate, orstopped_occurring, or a cause other thangenerated_code,later_code,configuration_or_host,data,dependency,not_a_bug, orunknown, isinvalid_arguments(exit 2) before any request.All three accept
--staging, use the pinned origin, and print the validated response on stdout. They run from thegenerated application's root, where they read the Project's state archived at
.firstdraft/designas the reportcommands 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, indexitems 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.untrustedandevidence.notereach the agent unchanged. The service filesissues 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 withrate_limited,update_required, orapi_contract_unsupportedlikethe rest.
Reports during maintenance (second commit)
From B7 of the 2026-11-21 install and collection decision:
report failure --kind deployed_error --item <item-id>sendsmaintenance_item_idand refuses--message,because an item's evidence can hold end users' text. Another kind with
--itemisinvalid_arguments.{"reports": "on"},firstdraft maintainwritesMAINTAIN_REPORTS_ON_LINEfromsrc/agent-sentences.json standard error, after the items. Standard error keepsthe JSON on stdout parseable; the update line already goes there for JSON commands. As with
start, the agent of aperson who said no hears nothing about reports. When the account read fails, the index reads no items and ends with
account_unavailableorinvalid_server_response.Third commit (owner direction, 2026-11-24)
unknownjoins the cause list, for an agent that looked and still cannot tell; the cause stays required.readPinnedProject, so they also run from an adopted application'sroot. The issue text in firstdraft/firstdraft#1349 tells the reader to run
firstdraft maintain show <id>in theapp's folder, which needs this.
Choices the decision note leaves open, for review: a dedicated
deployed_errorkind rather than an item ID on thefour existing kinds, whose names describe setup-time failures; the cause is required for every reason, with
unknownwhen the agentcannot 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), withresponse.maintain_unavailable: network failure, timeout, 408/5xx, or an error with no problem body. The Service refuses asecond resolution while the item stays resolved, so a repeat cannot resolve it twice; after an unconfirmed
resolution, run
maintain showbefore resolving again, because a recurrence may have reopened the item.invalid_maintain_response: a success response that breaks the contract.account_unavailableandinvalid_server_response, asaccountandstartdo.Version and contract
On
mainat 0.10.0, which is not yet published, somaintainjoins the 0.10.0 changelog entry. The accepted rangestays main's
>= 0.9.0 < 0.10.0; the Service's unreleased 0.9.0 contract includes the maintenance routes, and itscause and
deployed_errorchange is in firstdraft/firstdraft#1341. Production still serves 0.8.1.maintainships in the coordinated 0.10.0 release only if the live test of issue filing passes before that release iscut. Otherwise this entry moves to the next version's heading in
CHANGELOG.md, and that release's version pull requestchanges
package.json,package-lock.json, andrelease/compatibility.jsonas usual.Sibling changes
firstdraft/firstdraft: firstdraft/firstdraft#1341 adds the cause and thedeployed_errorreport to the service.firstdraft/skills: Add a Skill for maintaining a running app skills#191 addssrc/commands/maintain.jstopackedFileAllowlistand theSkill's
maintainguidance, 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, Codexapproved 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 includingmaintainandmaintain 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), andmaintain showbehaved 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,
maintainlisted each item'sissue_url, andmaintain resolve --reason ... --cause ...resolved items whose GitHub issues the service then closed, reopenedon a recurrence, and closed again.
report failure --kind deployed_errorended withcompilation_not_recordedthere, 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.