# MANIFEST: CsvStat
updated:     2026-10-25T05:23:25+00:00
state:       approved
blocks:      6

applied_specs: |
  ARCHITECTURE.md sha256=e12f94e5c90e8e9b4581c3d4e02add14222bb76448d04c486ee6d71e88a43bf6 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-1 applied_at=2026-10-25T05:32:30+00:00 build_sha256=3ef1b4f5ec2346d1696a152a5785f6a3727ca2527d46e7912c23d1d3bf5840f8
  ARCHITECTURE_compact.md sha256=7cfe515f9a57eff34b031e503fa114c640a1bd985c53bba108277ff174501356 commit=d1e82352c53afe7a38120978eef3cca7db4abcbc applied_by=block-5 applied_at=2026-10-25T05:59:27+00:00 build_sha256=7cfe515f9a57eff34b031e503fa114c640a1bd985c53bba108277ff174501356
  FEATURE-Arguments.md sha256=9a953f3bc7cea1d5d09ee74930eab235304c0c2cce1b56415ae02a85b0a85633 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=050ca136fb647afe9772d8a7bbd7efd28f5d0ff2b7d42fe9018370bc2c4205c2
  FEATURE-BooleanTextTypes.md sha256=99d5d9e9678ded2142bb56301acb85a36eb03c8257a973e5d3880165ea0353fc commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=b600d239798a96e10c3b3ab34cd2cb96837b64d3a4be94050918d0861ff71829
  FEATURE-ColumnProfile.md sha256=f22a1f086a66d407ec5d7aeb466f02c03727d79a8182a025a7c46ce99e333728 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-4 applied_at=2026-10-25T05:54:33+00:00 build_sha256=d676eae762df7a958e64696e9fb5d63d05351abc792985d0245b75cdb2d16949
  FEATURE-CsvReading.md sha256=71d95738575ab19b3deb8dc6e0b1c851898e4366d4643d02ca1ba45e8122ba5e commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=73f3b2b6a8f863a34e0a1d8b07d9c475794548780288dc00bbcccff6ece5e237
  FEATURE-DateType.md sha256=44aa097f757fa79e16249e524a4b64e0d8ed49a36056de7fc783060f7818c695 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=f4e2c6c2e8cdb8beaaafbf424f62c9d2cef5e868a762e30f5b2e33058577385d
  FEATURE-DecimalFormat.md sha256=109c0508d8abeeb49b1ed3343b85198184a4d8285c00123967a35401dcc420d2 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-3 applied_at=2026-10-25T05:47:23+00:00 build_sha256=187b3802af97252f817ad67deef5f95b5cd7c1acb4ae39ccc3b1c6076546ff46
  FEATURE-Executable.md sha256=59259545271cfe01a39df84ddc49b5dc74cdad084bc0204f885d93e3f8fedd64 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=0cef168b5ed9451342f94dd738f47850aed44505586728a613d956f81f066467
  FEATURE-FailureDiagnostics.md sha256=de12d876e427503a0498c8a36753e2cee77059e4647e2f63ec3a07b7b89ad177 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-4 applied_at=2026-10-25T05:54:33+00:00 build_sha256=bfda77e8b09b145df7d6366c19495cf1c30a9c28794602aeac4b0d97f7c67450
  FEATURE-FreqCount.md sha256=1f7104b9cee064d941af8db099fb686c7b3cfa2b6c5960060a9ba370e23abd9b commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-3 applied_at=2026-10-25T05:47:23+00:00 build_sha256=e37a7fe43670706ba775490da7b3347e3a4c2e912556fd77d41fc8d81f8fd488
  FEATURE-FreqLimit.md sha256=bb241d5e6e51728130ef0566fd9e2637271d0d96e5e2530600e15de37e6474f6 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-3 applied_at=2026-10-25T05:47:23+00:00 build_sha256=1c892b2436284fed50270f1a3be5d539e89cafd83b5456d68dd56f048011ec9c
  FEATURE-FreqMode.md sha256=b963091cedf7c073e18d2fd57ce10028f1860e1be7137a520a684d33b8c750a2 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-4 applied_at=2026-10-25T05:54:33+00:00 build_sha256=6ccd7343e3f42781d0ec51029f29b20090ed8ea2e08defe28e35796dd5434d73
  FEATURE-InputRejection.md sha256=d4482d2d5ab4f3f5e0ca46192fa2016b8f066f142603a827925623f692a87572 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=b5d11403b9b3a0367ac2d4bb0c7188a1764bed592d18d6b8779cbb3c2bc2bedc
  FEATURE-Median.md sha256=224ab7e008018a11e1c0ec4ca4c7b9c0c23f09325db2c231f86251852645fe23 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-3 applied_at=2026-10-25T05:47:23+00:00 build_sha256=8c314bc51abe8e8fe589279f2387e25af613b553a5d34b6d7a7eb0dbf642ae54
  FEATURE-MinMax.md sha256=9bb09a367200cedddc7dfcbd1ce40aa4162397965993c1f4e4d1258f59fb37d9 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-3 applied_at=2026-10-25T05:47:23+00:00 build_sha256=d745bb41b7e62ced9837eb7c92d4be96265987eee298b1a5289da79f6bffdcb3
  FEATURE-NullValues.md sha256=6c396e64753ed2a4380ea4a7ab6c6f5fed6a8a93939a526be9665b0a12b5d2f8 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=507bdf7d5d89216fa58c6a3939d0b4fd6445019097f046e1ce1cea0044268ecb
  FEATURE-NumericTypes.md sha256=d1f6d599a6e5a99be40b6643e8418dc043f1bbd73a65350287c76006431bc200 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=6a097d7af89e9a968a5db8bb9c13ba6aa5b042abd65931b92334e2af968a47ff
  FEATURE-ProfileOutput.md sha256=53ada49722304e16ad8f871161f474ce1b6cf33de48c73e9b6a1026eb600b26f commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-3 applied_at=2026-10-25T05:47:23+00:00 build_sha256=9abfe9d7a667b4571f509280aa1530d36ba4ac86950eab763c6bffc3f71212df
  FEATURE-RowCounts.md sha256=8464549c0bb1d22b7d07a655f60be7e4dce548a389709d33d5eacd350d4b07b1 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-3 applied_at=2026-10-25T05:47:23+00:00 build_sha256=d20f96c2f91875503a7936fde9dd89ed4bcd9b886a2187a5c1eba26510979443
  FEATURE-SumMean.md sha256=32216f91f19592c5cd59a19cf06f6e1bad94ebb5096db597e77b676c3b890656 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-3 applied_at=2026-10-25T05:47:23+00:00 build_sha256=42a7e29da62b50b5877b6baf51885934fd321e001113575d2a8a13cd920560df
  FEATURE-TestGate.md sha256=6406879939a6153b5a4e476ecf1e8aa83162a2b56ee23711b542b955faf8cfc0 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-5 applied_at=2026-10-25T05:59:27+00:00 build_sha256=c666c70aef0e05e0c48ddc9820dc8379e754bb125826e77a9baf77bd710f99d9
  FEATURE-Trimming.md sha256=934339d983dbe8db155f319ed7be59bb593aeefbff95b6f0616faf8b9ef981f0 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-2 applied_at=2026-10-25T05:38:06+00:00 build_sha256=9bb09a47a961bd020b0efaaa1f022937478bfd842be907988e90a9266d558e68
  FEATURE-UnreadableFile.md sha256=295ba43f8d54cb5e1194a2cef34bce8dbf1f9d42c77a1bae77b1c7d12ed24356 commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-4 applied_at=2026-10-25T05:54:33+00:00 build_sha256=22036426426c277e1e37ff6a70f80b547a2cd823a48ec07fb41f06c764d94d35
  FEATURE-UsageErrors.md sha256=39441830f6f6f9f080e230ce4c98feacea338ddc1fd3900c53f6ac21083bbd2e commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-4 applied_at=2026-10-25T05:54:33+00:00 build_sha256=ba384e7a765bd22e80aacd3f999408dacdf729ba95e0add4006cb76e865af12c
  VERIFICATION.md sha256=1012f095f2c4698eb266878c0fc3909a9bce812c97324ce4d88268d848122c7f commit=3b0637857d05da82743ee9ebd84dee45843b67ab applied_by=block-6 applied_at=2026-10-25T06:03:54+00:00 build_sha256=3c6fbbdb6543c1fc10f5222db2c1e20d7de44195cb62e711deb76dfd6f5bee14
