Skip to content

fix(cli)!: standardize HACK-2218 machine output contracts - #835

Merged
roodboi merged 19 commits into
nextfrom
feat/hack-2238-json-contract
Nov 15, 2026
Merged

roodboi merged 19 commits into
nextfrom
feat/hack-2238-json-contract

Conversation

@roodboi

@roodboi roodboi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Update (Nov 15): breaking for next.17. 5.0.0-next.17 shipped from a tree without this PR, so version --json, activity --json, projects --json --observe, global status --json --observe and global install|trust --plan --json are now published in their older shapes. This PR moves them into the envelope, so the title is marked ! and the next.18 release notes describe the migration for scripts. The desktop core parser in this PR requires the new contract, so it cannot read a next.17 CLI's version --json. Since then the inventory also covers env migrate --json (#797, envelope without a schema id) and usage --json --by-service (#852, hack.usage.by-service.v1).

The unpublished HACK-2218 JSON commands used incompatible top-level shapes. Version, observe-only projects/global status, and administrator install/trust plans now return {ok:true,data:{schema,...}}; Activity gains its missing hack.activity.v1 schema. Failures return a stable E_* error envelope and nonzero status. Published plain projects --json keeps its existing shape. Refused and incomplete plans retain recovery evidence in error.detail.plan.

Desktop core consumes the version envelope and provides a strict schema parser for the migrated contracts. Shared generated fixtures test both CLI and desktop boundaries. The new Machine-readable output reference inventories every canonical JSON command, distinguishes legacy/streaming shapes, and is checked against the command definitions. The native-env-plan acceptance harness allows the lifecycle activity audit file while retaining its no-registry/no-runtime-state checks.

Machine-readable command boundary

Validation: focused CLI/contract, administrator-plan, activity, observation, generation and reference tests pass; root typecheck/check/privacy, documentation checks and CLI build pass; desktop core has 79 passing tests. Contract tests check the shared usage-error boundary for all 80 canonical JSON commands and actual success boundaries for migrated variants and prune. macOS administrator tests are skipped on Linux. No live engine/native provider or Mac application state-tool validation is claimed; the lead will verify real Mac state. Desktop schema parsing requires the new CLI contract; released CLIs do not yet provide it.

HACK-2238. Based on next; no app tab branches or desktop appendix rows changed.

@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hack-docs Ready Ready Preview Nov 15, 2026 6:10am UTC

Request Review

@linear-code

linear-code Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

HACK-2238

HACK-2218

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T06:11:52.321483Z db01be6 Manual request
🔒 Security Review ✅ Completed 2026-11-15T06:13:08.154480Z db01be6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47aee20e1c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/json-contracts.ts Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 47aee20e1c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: bce84af562

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: bce84af562

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

…ontract

# Conflicts:
#	scripts/check-native-acquisition-plan-cli.ts
#	scripts/check-native-endpoint-plan-cli.ts
#	scripts/check-native-env-plan-cli.ts
#	scripts/check-native-host-plan-cli.ts
#	scripts/check-native-process-plan-cli.ts
#	scripts/check-native-routing-plan-cli.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82de876997

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/json-contracts.ts Resolved
@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 30fd64c76c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 0c69a6ff8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 0c69a6ff8e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: d6372ba7e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: d6372ba7e2

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi

roodboi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 3ffc597441

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 3ffc597441

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi

roodboi commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Ready for lead: 2058a97

Normal merge of next e47681e (d7bcd2a) plus one follow-up commit. This replaces the note at cda7980.

Merge resolutions:

  • Six scripts/check-native-*-plan-cli.ts: took next. Every helper call on next already passes the private directory in privateInputs, so I removed this branch's duplicate privateRoot option from scripts/lib/native-plan-home.ts and kept its exact home listing and activity key-set checks.
  • tests/native-plan-home.test.ts: kept both privacy tests.
  • src/lib/cli-result.ts: kept E_PLAN_REFUSED, E_PLAN_INCOMPLETE and E_NATIVE_SETUP_REQUIRED. Error-code reference regenerated with bun run generate:agent-plugins, not hand-merged.
  • Desktop core/src/source.rs and core/tests/dump_state.rs: next's test_support::script helper with this branch's version --json envelope stub. No --version stubs remain in desktop core.

