Skip to content

feat: fx capability ports (issue, usage, session migrate, --record) - #222

Merged
Patel230 merged 17 commits into
mainfrom
feat/dsh-harness-surface-replace-plan
Aug 21, 2026
Merged

feat: fx capability ports (issue, usage, session migrate, --record)#222
Patel230 merged 17 commits into
mainfrom
feat/dsh-harness-surface-replace-plan

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Ports four fx (vercel-labs/fx) capabilities to hawk, each committed separately:

  • issuehawk issue GitHub issue draft command (0b5b377)
  • usagehawk usage [--period] [--json] local LLM token/spend ledger (7e7a562)
  • session migratehawk sessions migrate current-format migration (5b3a7f1)
  • --record — live REPL output capture to an fxtape via --record <path> (5eb9074)

Plus a CI-gating fix: exempt the tape prompt-glyph matcher from the emoji audit (d87683e).

Verification: full go test ./... green, go vet clean, golangci-lint 0 issues, ~/go/bin/hawk verify passes.

Add the surface orchestration layer that was the remaining DSH port gap:
- FoldSurface: complete replay of a session log into model-visible surface
  nodes plus committed replacement history, enforcing DSH's provenance,
  replacement-range, seq-contiguity, and tool-result rewrite invariants.
- SurfaceManager: incremental, Log-bound fold with Nodes(),
  ReplaceGeneration() monotonic replacement counter, and ValidateNext() for
  atomic pre-flight admission without mutating committed state.
- surface_test.go ports DSH surface.spec.ts cases: provenance accepts and
  rejections, replacement range not-found and out-of-order, tool-result
  rewrite restrictions, surface ordering and splice examples, and
  incremental manager delta/generation/atomic-failure behavior.

Verified: go test ./internal/eventlog, go test ./..., go vet,
golangci-lint (0 issues), make ci guards, layer-import guard, hawk verify.
Port vercel-labs/fx TurnPermissionRecovery as a Go-native module so a
blocked/auto-denied high-risk action can only re-enter the approval screen
through its exact, non-guessable opaque permission_request_id. Generic model
or user text can never authorize, and the grant is single-use, consumed at
live revalidation of the exact call.

- internal/permissions/turnrecovery: domain-prefixed sha256 action/semantic
  ids, per-turn denied-call registry, preserved-outcome re-deny, remember/
  take-approval single-use consumption.
- internal/engine: PermissionService.EnableTurnRecovery + EscalatePermission
  wired into the high-risk approval gate; nil-by-default so existing behavior
  is unchanged.

Verified: go test (engine, engine/safety, turnrecovery), vet, golangci-lint,
go test -race.
Port vercel-labs/fx session_permission_state as a Go-native, session-scoped
exact-rule store where each rule carries a stable, monotonically increasing
id and generation (fx's RuleId). Unlike hawk's glob-based remembered rules,
these are addressable by id across workspace changes and can be listed and
revoked without re-deriving the rule from the current workspace. Optimistic
expected-generation checks preserve fx's applied/stale/full/invalid outcomes.

- internal/permissions/stableid: immutable State of exact rules
  (kind+sha256 identity digest), ApplySet/ApplyRevoke, Decide, Validate with
  fx's invariants (nonzero monotonic ids, id<=generation, max 1024 rules,
  digest/canonical match, no dup id/key).
- internal/permissions: StableRuleStore persisting the state next to
  permissions.json with Remember (stable id)/Revoke/List/Resolve/Load/Save.
- internal/engine: PermissionService.SetExactRuleStore + RememberExact/
  RevokeExact/ListExact; nil-by-default so existing behavior is unchanged.

Verified: go test (permissions, stableid, engine), vet, golangci-lint,
go test -race.
Port vercel-labs/fx's terminal capture/replay container
(src/core/workspace/record_tape.zig + src/core/cli/cli_replay.zig) Go-native.
The on-disk fxtape is byte-for-byte compatible with fx: an 18-byte header
(magic FXTP\x01, LE cols/rows, LE epoch_ms, version) plus frames of LE
delta_ms, kind (stdout/stdin/resize/sigint/marker), LE len, and payload.
Deltas are wall-clock, so the tape records output bytes, timing, resizes,
ctrl+c, and named markers exactly as the session produced them.

- internal/terminal/tape: Writer (records frames with timing deltas),
  Parse (validates magic/truncation), and a focused ANSI virtual-terminal
  Grid + ReplayTape that reconstruct visible output, honoring resizes and
  stripping SGR/clearing sequences.
- cmd/replay: hawk replay <tape> [--json|--frames|--golden] mirrors fx's
  flags; default prints the reconstructed transcript.

Verified: go test (tape incl. end-to-end record->file->replay smoke), vet,
golangci-lint, go test -race, and a built-binary CLI replay smoke.
@Patel230
Patel230 merged commit a9a7e6e into main Aug 21, 2026
26 checks passed
@Patel230
Patel230 deleted the feat/dsh-harness-surface-replace-plan branch August 21, 2026 12:38
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