feat: fx capability ports (issue, usage, session migrate, --record) - #222
Merged
Conversation
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.
…on migrate parity)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports four fx (
vercel-labs/fx) capabilities to hawk, each committed separately:issue—hawk issueGitHub issue draft command (0b5b377)usage—hawk usage [--period] [--json]local LLM token/spend ledger (7e7a562)session migrate—hawk sessions migratecurrent-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 vetclean,golangci-lint0 issues,~/go/bin/hawk verifypasses.