## story 1: Stand up the Go module, directory layout, and architecture for csvstat.
id:           foundation
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-1.md
summary:      Stand up the Go module, directory layout, and architecture for csvstat.
type:         foundational
kind:         capability
phase:        1
block:        1
implements:   ARCHITECTURE.md
instructions: |
  Create the root go.mod (module path csvstat, Go 1.22 or newer, no third-party requires) and the
  layout: cmd/csvstat (package main), internal/cli, internal/csvdata, internal/profile,
  internal/freq, bin/.

  Document in ARCHITECTURE.md the package ownership, the Run(args []string, stdout, stderr
  io.Writer) int entry contract, the exit-code table (0, 1, 2, 3), and the rule that only main calls
  os.Exit. State that sources/ is read-only and that application code never reads sources/run.sh
  or embeds an answer.
stack:        common.md, go.md
stack_mode:   builder
size:         13321
provides:     go.mod, internal/, cmd/csvstat/, bin/
acceptance:   yes
state: closed/implemented

## story 2: Build the csvstat executable from the module root with a thin main over cli.Run.
id: executable
finding: ADVISORY: implemented, not verified — every binding criterion this story passed was already green before the story built, so none measured the work. Repair the criteria in the Blueprint to exercise this story and rebuild to obtain a verdict.
evidence: evidence/block-2.md
summary: Build the csvstat executable from the module root with a thin main over cli.Run.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-Executable.md
covers: FOUND-001
accepts: st-003
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6480
provides: csvstat command, cli.Run
instructions: |
  Implement cmd/csvstat/main.go, which calls cli.Run(os.Args[1:], os.Stdout, os.Stderr) and passes
  the result to os.Exit. Implement a minimal internal/cli.Run that returns 0 so the module builds
  with go build ./cmd/csvstat using only the standard library.
