=== BEGIN ARTIFACT ANALYSIS.md === # Blueprint Analysis: CsvStat ## Commander Expectations - assert the CSV profiler builds as a standard-library Go CLI and passes every supplied conformance check. ## Crew | Crew | Charge | |---|---| | Commander | Defines intent and decides what done means. | | Team Lead | Confirms epic completeness and stakeholder expectations. | | Planning Crew | Authors atomic specifications and the ordered Manifest. | | Shipyard Crew | Builds the tickets without synchronous Commander access. | ## Story List ### Feature: CLI Foundation and Input Handling | ID | Story | High-level AC | |---|---|---| | CLI-001 | Build the csvstat command entry point | A Go module builds `./cmd/csvstat` as an executable using only the standard library, with command help text available for the supported invocation forms. | | CLI-002 | Read and validate CSV input | The command reads RFC 4180 CSV, trims headers and values, accepts quoted fields, and rejects empty files, invalid headers, and ragged records. | | CLI-003 | Resolve columns and null values | The command recognizes the specified null spellings and rejects absent named columns without writing standard output. | ### Feature: Column Profiling | ID | Story | High-level AC | |---|---|---| | PROFILE-001 | Infer column types | Each column is classified as integer, number, date, boolean, text, or empty according to the stated precedence and validation rules. | | PROFILE-002 | Calculate column statistics | Profile output reports rows, nulls, distinct values, min, max, numeric sum, mean, and median with the required formatting and ordering. | | PROFILE-003 | Render profile CSV output | Full-file and single-column profile commands emit the exact CSV header and row structure, including RFC-compliant quoting and empty fields. | ### Feature: Frequency Reporting | ID | Story | High-level AC | |---|---|---| | FREQ-001 | List frequent column values | `--freq` excludes nulls and orders values by descending count then bytewise ascending value. | | FREQ-002 | Apply frequency limits | `--top` accepts positive integers, defaults to five, and limits the frequency rows while preserving ordering. | ### Feature: Command Errors and Verification | ID | Story | High-level AC | |---|---|---| | CLI-004 | Map operational and usage failures | File, argument, and rejected-input failures return exit codes 1, 2, and 3 respectively and write nothing to standard output. | | TEST-001 | Provide the project test gate | `bin/test.sh` runs `go vet ./...` and `go test ./...`, succeeding only when both pass. | | VERIFY-001 | Pass the complete supplied conformance suite | The complete supplied `sources/run.sh` suite passes without filtering; acceptance declares `Suite: full`. | ## Surfaced Acceptance Criteria | ID | Story ID | Criterion | |---|---|---| | AC-001 | CLI-001 | The command shall provide help text covering the supported profile and frequency invocation forms. | | AC-002 | CLI-002 | The parser shall preserve quoted commas and apply trimming before null, type, and statistic evaluation. | | AC-003 | CLI-004 | A failing command shall write one diagnostic line to standard error naming the file and, for rejected records, the line number. | ## Relationship Model | Source or group | Relationship type | Related source or group | Evidence | Delivery implication | |---|---|---|---|---| | `sources/INSTRUCTIONS.md` | instruction-to-test | `sources/run.sh` | The instructions define the CLI, rules, outputs, and exit codes that the harness checks. | Implement the normative behavior before running conformance verification. | | `sources/run.sh` | test-kit-to-implementation | `./cmd/csvstat` | The harness builds the command and invokes all profile, frequency, rejection, operational, and usage cases. | Stage the harness and fixtures; terminal verification runs the full suite. | | `sources/*.csv` | fixture-to-verification | `sources/run.sh` | The harness reads the supplied employee, sensor, order, header-only, and ragged fixtures. | Preserve fixtures unchanged and make parser behavior data-driven. | | CSV parser | parser-to-normalizer | type and statistics engine | Values must be trimmed before null, type, comparison, and aggregation rules. | Establish normalization as the shared boundary for all downstream stories. | | CLI argument parser | dependency | profile and frequency commands | Options select distinct execution modes and invalid combinations have defined exit codes. | Complete argument validation before command dispatch. | ## Source Roles | Path | Role | Plan disposition | Build disposition | |---|---|---|---| | `sources/INSTRUCTIONS.md` | normative specification | context | prompt-only | | `sources/run.sh` | conformance test suite | context | stage | | `sources/employees.csv` | asset | context | stage | | `sources/sensors.csv` | asset | context | stage | | `sources/orders.csv` | asset | context | stage | | `sources/header_only.csv` | asset | context | stage | | `sources/ragged.csv` | asset | context | stage | ## Planning Instructions ### Delivery Shape A Go command-line pipeline accepts one CSV file and optional column, frequency, and top arguments. It parses and normalizes records, validates structure, infers column types, computes profiles or frequencies, writes CSV to standard output, and maps failures to defined exit codes. ### Story Realization Map | Story ID | Blueprint scope | Evidence | Related files | Delivery kind | |---|---|---|---|---| | CLI-001 | Go module and command entry point | `sources/INSTRUCTIONS.md` command and stack sections | `cmd/csvstat`, `go.mod` | capability | | CLI-002 | CSV parser and structural validation | `sources/INSTRUCTIONS.md` reading section | `sources/*.csv` | capability | | CLI-003 | normalization, nulls, and column lookup | `sources/INSTRUCTIONS.md` null and command sections | `sources/employees.csv`, `sources/orders.csv` | capability | | PROFILE-001 | type inference and date validation | `sources/INSTRUCTIONS.md` types section | `sources/employees.csv`, `sources/sensors.csv`, `sources/orders.csv` | capability | | PROFILE-002 | statistics and decimal formatting | `sources/INSTRUCTIONS.md` profile and decimals sections | all profile fixtures | capability | | PROFILE-003 | profile CSV rendering | `sources/INSTRUCTIONS.md` output section | `sources/run.sh` | capability | | FREQ-001 | frequency aggregation and ordering | `sources/INSTRUCTIONS.md` frequency section | `sources/run.sh` | capability | | FREQ-002 | top argument behavior | `sources/INSTRUCTIONS.md` command section | `sources/run.sh` | capability | | CLI-004 | diagnostics and exit-code mapping | `sources/INSTRUCTIONS.md` exit section | `sources/run.sh` | capability | | TEST-001 | local vet/test launcher | `sources/INSTRUCTIONS.md` tests section | `bin/test.sh` | test harness | | VERIFY-001 | complete supplied conformance execution | `sources/run.sh` | `sources/run.sh`, staged CSV fixtures | acceptance contract | ### Test and Acceptance Strategy Implementation stories use focused unit and command tests for parsing, normalization, inference, statistics, rendering, frequency ordering, and exit codes. `TEST-001` provides the local vet and test gate. `VERIFY-001` is the sole terminal story that runs the complete unfiltered supplied harness and declares `Suite: full`; all other validation remains scoped to the story capability. ### Sequencing and Dependencies Create the Go module and command entry point first. Implement CSV parsing and normalization before inference and aggregation. Implement profile and frequency renderers after their calculations. Add error mapping around all command paths. Run focused tests and `bin/test.sh` before the final full `sources/run.sh` verification. The supplied harness and all fixtures must be staged before terminal verification. ### Source Conflicts and Gaps No unresolved source conflicts or blockers. The CLI help wording is not specified, so the command story carries the derived requirement to expose help for the documented invocation forms. ## Analysis Notes generated: 2026-10-23 blueprint: /mnt/c/Users/barlo/projects/drydock/uat/CsvStat/runs/20261023.222823/workspace/targets/CsvStat/blueprint Quality: Ready blockers: 0 questions: 0 features: 4 stories: 11 stack: Go 1.22+, standard library, POSIX shell display_name: not proposed short_description: not proposed Project type: cli. No blockers or open Commander questions remain. === END ARTIFACT === === BEGIN ARTIFACT SEA_TRIALS.md === # Sea Trials: CsvStat ## st-001: Supplied grader passes Type: technical Required: yes Criterion: The completed csvstat shall make `sh sources/run.sh` exit zero. Verification: proof Command: ["sh", "sources/run.sh"] Pattern: ubiquitous ## st-002: Test suite passes Type: technical Required: yes Criterion: The application shall provide a POSIX-compatible `bin/test.sh` that exits zero when go vet and every automated test pass. Verification: proof Command: ["sh", "bin/test.sh"] Pattern: ubiquitous ## st-003: Executable builds with go build Type: technical Required: yes Criterion: The application root shall be a Go module from which `go build ./cmd/csvstat` produces the csvstat executable using only the standard library. Verification: proof Command: ["go", "build", "./cmd/csvstat"] Pattern: ubiquitous ## st-004: Column types are inferred Type: behavioral Required: yes Criterion: The application shall assign each column the first of integer, number, date, boolean, and text that every non-null value satisfies, and empty when it has no non-null value. Verification: proof Pattern: ubiquitous ## st-005: Profiles match the known answers Type: behavioral Required: yes Criterion: The application shall compute rows, nulls, distinct, min, max, sum, mean, and median for every column of the supplied data files, matching the known answers in `sources/run.sh` byte for byte. Verification: proof Pattern: ubiquitous ## st-006: Frequencies are ordered and limited Type: behavioral Required: yes Criterion: When `--freq` is given, the application shall list the column's non-null values by count descending then value ascending, at most `--top` rows. Verification: proof Pattern: event ## st-007: Malformed input is rejected Type: behavioral Required: yes Criterion: If the file is empty, has an empty or repeated header name, has a ragged record, or a named column is absent, then the application shall exit 3 and write nothing to standard output. Verification: proof Pattern: unwanted ## st-008: Errors map to exit codes Type: behavioral Required: yes Criterion: If the file cannot be read, then the application shall exit 1; if the arguments are malformed, then the application shall exit 2; in both cases it shall write nothing to standard output. Verification: proof Pattern: unwanted ## Questions - None. === END ARTIFACT === === BEGIN ARTIFACT TECHNOLOGY_STACK.md === # Technology Stack | Technology | Rigging | Notes | |---|---|---| | Go 1.22 or newer | go.md | Primary implementation language and module runtime. | | Go standard library | — | Use `encoding/csv` and other standard packages only; no database or external dependencies. | | POSIX shell | cli.md | Provides the required `bin/test.sh` and executes the supplied conformance harness. | | Go tooling (`go build`, `go test`, `go vet`) | common.md | Required build, test, and static-analysis commands. | === END ARTIFACT ===