compactionkernel

package
v1.0.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 8 Imported by: 0

Documentation

Overview

Package compactionkernel makes compaction survival a checkable property. A kernel is the smallest pinned statement of what governs a session: the tree revision, the governing authority files with their blob hashes, and an optional bounded list of requirement ids with their pinned spec blob hashes. It is rendered into a fenced envelope a host hook injects, and verified again out of whatever text survived compaction.

Claude Code's PreCompact hook should call `corvint kernel` and carry the rendered block into the compacted transcript; the following SessionStart(compact) hook should pipe that transcript into `corvint kernel verify`. A host that emits no compaction signal degrades to the session-start injection alone; nothing here depends on a host-specific compaction API.

Index

Constants

View Source
const (
	// Profile names this kernel's wire shape.
	Profile = "corvint-compaction-kernel/0"
	// MaxKernelBytes bounds the canonical JSON document, envelope excluded. The
	// kernel must stay small enough that no compaction budget can justify
	// dropping it (CKN-V0-002).
	MaxKernelBytes = 600
)

Variables

This section is empty.

Functions

func InjectionBlock

func InjectionBlock(index *contextindex.Index, governance []Entry) (string, error)

InjectionBlock is the orchestrator's entry point: the exact block the session-start and user-prompt adapter paths inject, with no requirement list.

func Render

func Render(kernel Kernel) string

Render produces the exact envelope a hook injects: a fenced block whose body is the marker, the canonical JSON on one line, and the closing marker.

Types

type Authority

type Authority struct {
	Authority string
	BlobHash  string
	Path      string
}

Authority is one governing file pinned to the blob the index read.

type Entry

type Entry struct {
	Authority string
	BlobHash  string
	Line      int
	Path      string
	Relation  string
}

Entry is one row of the harness governance array, in the shape the user-prompt packet already produces.

func GovernanceFromPacket

func GovernanceFromPacket(packet map[string]any) []Entry

GovernanceFromPacket converts the `governance` member of a harness packet into kernel entries, so no caller re-implements the authority selection the prompt compiler already made.

type Kernel

type Kernel struct {
	Authorities  []Authority
	Digest       string
	Omitted      int
	Requirements []Requirement
	Revision     string
}

Kernel is the compaction-survival statement itself.

func Build

func Build(index *contextindex.Index, governance []Entry, requirementIDs []string) (Kernel, error)

Build compiles the kernel for one index. governance is the harness governance array; requirementIDs is optional.

type Mismatch

type Mismatch struct {
	Actual   string `json:"actual"`
	Expected string `json:"expected"`
	Path     string `json:"path"`
	Reason   string `json:"reason"`
}

Mismatch names one specific way a recovered kernel no longer matches the repository. It never carries source content.

type Requirement

type Requirement struct {
	BlobHash string
	ID       string
	Line     int
	Path     string
}

Requirement binds a requirement id to the pinned blob of the spec that states it.

type Verdict

type Verdict struct {
	Digest     string     `json:"digest"`
	Mismatches []Mismatch `json:"mismatches"`
	Revision   string     `json:"revision"`
	State      string     `json:"state"`
}

Verdict is the result of checking recovered text against the current index.

func Verify

func Verify(text string, index *contextindex.Index) (Verdict, error)

Verify finds the envelope in arbitrary text -- a post-compaction summary, a transcript, a pasted note -- recomputes the digest, and checks every pinned blob hash against the current index.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL