npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@civaapple/qi-kernel

v0.5.1

Published

Deterministic Qi Session state machine, replay, and EventStore port

Readme

@civaapple/qi-kernel

The deterministic state machine that validates and projects Qi's append-only Session history.

Purpose

The Kernel turns a validated event sequence into SessionView. It defines legal lifecycle transitions and the minimal EventStore port used by loops, evaluators, streams, and durable adapters.

Non-goals

  • It never calls models, tools, external systems, or user interfaces.
  • It does not authorize actions or infer missing events.
  • A projection is not a second source of truth and is never mutated directly.

Core model

applySessionEvent() applies one fact to a projection; replaySession() reconstructs the same view from the complete history. Runs contain Steps and Actions, while goals, evidence, evaluations, memory, control receipts, Session mode, Plan revisions/reviews, and pending control Questions remain related first-class views. ProcessTasks are Session-scoped views linked back to their originating Run/Step/Action, so their lifetime may outlast a completed Run without making that Run unsettled.

Behavioral invariants

  • A Session stream cannot be aliased to a different Session ID.
  • Authority and action start are durable before execution.
  • Action terminal meanings remain distinct, including indeterminate settlement.
  • A Run cannot terminate while an Action settlement is unknown.
  • Verified completion rejects missing or untrusted evidence.
  • Terminal Run outcomes are mutually exclusive.
  • Value-free safety audit events replay deterministically without becoming mutable domain state.
  • Context compaction can reference only a completed source Step, must reduce estimated cost, and remains visible on the current Step projection.
  • A ProcessTask can start only from a running authorized Action; stop, exit, and lost ownership are distinct, validated transitions.
  • Mode changes are rejected while a top-level Run is active or a Plan review / control Question is pending; Ask and Plan Runs deny tools/effects outside their mode allowlists; Plan-bound Agent Runs require an accepted revision and bind at most one Plan item.

Failure semantics

Illegal transitions throw StateTransitionError. Stale optimistic writes throw ConcurrencyError. The Kernel does not repair or skip invalid history; recovery must add explicit events through an authorized supervisor.

Install and minimal use

npm install @civaapple/qi-kernel @civaapple/qi-protocol
import { InMemoryEventStore } from "@civaapple/qi-kernel";
import { createId } from "@civaapple/qi-protocol";

const stream = new InMemoryEventStore().read(createId("ses"));

Public API

The stable surface is applySessionEvent(), replaySession(), projection view types, EventStore, InMemoryEventStore, domain errors, and the KERNEL_ASK_MODE_TOOLS / KERNEL_PLAN_MODE_EXTRA_TOOLS hard-gate allowlists. The allowlists are exported so cross-package verification can prove that Kernel replay and capability policy accept the same Ask/Plan tool names; they do not grant authority.

Change guide

Update event schema first, then transition rules and replay tests. Any new terminal or recovery state must be handled exhaustively in all projections and downstream control surfaces.

Verification

Use tests/slice0.test.mjs for transition invariants and tests/sqlite-store.test.mjs for persistence parity.

Further reading