Skip to content

hoist gather/pull semantics into ghost-core for embedded consumers#220

Closed
nahiyankhan wants to merge 1 commit into
mainfrom
embedded-consumer-contract
Closed

hoist gather/pull semantics into ghost-core for embedded consumers#220
nahiyankhan wants to merge 1 commit into
mainfrom
embedded-consumer-contract

Conversation

@nahiyankhan

Copy link
Copy Markdown
Collaborator

Category: new-feature
User Impact: Hosts that embed Ghost as a library can now consume gather/pull semantics directly instead of re-implementing CLI behavior.
Problem: Governed hosts (UI-generation servers, review-orchestration services) that embed Ghost had to mirror command code to reproduce the wild-posture gate, steering order, and event shapes, risking drift from the CLI's load-bearing semantics.
Solution: Hoist those semantics into ghost-core as pure functions (buildGatherMenu, orderPulledNodes, steeringBucket), export observability event types and stampGhostEvent from ./fingerprint, and document the embedded-consumer contract so the CLI becomes one transport for the semantics rather than their source of truth.

Validation:

  • pnpm build: pass
  • pnpm test: 154 passed, 1 skipped (16 files)
  • pnpm check: pass (biome, typecheck, file-size, terminology, CLI manifest in sync)

Changeset: added (.changeset/embedded-consumer-contract.md, minor)

Ghost Review:

  • ghost check / ghost review: not run because this repo has no root .ghost/ fingerprint package (ghost validate reports manifest.yml missing).
File changes

.changeset/embedded-consumer-contract.md
Minor changeset describing the new library surface.

docs/embedded-consumers.md
New contract page naming which behaviors are semantics every consumer must honor (wild-posture gate, steering order, checks-as-review-only, index front door, skeleton extraction) vs. CLI presentation, with a minimal consumption sketch and a "must not" list.

packages/ghost/package.json
#ghost-core / #scan import types conditions now point at shipped dist/ declarations instead of unshipped src/, so embedders get types from the packed artifact.

packages/ghost/src/ghost-core/catalog/menu.ts
Adds buildGatherMenu(catalog, { includeWild }) returning { entries, wildAvailable, wildIncluded } — the gather menu semantics as a pure function.

packages/ghost/src/ghost-core/catalog/steering.ts
New home for orderPulledNodes / steeringBucket (index → concrete → steady/wild → guard, stable within bucket), hoisted out of the pull command.

packages/ghost/src/ghost-core/catalog/index.ts, packages/ghost/src/ghost-core/index.ts
Re-export the new menu and steering functions and types from ghost-core.

packages/ghost/src/commands/gather-command.ts
CLI now consumes buildGatherMenu instead of computing wild counts and inclusion flags inline.

packages/ghost/src/commands/pull-command.ts
CLI now imports orderPulledNodes from ghost-core; local copies removed.

packages/ghost/src/observability-events.ts
Doc comments clarifying that library consumers may construct these event shapes for their own telemetry but must never write into a fingerprint package directory.

packages/ghost/src/fingerprint.ts
Exports observability event types (GatherObservabilityEvent, PullObservabilityEvent, PullMiss, GhostObservabilityEvent, NewGhostObservabilityEvent), the pure stampGhostEvent helper, and LoadedCheck.

packages/ghost/test/ghost-core/catalog-menu.test.ts
Tests for buildGatherMenu semantics: wild gate, discoverability count, inclusion flag.

packages/ghost/test/observability-events.test.ts
Tests for stampGhostEvent and exported event shapes.

Screenshots/Demos: N/A

…host-core

Governed hosts embedding Ghost as a library (e.g. Summon) previously
mirrored CLI-internal behavior and drifted. Move the semantics down a
layer so embedders consume them instead of reimplementing them:

- buildGatherMenu(catalog, { includeWild }) in ghost-core returns
  { entries, wildAvailable, wildIncluded } — the gather menu with the
  wild-posture gate as a pure function; the gather command consumes it
- orderPulledNodes / steeringBucket (steering order: index → concrete →
  steady/wild → guard, stable within bucket) exported from ghost-core;
  the pull command consumes them
- observability event types + pure stampGhostEvent exported from
  ./fingerprint so embedders can record tape-shaped events in their own
  receipts without writing into a fingerprint package directory
- LoadedCheck exported from ./fingerprint
- #ghost-core / #scan types conditions repointed at shipped dist/
  declarations instead of unshipped src/
- docs/embedded-consumers.md: the contract page naming which behaviors
  are semantics every consumer must honor vs CLI presentation

CLI output is bit-identical; tests cover the new exports.
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