Skip to content

feat(patchy): manage patch lifecycles from the CLI - #266

Merged
allisonmahmood merged 3 commits into
mainfrom
portal/253-cli-verbs
Sep 16, 2026
Merged

allisonmahmood merged 3 commits into
mainfrom
portal/253-cli-verbs

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Patch owners need to manage their patches from the CLI and keep repo descriptions in sync with portal edits.

Adds lifecycle commands and description sync, with actionable refusals and definition-change reminders. Notices remain visible when commands fail or recover a saved publish attempt. CLI documentation and distributed skills describe the new behavior.

Stacked on #265 (portal/252-patchy-list). This PR intentionally targets that branch, not main.

Fixes #253.

Verification

  • pnpm lint
  • pnpm typecheck
  • pnpm test: 875 tests across 79 files passed
  • pnpm test:packed-cli-e2e: complete real-server workflow passed

The full suite exposed a startup test's outer deadline being shorter than its subprocess timeout. A separate commit aligns those deadlines without changing the assertions.

Implemented with GPT-6 Astra in Oh My Pi.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:l 501-1,000 changed lines labels Sep 15, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Astra review

Reviewed 7e8d19ab4e7ccad7361df3efcef0a5c75d342a9d against origin/portal/252-patchy-list at 245511c8a9b992f2825f3b8977dfa7d886a04225, using the three-dot diff and issue #253, including its referenced spec sections 6 and 8. One pass, no subagents; merge blockers only.

Standards

No merge-blocking method findings. The lifecycle commands reuse the existing target resolution, API client and output contract. The shared description validator keeps CLI and server normalization consistent. No merge-blocking YAGNI findings; refusal details and warning retention support the requested lifecycle and sync behavior.

Spec

No merge-blocking intent findings. The diff covers the lifecycle verbs and confirmation/force rules, actionable refusals, description initialization and pull-down, repo/file description handling, definition-change reminders, and the required docs and skills.

Verification

Focused offline checks passed: 58 tests across 4 files, with 194 unrelated tests skipped. Coverage included CLI lifecycle/refusal behavior, publish recovery, description sync, reminders, dev-start notices, and owner lifecycle API behavior. I did not rerun the packed end-to-end suite.

