@console-one/sequence
v0.1.0
Published
Append-only behavioral type kernel. Types and values are the same continuum; mount a fact, see what's missing (gaps), fill gaps through compose, capabilities activate. One operation (mount), one data structure (Sequence), one protocol (ft text in/out).
Readme
@console-one/sequence
Append-only behavioral type kernel. Types and values are the same continuum — a value IS a maximally concrete type. Mount a typed fact, see what's missing (gaps), fill gaps through compose, capabilities activate. One operation (mount), one data structure (Sequence), one protocol (ft text in/out).
Install
npm install @console-one/sequenceQuick start
import { Sequence, FT } from '@console-one/sequence';
const seq = new Sequence();
seq.mount('schema', 'count', FT.number());
seq.mount('bind', 'count', 42);
seq.get('count'); // 42
seq.concreteness('count'); // 1 — value satisfies schemaCore API
Sequence— append-only block log with derived projection.mount()is the only write operation.FT.*— builder convenience API:FT.string(),FT.object({...}),FT.fn({...}),FT.segmented([...]), etc.createType— lower-level type constructor with full constraint vocabulary.compose— lattice meet.compose(a, b)returns the tightest type consistent with both.backwardInfer— given a required output, derive the required input.hoist/hoistForReader— emit projection as ft text, optionally scoped to a reader contract.receive— parse ft text into the sequence.loadEnv— boot a Sequence from a clock, snapshots, entries, and capability impls.rotate— lock-holder moves a range to a destination with a transparent redirect. The compression/federation/retention primitive.renderForReader— cluster → score → rank → budget → hoist pipeline.
Design invariants
- Types and values are the same continuum. A value is a maximally concrete type.
=overwrites,<<narrows. Ordered choice on unions.prevfor all self-reference. Prior value at same path, or prior element in array.- Behavioral predicates are refinement types.
- The "compiler" is the Sequence — parse → walk → mount; no separate compilation.
- Hoist output is valid ft input. Round-trippable.
- Mount → cascade (via backward index) → enforce admission → report changes.
- Kernel internals are values.
_deps.*,_rdeps.*,_caps,_blocks.*all readable viaget(). - Application features are type state, not kernel methods. Backlinks, indexes, ranking, sharding — all expressible as classes/capabilities mounted on the Sequence.
- Reader contracts separate kernel from renderer.
Source layout
src/
├── sequence.ts # kernel: append-only log, derived projection, cascade
├── type.ts # FieldType + constraint vocabulary
├── compose.ts # lattice meet, covers, backward inference, CDF, conjugate update
├── statement.ts # Statement/Block/MountEntry primitives
├── laws.ts # pre-mount admission laws (law({admission: true, check}))
├── builder.ts # FT.* convenience API
├── hoist.ts # emit projection as ft text
├── env.ts # loadEnv — boot with clock, snapshots, impls
├── rotation.ts # rotate(seq, {source, destination, author}) primitive
├── dsl/ # tokenize → parse → walk → mount
├── runtime/
│ └── render.ts # cluster → score → rank → budget → hoist
└── test/ # 623 tests across 38 suitesSpecs
See specs/docs/ for the full architecture and invariant documentation:
ARCHITECTURE.md— overviewKERNEL_BOOT.md— boot contractDSL_REQUIREMENTS.md— DSL specificationNARRATIVE_IS_TOOL.md— the unification statement
Development
npm install
npm run build # tsc
npm test # jest
npm run lint # tsc --noEmitGit hooks
Hooks are tracked under .githooks/. Enable after cloning:
git config core.hooksPath .githooks- pre-commit:
tsc --noEmit - pre-push:
jest
License
MIT