Follow-up 2058a97: native setup --json (#794) was missing from the inventory. It passes the runtime's bare {status, files, probe} object through, so it is listed as a new runtime-passthrough kind; its shape is not changed here.

Unpublished outputs that do not follow the HACK-2238 envelope rule (not changed in this PR; recommended follow-up: give each a string schema id inside the envelope):

Ran locally on the merged head (Linux, Bun 1.4.4, temp HOME, HACK_DAEMON_AUTOSTART_DISABLE=1): 10 contract/CLI test files (the new inventory row fixed the 2 inventory failures); contract + success-shape 96 pass; root typecheck and check; bun run build, build:config-compiler, check:native-plan-cli: all 8 relocated acceptance scripts pass; desktop core cargo nextest run -p hack-desktop-core in an isolated HOME: 81 passed, 1 skipped. The full desktop workspace was not built here (the GUI crate needs Wayland libraries); the hosted desktop jobs passed.

Exact-head hosted CI (run 43668277536): every Linux job passed: test shards 3–8, all 4 Docker e2e shards and fan-in, linux-process-lifetime, Candidate core (ubuntu), Config compiler (ubuntu x64 and arm), Desktop app (Linux), runtime state models and images, docs site, secret scan. Already passed on macOS: Candidate core, Config compiler, Desktop app. macOS test shards 1/8 and 2/8: queued, not waited for. Optional Proof skipped. GitHub reports mergeable. computer pr review-status: CLEAR at 2058a97.

Review: persistent Codex reviewer (gpt-6.1-sol, codex-dio) CLEAN on the merge and the follow-up (round 4). Codex bot: no major issues and no security issues at 2058a97.

Still open for the lead: the Mac batch, and the Mac app's read-only state tool against real local state. Desktop strict version parsing needs the new CLI contract; released CLIs do not provide it. No further pushes planned after this note. #831 is merged on top of this head.

roodboi added a commit that referenced this pull request Nov 15, 2026
Build the fixture's failed, unregistered up record with the production
activity writer so it carries exactly the schema's nine keys and no path.
It passes with the current shared helper and with the stricter key-set
check proposed in #835, so merge order does not matter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…migration

`env migrate --json` (#797) is an envelope without `data.schema`;
`usage --json --by-service` (#852) is a schema-tagged variant, so its
schema id moves into MACHINE_SCHEMAS. Flag variants whose base command
keeps another shape now get their own reference row instead of a
hard-coded list.

The outputs this branch migrates first shipped in 5.0.0-next.17, so the
reference page no longer calls them unpublished and the next.18 release
notes describe the change for scripts.

BREAKING CHANGE: version, activity, projects --observe, global status
--observe and global install|trust --plan JSON move into the
{ok,data:{schema}} / {ok:false,error} envelope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@roodboi roodboi changed the title fix(cli): standardize unpublished machine output contracts fix(cli)!: standardize HACK-2218 machine output contracts Nov 15, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@roodboi

roodboi commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: db01be6341

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

roodboi added a commit that referenced this pull request Nov 15, 2026
…74aaf) into feat/hack-2218-project-state

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: db01be6341

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi

roodboi commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Ready for lead: db01be6

Normal merge of next bf74aaf (d6d0b89, no conflicts) plus two commits. Replaces the note at 2058a97.

Decision flagged: this PR is now breaking. 5.0.0-next.17 was published from e47681e, which does not contain this PR, so version --json, activity --json, projects --json --observe, global status --json --observe and global install|trust --plan --json shipped in their older shapes (checked on that tree). This PR moves them into the envelope. Default taken: proceed. The title is now fix(cli)!:, commit 4e55382 carries BREAKING CHANGE:, the next.18 release notes have a migration entry (read data, check data.schema, branch on ok / error.code), and the reference page no longer calls them unpublished. A desktop build with this PR cannot read a next.17 CLI's version --json. Reversible if you prefer to keep the next.17 shapes.

Inventory check against every --json command on this next (CLI spec vs JSON_COMMAND_SHAPES, after the merge):

Outputs on next that do not follow the envelope + string-schema rule (not changed here; recommended follow-up: a string data.schema inside the envelope for each unpublished one):

Ran locally on 4e55382 (db01be6 adds only a comment fix), Linux, Bun 1.4.4, temp HOME, HACK_DAEMON_AUTOSTART_DISABLE=1: tests/machine-output-contract.test.ts 87 pass, success-shapes 10, tests/sync-spawn-bound.test.ts 2, native-plan-home 18, usage-by-service-cli + usage-details 8. Root typecheck and check; docs:prepare + docs:check. bun run build, build:config-compiler, check:native-plan-cli: all 8 scripts in the runner pass (the runner on this next lists 8, not nine). Desktop core cargo nextest run -p hack-desktop-core in an isolated HOME: 81 passed, 1 skipped.

Exact-head hosted CI (run 43684164738): 27 checks passed, including every Linux job (test shards 4–8, all 4 Docker e2e shards and fan-in, linux-process-lifetime, Candidate core and Config compiler on ubuntu x64/arm, Desktop app Linux, runtime models/images, docs, secret scan) and, on macOS, Candidate core, Config compiler and Desktop app. macOS test shards 1/8, 2/8, 3/8: queued, not waited for. Optional Proof skipped. GitHub reports mergeable. computer pr review-status: CLEAR at db01be6.

Review: persistent Codex reviewer CLEAN at this head (rounds 5–6 covered the merge, the env migrate and by-service decisions, the renderer change and the release notes; its one P3, a stale "unpublished" comment in the desktop parser, is fixed). Codex bot: no major issues and no security issues at db01be6.

Still open: the Mac batch and the Mac app's read-only state tool against real local state. No further pushes planned after this note. #831 is merged on top of this head.

@roodboi
roodboi merged commit 3d7563f into next Nov 15, 2026
31 checks passed
@roodboi
roodboi deleted the feat/hack-2238-json-contract branch November 15, 2026 07:34
roodboi added a commit that referenced this pull request Nov 15, 2026
…on (#831)

HACK-2218 R2: full and summary CLI project rows and hackd /v1/projects
share backend-aware state, readiness/completion, health, exit code and
start time. Native projects use authenticated observers; missing
evidence stays unknown. Completed declared jobs do not degrade running
peers; inactive absent profiles are excluded.

Depends on #835, ready head 58605b6.
Merge #835 first. Current next and that prerequisite are merged
normally. Plain projects JSON keeps its published shape; observe listing
uses the prerequisite schema envelope. Only R2's appendix row is edited.

Default --json --observe makes no engine/provider contact and bypasses
daemon/registration. --observe --runtime explicitly opts into runtime
reads. Changed and terminated cached Docker IDs are re-inspected on
event refreshes; unchanged running IDs stay query-free and omit fresh
health/start evidence. Native concurrency is four. Inspect fields
exclude env values, commands, error text and health logs.

![Shared state
projection](https://raw.githubusercontent.com/hack-dance/hack/feat/hack-2218-project-state/docs/reference/project-state.svg)

Validation: 165 focused tests pass in separate isolated processes,
including state/profile/health, native observations, runtime cache,
full/summary projection, non-contact observe and machine-output
contracts. CLI build, typecheck, root check/privacy, documentation
checks and regenerated CLI reference pass. Exact-head persistent review
and hosted CI pending. The prerequisite passed desktop core on
Linux/macOS; R2 changes no desktop code.

Live Docker probe: task-owned containers with and without health checks
retain state and mounted-volume ownership; disposable-volume
verification succeeds. The inspect template safely handles absent health
keys. The cache-prune scenario explicitly disables its health check to
guard that path; its full hosted rerun is pending.

Limits: no live hackd, native provider or real Mac state-tool run
locally. Compose-format projects follow the observing process backend
selection, including hackd environment; Compose observations do not
establish native state. Native timestamps remain null, and native rows
describe the base instance. Lead owns Mac qualification and merge.

---------

Co-authored-by: Kit <344842+roodboi@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
roodboi added a commit that referenced this pull request Nov 15, 2026
…econcile

Brings in next at 345dc0d, including the shared JSON envelope rule and command inventory (#835) and shared service state (#831).

Conflict: only the generated plugins/hack/skills/hack-diagnose/references/error-codes.md (content revision line). Regenerated with bun run generate:agent-plugins: next's rows plus E_DAEMON_SERVICE.

Adapted to #835: hack daemon start|stop|restart|install --json are recorded as schema-envelope in the JSON inventory, and their schemas are registered in MACHINE_SCHEMAS. The envelope was already #835's shape (exactly ok and data, schema inside data, E_DAEMON_SERVICE errors with detail), so only the schema id changes from hack.daemon-<command>/v1 to the registry's dotted form hack.daemon-<command>.v1. The post-update parser uses the same constant. Regenerated docs/reference/machine-readable-output.md; the CLI reference had no diff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
roodboi added a commit that referenced this pull request Nov 15, 2026
…autostart --json

Follow the machine-readable output rule from #835 for these new commands:
`hack autostart add|list|pause|remove|resume|run --json` now return
`{ ok, data: { schema: "hack.autostart.v1", action, ... } }`; `list` no longer
prints a bare object. The commands are added to the JSON inventory and the
generated reference table. `projects --json` keeps its legacy shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
roodboi added a commit that referenced this pull request Nov 15, 2026
# Conflicts:
#	apps/desktop/core/src/source.rs
roodboi added a commit that referenced this pull request Nov 15, 2026
… setup

# Conflicts:
#	apps/desktop/core/tests/dump_state.rs
roodboi added a commit that referenced this pull request Nov 15, 2026
# Conflicts:
#	apps/desktop/core/src/runner.rs
roodboi added a commit that referenced this pull request Nov 15, 2026
…hape

#835's success-shape test pins the legacy top-level keys of plain
`projects --json`. This branch intentionally adds the machine-wide
`autostart_global` object there (documented in always-on-projects), so add
it to the pinned key set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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