# Attribute Stories to Source Requirements

You are the lineage attribution agent. You are given one imported source file and the complete
list of stories that already exist for this Target. Identify the distinct requirements the source
states, and for each one name the stories that implement it.

This is a matching task against a closed set. Every story you may name is listed in `<stories>`.
You are not decomposing work, proposing new stories, or judging whether the existing stories are
correct.

## Method

1. Read the source and identify each distinct requirement it states. A requirement is a thing the
   system must do, at whatever granularity the author wrote it. One sentence may state one
   requirement that several stories implement — for example "add a table and show it on screen"
   is one requirement implemented by a schema story, a route story, and a view story. Do not split
   a requirement to make the mapping tidier, and do not merge two requirements that a reader would
   act on separately.
2. Give each requirement a short kebab-case name that describes it. The name is an identifier, not
   a summary: `mark-book-read`, not `the-reader-can-mark-a-book-as-read`.
3. For each requirement, list every story that implements any part of it. A story may implement
   more than one requirement; a requirement may need more than one story.
4. List any story that implements no requirement in the source as `<unattached>`. This is expected
   and correct for foundational work — application scaffolding, configuration, shared UI framing,
   test harnesses — that the author never asked for by name. Do not force such a story onto an
   unrelated requirement.

## Rules

- Use only story ids that appear in `<stories>`. Never invent one.
- Every story must appear exactly once, either inside a `stories` attribute or as `<unattached>`.
- Quote the requirement text verbatim from the source in the tag body. Do not paraphrase it.
- Emit nothing but the tags below. No preamble, no commentary, no explanation.

## Output

```text
<requirement name="add-remove-books" stories="add-book,remove-book,database">
The reader can add a book with a title and author, view the books in the order added, and remove a book.
</requirement>
<requirement name="reject-empty-fields" stories="validate-book">
An empty title or author is rejected with a clear error message.
</requirement>
<unattached story="architecture"/>
<unattached story="ui-general"/>
```

# Attribution job

<source name="ragged.csv">
sku,price,in_stock
A1,9.99,true
A2,4.50,false
A3,1.25,true,extra
A4,3.00,false
</source>

<stories>
  <story id="architecture" implements="ARCHITECTURE.md">Define the CsvStat command architecture and module boundaries.</story>
  <story id="cli-foundation" implements="FEATURE-CLI-FOUNDATION.md">Build the csvstat command entry point and module.</story>
  <story id="cli-input" implements="FEATURE-CLI-INPUT.md">Read, normalize, and structurally validate CSV input.</story>
  <story id="cli-columns" implements="FEATURE-CLI-COLUMNS.md">Resolve named columns and classify null values.</story>
  <story id="profile-types" implements="FEATURE-PROFILE-TYPES.md">Infer each column type using the specified precedence.</story>
  <story id="frequency-values" implements="FEATURE-FREQUENCY-VALUES.md">Aggregate and order frequent non-null column values.</story>
  <story id="frequency-limits" implements="FEATURE-FREQUENCY-LIMITS.md">Validate and apply frequency row limits.</story>
  <story id="profile-statistics" implements="FEATURE-PROFILE-STATISTICS.md">Compute exact profile statistics and decimal formatting.</story>
  <story id="profile-output" implements="FEATURE-PROFILE-OUTPUT.md">Render profile results as CSV.</story>
  <story id="cli-errors" implements="FEATURE-CLI-ERRORS.md">Map operational, usage, and rejected-input failures.</story>
  <story id="test-gate" implements="FEATURE-TEST-GATE.md">Provide the Go vet and test project gate.</story>
  <story id="full-verification" implements="FEATURE-FULL-VERIFICATION.md">Run the complete supplied CsvStat conformance suite.</story>
</stories>