acceptance: yes
depends: foundation
state: closed/implemented

## story 3: Read UTF-8 RFC 4180 CSV with the first record as header.
id: csv-reading
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-2.md
summary: Read UTF-8 RFC 4180 CSV with the first record as header.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-CsvReading.md
covers: INGEST-001
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6936
provides: csvdata.Read
instructions: |
  In internal/csvdata, read a file with encoding/csv (FieldsPerRecord = -1 so raggedness is judged
  by this package, LazyQuotes off). Return header and data records. A quoted field containing a
  comma is one value. A line ending after the last record creates no extra record. Record the source
  line number of each record for diagnostics.
acceptance: yes
depends: foundation
state: closed/implemented

## story 4: Trim leading and trailing spaces from every header name and value.
id: value-trimming
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-2.md
summary: Trim leading and trailing spaces from every header name and value.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-Trimming.md
covers: INGEST-002
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6439
provides: csvdata trimming
instructions: |
  After reading, trim spaces from every header name and every value before any other rule applies.
  Trim spaces only (not other whitespace classes beyond what the source states).
acceptance: yes
depends: csv-reading
state: closed/implemented

## story 5: Recognise null spellings: empty, NA, N/A, NULL ignoring case.
id: null-values
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-2.md
summary: Recognise null spellings: empty, NA, N/A, NULL ignoring case.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-NullValues.md
covers: INGEST-003
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6439
provides: csvdata.IsNull
instructions: |
  Implement IsNull on a trimmed value. A quoted empty field is empty and null. A value of only
  spaces becomes empty after trimming and is null.
acceptance: yes
depends: value-trimming
state: closed/implemented

## story 6: Infer integer and number column types.
id: numeric-types
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-2.md
summary: Infer integer and number column types.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-NumericTypes.md
covers: TYPE-001
accepts: st-004
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6588
provides: profile.InferType (integer, number)
instructions: |
  In internal/profile, a column is integer when every non-null value matches -?[0-9]+, and number
  when every non-null value matches -?[0-9]+(\.[0-9]+)?. Integer is tested first. Use anchored
  regular expressions or hand-written scanners; no float parsing for classification.
acceptance: yes
depends: null-values
state: closed/implemented

