# 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

- Copy story ids byte-for-byte from `<stories>`, preserving underscores, hyphens, and case; never invent or normalize one.
- Every story appears in one or more requirement `stories` attributes, or once as `<unattached>`, never both.
- 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="seed_accounts.csv">
account,name
DRAWER1,Front Drawer
DRAWER2,Back Drawer
PETTY,Petty Cash
SAFE,Store Safe
</source>

<stories>
  <story id="foundation-python" implements="ARCHITECTURE.md">Stand up the Python project tree, environment, dependency manifest, pytest runner, and bin/test.sh.</story>
  <story id="foundation-database" implements="DATABASE.md">Declare the accounts, categories, and transactions tables and every repository operation the stories need.</story>
  <story id="foundation-cli" implements="FEATURE-CliEntry.md">Provide the `ledger` executable at the application root with a command registry, usage-error handling, and the stdout/stderr contract.</story>
  <story id="feature-validation" implements="FEATURE-Validation.md">Validate codes, names, memos, amounts, and dates, and format integer cents as two-decimal text.</story>
  <story id="feature-balance-rule" implements="FEATURE-BalanceRule.md">Check that a proposed set of transaction changes leaves no account balance below zero before any write.</story>
  <story id="feature-init-count" implements="FEATURE-InitCount.md">Implement `ledger init` and `ledger count`.</story>
  <story id="feature-load-csv-reader" implements="FEATURE-LoadCsvReader.md">Read and header-check a CSV file named on the command line, exiting 1 when it cannot be read.</story>
  <story id="feature-account-add" implements="FEATURE-AccountAdd.md">Implement `ledger account add <code> <name>`.</story>
  <story id="feature-txn-post" implements="FEATURE-TxnPost.md">Implement `ledger txn post <account> <category> <amount> <date> [<memo>]`.</story>
  <story id="feature-load-accounts" implements="FEATURE-LoadAccounts.md">Implement `ledger load accounts <csv>` as an all-or-nothing load.</story>
  <story id="feature-account-delete" implements="FEATURE-AccountDelete.md">Implement `ledger account delete <code>`.</story>
  <story id="feature-txn-get" implements="FEATURE-TxnGet.md">Implement `ledger txn get <id>`.</story>
  <story id="feature-account-rename" implements="FEATURE-AccountRename.md">Implement `ledger account rename <code> <name>`.</story>
  <story id="feature-account-get" implements="FEATURE-AccountGet.md">Implement `ledger account get <code>`.</story>
  <story id="feature-txn-delete" implements="FEATURE-TxnDelete.md">Implement `ledger txn delete <id>`.</story>
  <story id="feature-txn-amend" implements="FEATURE-TxnAmend.md">Implement `ledger txn amend <id> <amount>`.</story>
  <story id="feature-load-categories" implements="FEATURE-LoadCategories.md">Implement `ledger load categories <csv>` as an all-or-nothing load.</story>
  <story id="feature-transfer" implements="FEATURE-Transfer.md">Implement `ledger transfer <from> <to> <amount> <date>` as an atomic two-row write.</story>
  <story id="feature-load-transactions" implements="FEATURE-LoadTransactions.md">Implement `ledger load transactions <csv>` with foreign-key, date, amount, and balance validation before any write.</story>
  <story id="feature-report-balances" implements="FEATURE-ReportBalances.md">Implement `ledger report balances`.</story>
  <story id="feature-report-monthly" implements="FEATURE-ReportMonthly.md">Implement `ledger report monthly`.</story>
  <story id="feature-report-categories" implements="FEATURE-ReportCategories.md">Implement `ledger report categories`.</story>
  <story id="feature-command-contract" implements="FEATURE-CommandContract.md">Assemble and verify the CSV output contract and exit codes across every command.</story>
  <story id="feature-no-negative-balance" implements="FEATURE-NoNegativeBalance.md">Assemble and verify that every writing command enforces the no-negative-balance rule atomically.</story>
  <story id="feature-verification" implements="FEATURE-Verification.md">Terminal gate: run the supplied grader and the full project test suite.</story>
</stories>
