archive

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package archive implements M8.3 (方案 §14.2): conservative archiving of the append-only JSONL streams — project events and run streams — to keep the working tree small without losing history.

Archive layout (all committed, all ordinary files):

.devsys/archive/events/<YYYY-MM>.jsonl   archived event shards
.devsys/archive/runs/<run-id>.jsonl      archived run streams
.devsys/archive/manifest.yaml            what moved, when, by whom

Reads merge live and archived state: events.Read covers both shard trees, readRunStream-equivalents fall back to the archived stream when the live one is gone. Search excludes archive/ (current-state retrieval only). There is deliberately no delete/purge shape: dropping archived history is a manual git operation (默认保守:不删,只归档).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlanEvents

func PlanEvents(root, beforeMonth string) ([]string, error)

PlanEvents lists the live event shards strictly older than beforeMonth (YYYY-MM, zero-padded so lexical order is chronological).

func PlanRuns

func PlanRuns(root string, ids []string) ([]string, error)

PlanRuns validates run IDs and requires every referenced run to be terminal: archiving a running stream would break round bookkeeping (nextRound/lastExit) and the dispatch stall sweep.

Types

type Entry

type Entry struct {
	Kind       string `json:"kind" yaml:"kind"` // "events" | "run_stream"
	Source     string `json:"source" yaml:"source"`
	SHA256     string `json:"sha256" yaml:"sha256"`
	Bytes      int64  `json:"bytes" yaml:"bytes"`
	Lines      int    `json:"lines" yaml:"lines"`
	ArchivedAt string `json:"archived_at" yaml:"archived_at"`
	ArchivedBy string `json:"archived_by" yaml:"archived_by"`
	Reason     string `json:"reason" yaml:"reason"`
}

Entry records one archived file: the pointer that keeps history queryable.

type Manifest

type Manifest struct {
	SchemaVersion int     `json:"schema_version" yaml:"schema_version"`
	Entries       []Entry `json:"entries" yaml:"entries"`
}

Manifest is the archive catalogue.

type Report

type Report struct {
	Archived      []string `json:"archived"`
	Skipped       []string `json:"skipped,omitempty"`
	BytesArchived int64    `json:"bytes_archived"`
	BytesBefore   int64    `json:"bytes_before"`
	BytesAfter    int64    `json:"bytes_after"`
	Manifest      Manifest `json:"manifest"`
	DryRun        bool     `json:"dry_run,omitempty"`
	Note          string   `json:"note,omitempty"`
}

Report is what an archive run moved.

func Apply

func Apply(ctx context.Context, root string, spec Spec) (Report, error)

Apply moves every source in spec into archive/ inside ONE storage transaction (read-copy-delete per file plus a single manifest rewrite), so an interruption replays to exactly one outcome. Manifest-only writes never happen: an empty plan is a no-op report.

type Spec

type Spec struct {
	// EventMonths lists live event shards (YYYY-MM) older than BeforeMonth.
	BeforeMonth string
	// RunIDs lists run streams to archive (each must be terminal).
	RunIDs []string
	Actor  string
	Reason string
	Now    time.Time
	DryRun bool
}

Spec selects what to archive.

Jump to

Keyboard shortcuts

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