## story 7: Infer date columns of real YYYY-MM-DD calendar dates.
id: date-type
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-2.md
summary: Infer date columns of real YYYY-MM-DD calendar dates.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-DateType.md
covers: TYPE-002
accepts: st-004
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6425
provides: profile.InferType (date)
instructions: |
  A column is date when every non-null value matches YYYY-MM-DD and is a real calendar date
  (2025-02-30 is not). Validate with time.Parse using layout 2006-01-02 plus a digit-shape check.
acceptance: yes
depends: numeric-types
state: closed/implemented

## story 8: Infer boolean, text, and empty column types.
id: boolean-text-types
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-2.md
summary: Infer boolean, text, and empty column types.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-BooleanTextTypes.md
covers: TYPE-003
accepts: st-004
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6663
provides: profile.InferType (boolean, text, empty)
instructions: |
  Boolean when every non-null value equals true or false ignoring case. Text is the fallback. A
  column with no non-null value is empty. The full order is integer, number, date, boolean, text.
acceptance: yes
depends: date-type
state: closed/implemented

## story 9: Parse options and exactly one file argument, with options preceding the file.
id: args-parsing
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-2.md
summary: Parse options and exactly one file argument, with options preceding the file.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-Arguments.md
covers: CLI-001
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 7452
provides: cli.ParseArgs
consumes: cli.Run
instructions: |
  In internal/cli, parse args with a local flag.FlagSet using flag.ContinueOnError and output
  discarded. Recognise --column <name>, --freq <name>, --top <n>, then exactly one positional file.
  Return a typed Options value (Column, Freq, Top, TopSet, File) or a usage error. Validation of
  combinations belongs to the usage-errors story.
acceptance: yes
depends: executable
state: closed/implemented

## story 10: Reject empty files, empty or repeated header names, and ragged records.
id: input-rejection
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-2.md
summary: Reject empty files, empty or repeated header names, and ragged records.
type: service
kind: capability
phase: 1
block: 2
implements: FEATURE-InputRejection.md
covers: INGEST-004
accepts: st-007
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 7622
provides: csvdata.ErrRejected
instructions: |
  Return a rejection error (carrying the line number for a ragged record) for: an empty file, a
  file with only blank lines, an empty header name, a repeated header name, or any record whose
  field count differs from the header. A header-only file is valid and has zero rows. The cli layer
  maps this error to exit 3.
acceptance: yes
depends: value-trimming
state: closed/implemented

## story 11: Report rows, nulls, and distinct counts per column.
id: row-counts
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-3.md
summary: Report rows, nulls, and distinct counts per column.
type: service
kind: capability
phase: 2
block: 3
implements: FEATURE-RowCounts.md
covers: STAT-001
accepts: st-005
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6483
provides: profile.Counts
instructions: |
  rows is the data record count, nulls the null value count, distinct the number of different
  trimmed non-null strings compared exactly. A header-only file yields rows 0 for every column.
acceptance: yes
depends: null-values, input-rejection
state: closed/implemented

## story 12: Compute exact sum and mean for integer and number columns.
id: sum-mean
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-3.md
summary: Compute exact sum and mean for integer and number columns.
type: service
kind: capability
phase: 2
block: 3
implements: FEATURE-SumMean.md
covers: STAT-003
accepts: st-005
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6600
provides: profile.SumMean
instructions: |
  Use math/big (big.Rat) for exact arithmetic. Sum is the exact total of non-null values; mean is
  the total divided by the non-null count. Other types have no sum or mean. Keep exact values for
  the formatting story to round once at output time.
acceptance: yes
depends: boolean-text-types
state: closed/implemented

## story 13: Compute the median for integer and number columns.
id: median
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-3.md
summary: Compute the median for integer and number columns.
type: service
kind: capability
phase: 2
block: 3
implements: FEATURE-Median.md
covers: STAT-004
accepts: st-005
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6454
provides: profile.Median
instructions: |
  Sort the non-null values exactly (big.Rat). With an odd count take the middle value; with an even
  count take the mean of the two middle values, exactly.
acceptance: yes
depends: sum-mean
state: closed/implemented

## story 14: Compute min and max by column type.
id: min-max
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-3.md
summary: Compute min and max by column type.
type: service
kind: capability
phase: 2
block: 3
implements: FEATURE-MinMax.md
covers: STAT-002
accepts: st-005
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 7254
provides: profile.MinMax
instructions: |
  integer and number: compare exactly (math/big), not as float64. date: earliest and latest.
  boolean: min is false if any value is false else true; max is true if any value is true else
  false; written lowercase regardless of input case. text: smallest and largest by byte value.
  empty: blank. A single non-null value is both min and max.
