Skip to content

Find a maintained app's Project from its own files - #70

Merged
raghubetina merged 2 commits into
mainfrom
maintain-from-app-files
Nov 24, 2026
Merged

raghubetina merged 2 commits into
mainfrom
maintain-from-app-files

Conversation

@raghubetina

@raghubetina raghubetina commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

firstdraft maintain read the Project only from planning state: .firstdraft/state.json, or its archive at .firstdraft/design after root adoption. An app compiled with --output, and any fresh clone of an app, has neither. With publication removed, that is where someone fixing a production error works, often on another computer, so the commands could not run where they are most needed. firstdraft/firstdraft#1349's issue text says to run firstdraft maintain show ID "in the app's folder"; this makes that true.

What changes

Without Project state, the maintain commands, and report failure --kind deployed_error, read the Project ID from the app's own .firstdraft/gaps.json. Planning state, where it exists, still wins.

What each command needs, and where it comes from now:

Needs From planning state From a fresh clone
Project ID state.json .firstdraft/gaps.json, project.id
API origin state.json, pinned Not in the app's files. The origin login would select: --staging, FIRSTDRAFT_API_URL, or https://firstdraft.com
Login Saved login or environment token for that origin The same, on this computer: firstdraft start and the agent-started login
Compilation, for a deployed_error report .firstdraft/compilation.json Not in the app's files. The report ends with compilation_not_recorded and sends nothing, unless a compilation.id is given right after report failure

After a successful response from a fresh clone, each maintain command writes one fixed line on standard error, applicationProjectLine in src/agent-sentences.js, after any update line: it names the file and the origin it used, and how to select another origin. It says nothing about reports, so the agent of a person who said no still hears nothing about them. A Project on another origin answers environment_not_found, which the existing recovery covers. A gaps.json that is not JSON, whose format is not firstdraft.foundation-gaps/…, or whose project.id is not a UUIDv7, is local_input_unreadable.

The maintain commands now read the Project once per command and pass it to each request, instead of reading it per request.

Why gaps.json is a sound source

Read on the service's origin/main (fc8e3fb0b):

  • Compilations::Promote and Compiler::Renderers::FoundationGapsRecord write the AnalysisRun's GapSet into every artifact as .firstdraft/gaps.json, byte for byte. Compiler::CompileCapturedProject takes the GapSet as a required input, so every service Compilation emits it.
  • Compiler::Gaps::GapSet.build writes project.id from the Project's ID: the client-generated UUIDv7 that plan init creates and no later push changes. A recompile changes graph_version beside it, not the ID.
  • The format is firstdraft.foundation-gaps/2, and the service caps a GapSet at 32 MiB, which the CLI also uses as its read limit.
  • raghubetina/dunbar150-compiled commits .firstdraft/gaps.json with project.id 01a20c54-fbc2-7cb1-abce-06e6e516e056; the generated .gitignore leaves .firstdraft alone.

Limits: the app's AGENTS.md says the file is there "if retained", so an owner who deletes .firstdraft loses it, and the command then reports local_input_unreadable with where to run it instead. The file also carries the analyzer and Compiler releases and every gap, none of which the CLI reads.

Checks

  • npm run check: 402 tests pass, with the packed smoke. New tests: a linked .firstdraft and a GapSet that is not UTF-8 (both refused before any request); a fresh clone at the default, --staging, and custom origins for the index, and for a resolution; four malformed gaps.json files; planning state winning over gaps.json; and a deployed_error from a fresh clone without a Compilation (compilation_not_recorded, nothing sent), with one (sent to the selected origin), and another kind from the same folder (still local_input_unreadable).
  • Observed (2026-11-24): from a fresh --depth 1 clone of raghubetina/dunbar150-compiled, against a local service holding a Project with that ID, maintain, maintain show, and maintain resolve --reason not_a_bug --cause not_a_bug each succeeded and printed the note.

Version

0.10.0 is not published, so this joins its CHANGELOG.md entry.

Docs: updated docs/commands.md (Maintain a deployed application: where the commands find the Project, the note; the deployed_error report from a clone), docs/errors.md (local_input_unreadable), and CHANGELOG.md (0.10.0). The Skill's guidance follows in firstdraft/skills, and the service's issue text in firstdraft/firstdraft#1349.

Review: Codex, approve (2 rounds, 7 findings fixed)

`firstdraft maintain` read the Project only from planning state, which
an app compiled with --output, or any fresh clone of an app, does not
have. With publication removed, that is where someone fixing a
production error works, so the commands could not run where they are
most needed.

Every Compilation writes its GapSet into the app as
.firstdraft/gaps.json, and its project.id is the Project's ID, which
no recompile changes. Without Project state, the maintain commands and
a deployed_error report now read that ID. The file holds no origin, so
they use the one `login` would select (--staging, FIRSTDRAFT_API_URL,
or firstdraft.com) and need a login for it, and maintain says so on
standard error. It also records no Compilation, so a deployed_error
report from such a copy ends with compilation_not_recorded unless one
is named. Planning state, where it exists, still wins.

The maintain commands now read the Project once per command and pass
it to each request.

Checked against a fresh clone of raghubetina/dunbar150-compiled and a
local service holding its Project: maintain, maintain show, and
maintain resolve each succeeded and printed the note.
Review found that the fallback read gaps.json through a symlinked
.firstdraft, which the planning-state reader refuses, so a link into
another checkout could act on that checkout's Project; it now requires
a real .firstdraft directory. It also decoded malformed UTF-8 leniently;
it now refuses it, as the state reader does.

The note maintain prints from a fresh clone told every agent where a
failure report's Compilation goes, including the agent of a person who
said no to reports, who is to hear nothing about them. The note now
names only the file and the origin; the report's own
compilation_not_recorded detail, reached only with reports on, says
the rest.

The help texts and the command reference now say which origin a clone
uses, that a deployed_error from a clone reads the account first, and
that it reads the app's gaps.json for its Project ID.
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
With firstdraft/cli#70, the maintain commands find the Project from
the application's own .firstdraft/gaps.json when the planning state is
not on this computer, as in a fresh clone or an app compiled with
--output. So the Skill now says to run them from the application's
folder in every layout.

That copy holds no API origin, so the Skill no longer says to read one
from planning state that may not exist: it uses the saved api_url when
there is one, and otherwise the default origin, or --staging when the
owner says so. It also says that a failure report from such a copy
needs its Compilation's ID, and to continue without the report when
there is none.
@raghubetina
raghubetina marked this pull request as ready for review November 24, 2026 15:33
@raghubetina
raghubetina merged commit 34fe52c into main Nov 24, 2026
6 checks passed
raghubetina added a commit to firstdraft/skills that referenced this pull request Nov 24, 2026
With firstdraft/cli#70, the maintain commands find the Project from
the application's own .firstdraft/gaps.json when the planning state is
not on this computer, as in a fresh clone or an app compiled with
--output. So the Skill now says to run them from the application's
folder in every layout.

That copy holds no API origin, so the Skill no longer says to read one
from planning state that may not exist: it uses the saved api_url when
there is one, and otherwise the default origin, or --staging when the
owner says so. It also says that a failure report from such a copy
needs its Compilation's ID, and to continue without the report when
there is none.
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