Documentation
¶
Overview ¶
Package flowcorpus parses a curated flow corpus (corpus.jsonl) into CKV chunks. The corpus is the machine-loadable form of human-written flow docs: each record describes a step / flow / invariant in natural language (often Korean prose) tied to a precise file:line + symbol. Embedding that prose is the "human wording → exact code keyword" bridge — a Jira-style description ("수수료 위임이 어디서 검증되나?") retrieves the step that implements it.
Record types (one JSON object per line, discriminated by "type"):
flow → ChunkFlowSpine (embed = summary) step → ChunkFlowStep (embed = prose + symbol + branch conditions) invariant → ChunkInvariant (embed = statement + assumes + check; curated) edge → skipped (graph-only; step.calls already carries the relation)
Input contract: <go-stablenet>/.claude/docs/corpus/SCHEMA.md. Malformed or unknown records are counted and skipped with a warning (build_corpus.py is a best-effort markdown parser, so the caller should check the counts), never aborting the load.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlignSteps ¶
AlignSteps sets AlignedChunkID on every flow_step chunk to the code chunk whose [Start, End] range contains the step's line, and returns how many of the total flow steps resolved. When several code spans contain the line the tightest (smallest) one wins, so a step aligns to the innermost symbol rather than an enclosing block. A step whose line matches no span is left unaligned (the corpus drifted from the code) and simply not counted as resolved.
Types ¶
type CodeIndex ¶
CodeIndex maps a repo-relative file path to its code chunks' line spans.
type CodeSpan ¶
CodeSpan is a code chunk's line range and ID — the alignment target for a flow step. Built from the source chunks of one index (symbol / function-split kinds), keyed by file.
type Stats ¶
type Stats struct {
Flows int
Steps int
Invariants int
Edges int // counted but not chunked (graph-only)
Skipped int // malformed / unknown-type records
Warnings []string
}
Stats reports what Load produced, so the build can log counts and the caller can sanity-check against the source (e.g. expected flow/step/invariant totals).
func Load ¶
Load reads and parses the corpus file at path. corpusRel is the citation path stamped on fileless chunks (flow / invariant records carry no code location); steps cite their own file:line. corpusRel should be the corpus file's path relative to a docs root registered with the build so query-time citation enforcement can resolve it.