acceptance: yes
depends: boolean-text-types
state: closed/implemented

## story 15: Format decimal results to two places, rounded half away from zero once.
id: decimal-format
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-3.md
summary: Format decimal results to two places, rounded half away from zero once.
type: service
kind: capability
phase: 2
block: 3
implements: FEATURE-DecimalFormat.md
covers: STAT-005
accepts: st-005
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 7040
provides: profile.FormatDecimal
instructions: |
  Format a big.Rat with exactly two decimals, rounding half away from zero from the exact value,
  with a leading minus only when the rounded result is non-zero (no negative zero), and no
  thousands separator. Number min, max, sum, mean, and median and integer mean and median use it.
  Integer min, max, and sum are plain integers.
acceptance: yes
depends: min-max, sum-mean, median
state: closed/implemented

## story 16: Count and order distinct non-null values of a column.
id: freq-count
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-3.md
summary: Count and order distinct non-null values of a column.
type: service
kind: capability
phase: 2
block: 3
implements: FEATURE-FreqCount.md
covers: FREQ-001
accepts: st-006
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 7365
provides: freq.Count
instructions: |
  In internal/freq, count trimmed non-null values, order by count descending then value ascending
  by byte value, and write header value,count then rows. Nulls are omitted. A column with no
  non-null value writes only the header.
acceptance: yes
depends: null-values, input-rejection
state: closed/implemented

## story 17: Limit frequency rows with --top, default 5.
id: freq-limit
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-3.md
summary: Limit frequency rows with --top, default 5.
type: service
kind: capability
phase: 2
block: 3
implements: FEATURE-FreqLimit.md
covers: FREQ-002
accepts: st-006
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6804
provides: freq.Top
instructions: |
  Apply a row limit after ordering. Default is 5 when --top is not given. A limit larger than the
  distinct count lists all values.
acceptance: yes
depends: freq-count
state: closed/implemented

## story 18: Write the column profile as RFC 4180 CSV for the default invocation.
id: profile-output
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-3.md
summary: Write the column profile as RFC 4180 CSV for the default invocation.
type: service
kind: capability
phase: 2
block: 3
implements: FEATURE-ProfileOutput.md
covers: OUT-001
accepts: st-005
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 8019
provides: csvstat <file>
consumes: csvdata.Read, profile.InferType, profile.Counts, profile.FormatDecimal, cli.ParseArgs
instructions: |
  When neither --column nor --freq is given, write header column,type,rows,nulls,distinct,min,max,
  sum,mean,median and one row per column in file order using encoding/csv with \n line endings so
  fields containing commas, quotes, or newlines are quoted. Build the full output in memory and
  write to stdout only on success.
acceptance: yes
depends: decimal-format, row-counts, args-parsing
state: closed/implemented

## story 19: Reject malformed arguments with exit 2 and a usage line on standard error.
id: usage-errors
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-4.md
summary: Reject malformed arguments with exit 2 and a usage line on standard error.
type: service
kind: capability
phase: 3
block: 4
implements: FEATURE-UsageErrors.md
covers: CLI-004
accepts: st-008
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6621
provides: exit code 2
instructions: |
  Exit 2, with nothing on stdout, for: missing file, extra file, unknown option, missing option
  value, --top not a positive integer, --top without --freq, and --column with --freq. Write one
  stderr line showing both command forms.
acceptance: yes
depends: args-parsing
state: closed/implemented

## story 20: Profile a single named column with --column.
id: column-profile
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-4.md
summary: Profile a single named column with --column.
type: service
kind: capability
phase: 3
block: 4
implements: FEATURE-ColumnProfile.md
covers: CLI-002
accepts: st-007
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6931
provides: csvstat --column
instructions: |
  Write the profile header and only the named column's row. A column name absent from the trimmed
  header exits 3 with nothing on stdout. Match names exactly and case-sensitively.
acceptance: yes
depends: profile-output, usage-errors
state: closed/implemented

