FrankenTerm

Design Decisions Explained

972 words4 min read11 subsectionsFrom the README at ft 0.15.21

On this page11
Why SQLite, not Postgres / RocksDB / a custom store?Why asupersync, not tokio?Why forbid unsafe code in the CLI and core?Why TOON in addition to JSON?Why a Bloom prefilter in the pattern engine?Why a 1 MiB overlap window for delta extraction?Why prepare/commit/compensate for multi-pane ops?Why three scrollback tiers instead of two?Why fail-closed instead of fail-open for missing telemetry?Why reality-check + Sigstore attestation bundles?Why a vendored WezTerm fork instead of a thin wrapper?

This section catalogues the non-obvious design decisions the project has made, the choices a reasonable engineer might second-guess. For each, the rationale.

Why SQLite, not Postgres / RocksDB / a custom store?

  • SQLite is bundled (no system dep), runs in-process (no IPC overhead), and supports FTS5 + WAL out of the box.
  • Single-writer integrity is a deliberate constraint: only one watcher writes, and multiple readers are fine.
  • Backup is the SQLite online backup API: consistent snapshots without stop-the-world.
  • Versioned storage: schema migrations are versioned (current schema: 51; the live authority is storage/schema_ddl.rs::SCHEMA_VERSION); rollbacks are tracked in forensic_migration + rollback_execution.
  • Trade-off accepted: at fleet-of-thousands scale, write throughput would become a bottleneck. We're not there.

Why asupersync, not tokio?

  • Cx cancellation propagation is built into the runtime rather than retrofitted via CancellationToken. FrankenTerm still has to prove each operation's checkpoints, wakeups, side-effect boundary, and settlement behavior; propagation alone is not an end-to-end cancel-correctness proof.
  • Structured task ownership — explicit handles and JoinSet scopes make task lifetime and terminal acknowledgement auditable. The project verifies propagation and abort semantics at the wrapper boundary instead of claiming that a detached handle is impossible by construction.
  • Loom model for runtime_async is published as an attestation slot (proofs/loom-runtime-async).
  • The dual-runtime migration is done. Direct tokio use is banned and runtime_async is the supported first-party async API. Its implementation layer and explicitly audited integration seams may still name pinned asupersync types directly; those references are not evidence that every operation has completed its cancellation/ownership proof.

Why forbid unsafe code in the CLI and core?

  • Keep unsafe out of application logic. The CLI and core forbid unsafe code, and other crates inherit the workspace lint where applicable. Native/FFI exceptions remain subject to separate audits.
  • Native-API workarounds use std::process::Command (sysctl, ps, pgrep on macOS) rather than FFI.
  • Vendored WezTerm crates with unsafe are audited separately and tracked in docs/vendored-wezterm-design.md.
  • Trade-off accepted: some optimizations require unsafe and we don't take them. Performance work remains measurement-driven within safe Rust; current target-class input latency, resize/zoom responsiveness, and long-session scalability are not certified and must not be inferred from this safety policy.

Why TOON in addition to JSON?

  • Tokens cost money when responses are fed back to LLMs. TOON (Token-Optimized Object Notation) is a tree serialization optimized for low token count.
  • Savings depend on payload shape. The README intentionally avoids fixed percentages; substrate at docs/perf-ledger/toon-encoding.md.
  • JSON remains the default. TOON is opt-in via --format toon or FT_OUTPUT_FORMAT=toon.

Why a Bloom prefilter in the pattern engine?

  • Most chunks match zero rules. A 1 KB chunk of plain output rarely needs to be regex-evaluated against 100 patterns.
  • Bloom prefilter rejects in O(k) with k small (8 hashes typical). False positives gracefully fall through to AC + regex; false negatives are forbidden (the filter is built from rule anchors, so a chunk that could match always passes).
  • Result: 10–100× CPU reduction for typical rule packs.

Why a 1 MiB overlap window for delta extraction?

  • Scrollback capture is a sliding snapshot. Matching may need to reach through a large retained prefix after scrolling; a tiny fixed border turns ordinary polls into false gaps.
  • The window remains bounded. One MiB caps per-pane matching work and memory while covering realistic shifts in retained terminal history.
  • Misses stay explicit. A reset, clear, or shift beyond the bound produces a gap event instead of silently inventing continuity.

Why prepare/commit/compensate for multi-pane ops?

  • Multi-pane ops are distributed transactions whether you call them that or not.
  • Two-phase commit (prepare + commit) lets us validate every precondition before any side effect.
  • Compensation is per-step undo for the steps that did commit before the failure.
  • The idempotency ledger makes mid-flight crash recovery trivial: replay re-attempts only steps without receipts.
  • Trade-off accepted: tx contracts are more verbose than direct command scripts. The verbosity is the documentation of what could go wrong.

Why three scrollback tiers instead of two?

  • Hot/cold is the easy two-tier design. It also wastes RAM: a line accessed five minutes ago doesn't need to be in VecDeque, but it doesn't need to be evicted to SQLite either.
  • Warm (compressed in RAM) is the sweet spot for the 5-30 minute window: ~5× smaller than hot, but still in-process, decompressible on demand.
  • Cold (SQLite-backed) is the queryable safety net for everything older.
  • Benchmark-lane observation: the retained five-minute synthetic workload records a ~200 MB ceiling for 200 simulated panes with its declared tier boundaries. This is not evidence for native GUI/mux operation, a long-running production session, or the M4/M5/high-core target classes. The fail-closed swarm-capacity-envelope currently forbids promoting it to a high-scale memory guarantee.

Why fail-closed instead of fail-open for missing telemetry?

  • A swarm controller that doesn't know the state of the system must not pretend to know. Pretending is how you OOM the box at pane 87.
  • The cost of being wrong fail-open is silent damage. The cost of being wrong fail-closed is operator inconvenience.
  • The operator runbook is the recovery path. When the envelope denies admission because telemetry is missing, the runbook walks the operator through restoring the missing source.

Why reality-check + Sigstore attestation bundles?

  • The README makes load-bearing claims. Operators rely on those claims to make decisions.
  • Without verification, claims drift from reality. The substrate audit found dozens of is_safe() methods that returned true before any measurement was recorded; the README was making claims that the code couldn't back up.
  • Attestation bundles close the gap. Every claim links to an artifact slot, the artifact is hashed, and the bundle is signed. Operators can verify any release offline without trusting GitHub or any registry.

Why a vendored WezTerm fork instead of a thin wrapper?

  • Mux semantics aren't interchangeable across multiplexers. An abstraction that pretends they are produces a worst-of-all-worlds compromise.
  • Owning the dep graph lets us enforce the runtime ban (cargo-deny, RuntimeProof, forbid-unsafe).
  • Test/proof surfaces are easier on owned code.
  • Trade-off accepted: weekly upstream backports require manual work. The backport process is codified in AGENTS.md.