Summary: Standards 0 blockers, worst issue none; Spec 0 blockers, worst issue none.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Code review (PR 266 / #253)

Two-axis review of portal/252-patchy-list...portal/253-cli-verbs (80d9488, 7e8d19a), plus the extra axes asked for: #253 intent vs what landed, the implementation method, and YAGNI. Eight reviewers ran in parallel; findings below are theirs, lightly cleaned, not reranked across axes.


Standards

No Effect service findings. New CLI errors are Schema.TaggedErrors with structural fields, message from those fields, required cause when wrapping, and Output.contract recovers them with Effect.catchTags. Namespace imports and env acquisition look fine.

Documented standards (hard)

Hit every surface — The CLI (CLAUDE.md; ADR-0004; docs/SKILL_DISTRIBUTION.md)

  • skills/patchy/SKILL.md ~374–377 still says “New lifecycle CLI verbs are not implemented yet,” contradicting the new Managing a patch section, ADR-0004, and packages/sdk/skills/patchy-loop/SKILL.md.
  • Failure --json shape was widened to owner?, dependants?, sources?, purgeAt?, warnings?. patchy-loop matches. The global skill (~389–391) and packages/patchy/README.md (~725) still document { ok: false, error, kind, code?, state? }. README still lists success API shapes as whoami, publish, share and delete only.
  • README Command flags (~739) still documents --patch only on share/delete; --force, --yes, --clear, --description are missing from that list. PATCHY_API_TOKEN (~751) still names only whoami/publish/share/delete.
  • packages/patchy/src/Output.ts 1–8 (touched) still describes { ok: false, error, kind, code?, state?, warnings? }, omitting lifecycle fields the implementation already emits via refusalDetails.

Hit every surface — Vocabulary (CLAUDE.md; docs/agents/domain.md)

  • CONTEXT-MAP.md line 7 still says “new lifecycle CLI commands and portal controls remain future work.” Product shape and ADR-0004 now say the CLI verbs are built; the map agents read first is stale. (docs/product.md and packages/patchy/CONTEXT.md were updated.)

Fix: delete the leftover “not implemented” line; mirror ADR-0004’s failure envelope and command list in the global skill, README flags/env, and Output.ts header; drop the future-work clause on the map.

Smells (judgement only)

Duplicated Code — Project.recordDescription vs recordPublish are the same scoped temp-file rewrite of patchy.json. Repo YAGNI wins unless a third writer appears.

Repeated Switches — Api.fromRefusal’s Schema.is cascade and refusalDetails’ _tag switch encode the same refusal set at two layers. Expected for wire vs CLI errors; not a catchTags miss (wire bodies have no _tag).

Shotgun surgery across README/ADR/skills/api is required by Hit every surface — suppressed.


Spec

Quoted against #253 and parent #247 §6 / §8.

(a) Missing or partial

  • Global skill still teaches the old take-down. Spec: “the global skill for retire/delete/restore/rollback/describe and the description.” skills/patchy/SKILL.md adds a Managing section, but Publishing behavior still says “New lifecycle CLI verbs are not implemented yet” and “Take that page down” is patchy delete without --yes. An agent following that paragraph gets local exit 1.
  • Failure document not fully mirrored on CLI surfaces. Spec §8: “The failure document keeps { ok: false, error, kind, code } and gains those fields beside code.” ADR-0004 lists owner?, dependants?, sources?, purgeAt?, warnings?. packages/patchy/README.md Global flags still documents { ok: false, error, kind, code?, state? } and “warnings belong in success documents.” The skill’s --json pitfall matches that old shape.

(b) Not asked for

  • 7e8d19a (apps/server/src/start.test.ts 15s timeouts) is unrelated to §6/§8.
  • Pull-down and primitive reminders on add/remove. Spec: “at refresh, dev start and publish.” Those commands share Project.refresh, so they also rewrite patchy.json and emit warnings. ADR/README now advertise warnings on add/remove and dev status.

(c) Looks done, looks wrong

  • Same skill leftover as (a): new verbs are implemented, but the installed skill still tells agents they are not. That is a contract bug, not just stale copy.
  • invalid_description is local exit 1 for describe / publish --description preflight. Parent §8: “Refusal codes an agent branches on (all rejected, exit 2): … invalid_description (422).” Wire 422 is rejected; the same code with kind: "local" will mis-branch if agents follow that ladder without kind. (ADR-0004 already says kind first, then code; this is the weaker of the two.)

Intent of #253 vs what landed

#253 is the owner lifecycle on the CLI agents already use: take a live tool off, delete it with a 30-day window, bring it back, roll a live address to a retained version, and keep patchy.json honest with the cloud — without forking a patch, without admin CLI, and with refusals that name who to ask before --force.

The PR solves that problem. retire / delete --yes / restore / rollback / describe share the share/delete targeting rules. JSON success is the wire body. Refusals keep code plus dependants / sources / owner / purgeAt / state. Dependants and off-source copy ends with “Ask the person you are working for before forcing.” Publish treats not_owner, patch_retired, and patch_deleted as definitive, keeps the id, and only a gone 404 says to remove patch. Pull-down, file --description, repo refusal of that flag, init 501-code-point purpose with interactive re-prompt, and reminders on refresh / new dev / publish are in. Packed e2e: refused then forced retire, restore, rollback to 1, describe, then pull-down on refresh.

The spirit miss is agent copy, not missing verbs. The global skill still says the new verbs are not implemented, while a new section teaches the opposite. describe --patch inside a repo does not rewrite patchy.json (repo is only untargeted). The pull-down always says the description “was changed in the portal,” even when another CLI describe wrote it (the packed e2e does exactly that — matching the specified string, not the later portal). Extra vs “Done when”: warning plumbing through failed publish/dev, descriptionUpdatedAt on patch detail (needed for sync), and the unrelated 15s start.test deadline.

Admin CLI was not invented; serving 404s were left for ticket 11.


Method

Lifecycle policy stays in Patches. PatchesApi maps tagged errors onto wire schemas. The CLI is targeting, confirmation, and the agent contract. That layering is right.

commands.ts adds thin verbs on patchTarget and refused. Project.ts owns patchy.json identity: description write, publish stamp, pull-down. Api.fromRefusal is the one decode of structured wire refusals. CliError is a second tagged ladder for agents; Output.contract is the only renderer. Reminders live in a small CLI helper, not the server.

Pull-down by stamp, not remembered text, is the correct last-write-wins: local edits leave descriptionSyncedAt alone; only a strictly newer cloud stamp overwrites. Reminders compare executed definitions to the last generated manifest.json before replacing it — no new store. Packed e2e actually hits the agent contract: packed binary, --json, exit 2, has_dependants, --force, restore, rollback, describe rewrite, refresh pull-down.

CLI tests are mostly contract tests (kind, code, fields, no HTTP on local refusals). start.test.ts pairs a 10s spawnSync timeout with a 15s Vitest deadline so a hang becomes a failed assertion rather than a silent kill. Mild smell: 10s is large for an instant Config fail.

Caveats: agent copy is duplicated (Patches.PatchRetired vs PatchRetiredError). version_unavailable / invalid_description stay generic RejectedError and pass through stub error text, so branching is only half-tagged. sameDefinition is a hand-rolled equality that special-cases optional/unique defaults instead of normalize-then-isDeepStrictEqual. describe’s file-or-text vs text parsing is the share-command trick again.

A simpler method: canonicalize definitions (drop default flags) then deep-equal; one writeRepo helper for the two patchy.json writers. Keep policy on the server.

Verdict: the method is sound with caveats.


YAGNI

The verbs, description sync, and reminder are the spec. Four handlers on existing patchTarget / refused / runProject is the smallest model that makes the behavior unsurprising. WarningBuffer is the right model for “notices survive a later failure.” Contract tables in cli.test.ts over verbs × targets × refusal codes are focused, not slop.

Trim, don’t rewrite:

  • recordDescription and recordPublish are the same atomic patchy.json write with different fields. One helper.
  • sameDefinition hand-walks columns/indexes. Normalize omitted booleans, then isDeepStrictEqual.
  • Dual warning returns (function arrays and rememberWarnings and PendingPublish.warnings) is extra plumbing around a buffer that already exists. The Set-dedup test restates Set semantics.

The six new tagged refusals look like Speculative Generality if you only look at the JSON envelope ({ error, kind, code, fields }). They are not: Effect service conventions require distinct tagged classes when the user-facing message and caller control flow differ. Do not collapse them into one RejectedError with optional fields.

lifecycleTarget is not a framework. Do not extract a generic lifecycle command.

keep lifecycle handlers and DescriptionText / trim the two patchy.json writers and sameDefinition / leave the tagged-error lattice.


Other surfaces (not the two axes)

  • docs/product.md § Describing a patch says the reminder is built; § Primitives still says “The CLI's reminder … remains future work.” Drop the latter.
  • skills-lock.json hash matches sha256sum skills/patchy/SKILL.md (40a6acff…7321).
  • Starter AGENTS.md correctly splits purpose vs patchy.json vs patchy.config.ts.
  • patchy-loop mentions both the portal pull-down notice and the primitive-change reminder. patchy-tables / patchy-files were correctly left alone (feat(patchy): retire, delete, restore, rollback and describe; the description sync and the change reminder #253 only named the loop).
  • Reverse states are present: retire/delete ↔ restore, describe ↔ --clear, --force vs --yes.

Standards: 5 documented-standard findings (plus 2 judgement smells); worst is the global skill still teaching that lifecycle verbs are not implemented.

Spec: 2 missing/partial, 2 scope-creep, 2 looks-wrong; worst is the same leftover skill copy (an agent following “Take that page down” omits --yes and exits 1).

allisonmahmood added a commit that referenced this pull request Sep 15, 2026
Resolve PR #266 review findings about stale lifecycle status, deletion confirmation, failure envelopes, flags and credentials. Clarify local description refusals and explicit-target behavior, and refresh the distributed skill hash.
@allisonmahmood

allisonmahmood commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner Author

Review dispositions

Fixed in f78ef9a after checking both conversation reviews against the implementation. The Reviews tab and inline review list were empty when checked.

Fixed

  • Removed the global skill's claim that lifecycle verbs are unimplemented. Agent deletion examples now use --yes after confirmation and point to the management guidance for retirement/recovery.
  • Mirrored the complete failure envelope, including lifecycle fields and warnings, in the global skill, README and Output header. Corrected the claim that warnings occur only on success; expanded lifecycle success shapes, flag descriptions and token guidance.
  • Updated CONTEXT-MAP and the product's Primitives section to mark the CLI lifecycle/reminder behavior as built, while leaving portal controls as future work.
  • Clarified local description validation versus HTTP 422 refusals, explicit-target describe behavior, and that the file-only --patch restriction applies to publish.
  • Refreshed skills-lock.json; the built package's global skill matches the canonical source byte-for-byte.

Kept as is, with reasons

  • Startup-test deadlines: the previous full-suite run hit Vitest's 5-second deadline while its subprocess was allowed 10 seconds. The separate 15-second outer deadline lets the bounded subprocess finish and preserves every assertion. No server behavior changed.
  • Add/remove notices and dev-status shape: add/remove perform the same transactional generation as refresh, so they should not silently suppress its notices. Healthy dev/status does not sync or regenerate; its shared response has an empty warnings array.
  • Local invalid_description: malformed CLI text is fixable before a description request is sent, so it remains exit 1/local. An HTTP 422 remains exit 2/rejected. ADR-0004 requires branching on kind/exit before code; the clarification makes this case explicit.
  • Explicit describe --patch or file targets: these deliberately operate independently of the working directory's repo binding. Only untargeted repo mode writes back to patchy.json, consistent with target/instance isolation.
  • “Changed in the portal” wording: this is the exact notice required by feat(patchy): retire, delete, restore, rollback and describe; the description sync and the change reminder #253, even when another CLI changed the cloud description.
  • Two atomic repo writers: their identity and recovery rules differ. Describe requires an exact existing id; publish may establish an id and accept an older receipt without a description stamp. Extracting their small I/O overlap is not needed for correctness.
  • Definition comparison: it already treats omitted/false flags identically and preserves index-column ordering. Its deep-equality fast path avoids canonicalizing unchanged definitions; no incorrect comparison was demonstrated.
  • Warning storage and isolation test: returned arrays serve success/preparation results, the command buffer preserves notices on later failure, and pending-attempt storage survives process restarts. The test checks output isolation between commands and ignores notices outside a command, not just Set behavior.
  • Error mappings and command parsing: wire bodies have no _tag, so wire-to-error and error-to-output mappings serve distinct boundaries. The typed lifecycle variants remain required by the Effect conventions; generic wire-only refusals retain their server message. Existing positional/target rules do not need another lifecycle abstraction.

Verification

  • pnpm lint and pnpm typecheck passed.
  • All 252 tests passed across cli.test.ts, devLifecycle.test.ts, primitiveReminders.test.ts and PatchesApi.test.ts.
  • Built CLI delete, describe and publish --help expose the documented flags; packaged skill/source comparison passed.

CI on f78ef9a04fc1a28aea6330971da2fa4f65e179a0 is complete: all eight reported checks passed (Node 22/24 tests, lint, Postgres concurrency, Clerk live, CLI smoke, dependency review and labeling). CI run. GitHub reports no required checks for this stacked base.

GitHub reports MERGEABLE / CLEAN; no new conversation, Reviews-tab or inline findings appeared after the fix. No unresolved blockers. Ready to merge into portal/252-patchy-list; still stacked on #265. I have not merged it.

allisonmahmood added a commit that referenced this pull request Sep 16, 2026
Resolve PR #266 review findings about stale lifecycle status, deletion confirmation, failure envelopes, flags and credentials. Clarify local description refusals and explicit-target behavior, and refresh the distributed skill hash.
Base automatically changed from portal/252-patchy-list to main September 16, 2026 16:51
Implement #253 with typed lifecycle refusals, repo description pull-down, and definition-change reminders. Preserve notices on failures and publish recovery, and update the CLI documentation and distributed skills.
Give startup checks a 15-second outer deadline around their existing 10-second subprocess timeout. The full suite exposed the shorter 5-second test deadline under load; configuration and credential-safety assertions are unchanged.
Resolve PR #266 review findings about stale lifecycle status, deletion confirmation, failure envelopes, flags and credentials. Clarify local description refusals and explicit-target behavior, and refresh the distributed skill hash.
@allisonmahmood
allisonmahmood merged commit d3f2df6 into main Sep 16, 2026
8 checks passed
@allisonmahmood
allisonmahmood deleted the portal/253-cli-verbs branch September 16, 2026 17:00
allisonmahmood added a commit that referenced this pull request Sep 16, 2026
Company, Connections and Your machines used separate page treatments, so
navigation and controls changed between signed-in pages.

They now share one app shell and one component set. Auth doors keep
their card, `/` stays unchanged, and existing forms and permissions keep
their behavior. The UI review spec and product glossary now document the
shared controls.

Stacked on #266 (`portal/253-cli-verbs`), which is this PR's base. The
diff contains only issue #254's shell and component work.

Closes #254.

## Verification

- Typecheck and lint passed.
- Full offline suite: 877 tests across 79 files passed.
- Final focused page suites: 57 tests passed after review corrections.
- Exercised all four signed-in pages and form success/refusal paths
through this worktree's dev instance; captured PNGs and checked 390px
layouts.
- Standards findings fixed and rechecked; no Spec findings remain.

Implemented with GPT-6 Astra in Oh My Pi.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:server Touches the server area size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(patchy): retire, delete, restore, rollback and describe; the description sync and the change reminder

1 participant