## story 21: Write one stderr diagnostic line and nothing on stdout when a command fails.
id: failure-diagnostics
finding: ADVISORY: implemented, not verified — every binding criterion this story passed was already green before the story built, so none measured the work. Repair the criteria in the Blueprint to exercise this story and rebuild to obtain a verdict.
evidence: evidence/block-4.md
summary: Write one stderr diagnostic line and nothing on stdout when a command fails.
type: service
kind: capability
phase: 3
block: 4
implements: FEATURE-FailureDiagnostics.md
covers: ERR-001
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 7188
provides: stderr diagnostics
instructions: |
  Failures write one stderr line naming the file and, for a ragged record, its line number. Stdout
  stays empty on every failure. Exit 3 for rejected input.
acceptance: yes
depends: input-rejection, usage-errors, profile-output
state: closed/implemented

## story 22: Exit 1 when the file cannot be opened or read.
id: unreadable-file
finding: ADVISORY: implemented, not verified — every binding criterion this story passed was already green before the story built, so none measured the work. Repair the criteria in the Blueprint to exercise this story and rebuild to obtain a verdict.
evidence: evidence/block-4.md
summary: Exit 1 when the file cannot be opened or read.
type: service
kind: capability
phase: 3
block: 4
implements: FEATURE-UnreadableFile.md
covers: ERR-002
accepts: st-008
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 6387
provides: exit code 1
instructions: A missing or unreadable file exits 1 with nothing on stdout and one stderr line naming the file.
acceptance: yes
depends: failure-diagnostics
state: closed/implemented

## story 23: Select frequency mode with --freq.
id: freq-mode
finding: ADVISORY: implemented, not verified — no governed acceptance command covers this story. Declare one in ACCEPTANCE.json to gate it.
evidence: evidence/block-4.md
summary: Select frequency mode with --freq.
type: service
kind: capability
phase: 3
block: 4
implements: FEATURE-FreqMode.md
covers: CLI-003
accepts: st-006, st-007
context: ARCHITECTURE_compact.md
stack: go.md
stack_mode: consumer
size: 7733
provides: csvstat --freq, csvstat --freq --top
instructions: |
  Dispatch to the frequency listing when --freq is given, honouring --top. A column name absent
  from the header exits 3 with nothing on stdout.
acceptance: yes
depends: freq-limit, usage-errors
state: closed/implemented

## story 24: Provide bin/test.sh running go vet and go test and the project test suite.
id: test-gate
finding: ADVISORY: implemented, not verified — every binding criterion this story passed was already green before the story built, so none measured the work. Repair the criteria in the Blueprint to exercise this story and rebuild to obtain a verdict.
evidence: evidence/block-5.md
summary: Provide bin/test.sh running go vet and go test and the project test suite.
type: service
kind: test harness
phase: 4
block: 5
implements: FEATURE-TestGate.md
covers: FOUND-002
accepts: st-002
context: ARCHITECTURE_compact.md
stack: common.md, go.md
stack_mode: consumer
size: 8164
provides: bin/test.sh
instructions: |
  Write a POSIX sh bin/test.sh that cds to the application root, runs go vet ./... then
  go test ./..., and exits non-zero if either fails. Ensure the suite covers each type, each
  statistic, null handling, rounding, each output form, and each exit code using files the tests
  write to temporary directories.
acceptance: yes
depends: column-profile, freq-mode, unreadable-file
state: closed/implemented

## story 25: Pass the supplied grader sources/run.sh with all 22 checks.
id:           release-verification
finding: ADVISORY: implemented, not verified — every binding criterion this story passed was already green before the story built, so none measured the work. Repair the criteria in the Blueprint to exercise this story and rebuild to obtain a verdict.
evidence: evidence/block-6.md
summary:      Pass the supplied grader sources/run.sh with all 22 checks.
type:         feature
kind:         test harness
phase:        4
block:        6
implements:   VERIFICATION.md
covers:       VERIFY-001
accepts:      st-001
instructions: |
  Assembly story. When every member story is closed, run the supplied grader unfiltered
  (Suite: full) and require exit 0. Repair any failure in the owning package, never in sources/.
stack:        common.md
stack_mode:   consumer
size:         5344
depends:      test-gate, column-profile, freq-mode, unreadable-file
acceptance:   yes
state: closed/implemented
