Skip to content

feat: register a CLI profile for running embedded engines - #9

Merged
abelanger5 merged 2 commits into
mainfrom
belanger/embedded-profile-registration
Sep 12, 2026
Merged

abelanger5 merged 2 commits into
mainfrom
belanger/embedded-profile-registration

Conversation

@abelanger5

Copy link
Copy Markdown
Contributor

Description

Creates an embedded profile in ~/.hatchet/profiles.yaml after embedded mode starts up, which can be used by other tools relying on CLI profiles (such as an MCP server, hatchet tui, etc).

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

Changes have been:

  • Tested (unit, integration, or manually with steps specified)
  • Linted and formatted
  • Documented (where applicable)
  • Added to CHANGELOG (where applicable) -- see Keep a Changelog

🤖 AI Disclosure
  • I acknowledge that an LLM was used in the creation of this Pull Request, in accordance with Hatchet's AI_POLICY.md.
  • Details: Claude w/ Fable 5.1

When the engine becomes ready, StartServer registers an embedded
profile in the CLI profile store (~/.hatchet/profiles.yaml, created if
absent) with the minted token and endpoints, plus metadata fields the
released CLI ignores (embedded, pid, cwd, startedat). Registration is
always attempted and never fails startup: write and permission errors
log a warning and continue. Graceful shutdown removes the entry only
when its token still matches this instance, so a newer engine's
registration survives. The user's default profile is never changed.

The writer honors the CLI's config lock protocol and profile file name
overrides, upserts via yaml.Node so other profiles, ordering, and
comments are preserved, and writes atomically. Timestamps must be
emitted as unquoted YAML timestamps because viper does not decode
quoted strings into time.Time; the upsert forces block style and a
regression test guards it. Registration is skipped under WithoutAPI
since such a profile would be unusable and unverifiable.

The sidecar inherits this through StartServer, so TypeScript and
Python embedded runs register identically with no SDK changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XHyfTNZGxYR249FURndHEX
@abelanger5
abelanger5 requested a review from mnafees September 9, 2026 18:40

@mnafees mnafees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense!

Replaces the duplicated profile-writing machinery (path resolution,
lock protocol, yaml.Node surgery, atomic writes, roughly 350 lines)
with the profilestore package the CLI itself now uses, so all writers
share one implementation. Registration upserts through
UpsertProfile with the embedded metadata fields, always including cwd
since upserts merge rather than replace, and deregistration uses
RemoveProfileIfTokenMatches. Store construction happens inside
register and deregister so failures stay best-effort warnings that
never fail engine startup. Tests are pruned to this repo's semantics;
format-fidelity coverage lives in the profilestore suite.

Verified live against the released v0.106.11 CLI: registration parses
and lists, comments survive, graceful shutdown removes the entry,
re-registration into an emptied file stays readable, and a killed
engine leaves a stale entry as designed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XHyfTNZGxYR249FURndHEX
@abelanger5
abelanger5 merged commit 9199b3e into main Sep 12, 2026
5 checks passed
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.

2 participants