# 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_transactions.csv">
txn_id,date,account,category,amount,memo
1,2026-01-01,SAFE,OPENING,5000.00,opening float
2,2026-01-01,PETTY,OPENING,200.00,opening float
3,2026-01-02,DRAWER1,SALES,155.26,sales day 1
4,2026-01-02,DRAWER2,SALES,83.11,sales day 1
5,2026-01-03,DRAWER1,SALES,160.51,sales day 2
6,2026-01-03,DRAWER2,SALES,86.21,sales day 2
7,2026-01-04,DRAWER1,SALES,165.76,sales day 3
8,2026-01-04,DRAWER2,SALES,89.31,sales day 3
9,2026-01-05,DRAWER1,SALES,171.01,sales day 4
10,2026-01-05,DRAWER2,SALES,92.41,sales day 4
11,2026-01-06,DRAWER1,SALES,176.26,sales day 5
12,2026-01-06,DRAWER2,SALES,95.51,sales day 5
13,2026-01-07,DRAWER1,SALES,181.51,sales day 6
14,2026-01-07,DRAWER2,SALES,98.61,sales day 6
15,2026-01-08,DRAWER1,SALES,186.76,sales day 7
16,2026-01-08,DRAWER2,SALES,101.71,sales day 7
17,2026-01-09,DRAWER1,SALES,192.01,sales day 8
18,2026-01-09,DRAWER2,SALES,104.81,sales day 8
19,2026-01-10,DRAWER1,SALES,197.26,sales day 9
20,2026-01-10,DRAWER2,SALES,107.91,sales day 9
21,2026-01-11,DRAWER1,SALES,202.51,sales day 10
22,2026-01-11,DRAWER2,SALES,111.01,sales day 10
23,2026-01-12,DRAWER1,REFUND,-12.50,refund
24,2026-01-12,DRAWER2,REFUND,-7.25,refund
25,2026-01-13,DRAWER1,REFUND,-9.99,refund
26,2026-01-13,DRAWER2,REFUND,-4.01,refund
27,2026-01-14,DRAWER1,TRANSFER,-1000.00,transfer to SAFE
28,2026-01-14,SAFE,TRANSFER,1000.00,transfer from DRAWER1
29,2026-01-14,DRAWER2,TRANSFER,-500.00,transfer to SAFE
30,2026-01-14,SAFE,TRANSFER,500.00,transfer from DRAWER2
31,2026-01-15,SAFE,TRANSFER,-200.00,transfer to PETTY
32,2026-01-15,PETTY,TRANSFER,200.00,transfer from SAFE
33,2026-01-16,PETTY,SUPPLY,-35.40,supplies
34,2026-01-17,PETTY,SUPPLY,-42.10,supplies
35,2026-01-18,PETTY,SUPPLY,-18.75,supplies
36,2026-01-19,PETTY,SUPPLY,-60.00,supplies
37,2026-01-20,PETTY,SUPPLY,-25.00,supplies
38,2026-01-21,SAFE,PAYROLL,-1200.00,payroll week 1
39,2026-01-28,SAFE,PAYROLL,-1200.00,payroll week 2
40,2026-01-28,SAFE,RENT,-900.00,rent
41,2026-02-01,SAFE,SALES,500.00,deposit
42,2026-02-01,PETTY,SALES,20.00,deposit
43,2026-02-02,DRAWER1,SALES,155.27,sales day 1
44,2026-02-02,DRAWER2,SALES,83.12,sales day 1
45,2026-02-03,DRAWER1,SALES,160.52,sales day 2
46,2026-02-03,DRAWER2,SALES,86.22,sales day 2
47,2026-02-04,DRAWER1,SALES,165.77,sales day 3
48,2026-02-04,DRAWER2,SALES,89.32,sales day 3
49,2026-02-05,DRAWER1,SALES,171.02,sales day 4
50,2026-02-05,DRAWER2,SALES,92.42,sales day 4
51,2026-02-06,DRAWER1,SALES,176.27,sales day 5
52,2026-02-06,DRAWER2,SALES,95.52,sales day 5
53,2026-02-07,DRAWER1,SALES,181.52,sales day 6
54,2026-02-07,DRAWER2,SALES,98.62,sales day 6
55,2026-02-08,DRAWER1,SALES,186.77,sales day 7
56,2026-02-08,DRAWER2,SALES,101.72,sales day 7
57,2026-02-09,DRAWER1,SALES,192.02,sales day 8
58,2026-02-09,DRAWER2,SALES,104.82,sales day 8
59,2026-02-10,DRAWER1,SALES,197.27,sales day 9
60,2026-02-10,DRAWER2,SALES,107.92,sales day 9
61,2026-02-11,DRAWER1,SALES,202.52,sales day 10
62,2026-02-11,DRAWER2,SALES,111.02,sales day 10
63,2026-02-12,DRAWER1,REFUND,-12.50,refund
64,2026-02-12,DRAWER2,REFUND,-7.25,refund
65,2026-02-13,DRAWER1,REFUND,-9.99,refund
66,2026-02-13,DRAWER2,REFUND,-4.01,refund
67,2026-02-14,DRAWER1,TRANSFER,-1000.00,transfer to SAFE
68,2026-02-14,SAFE,TRANSFER,1000.00,transfer from DRAWER1
69,2026-02-14,DRAWER2,TRANSFER,-500.00,transfer to SAFE
70,2026-02-14,SAFE,TRANSFER,500.00,transfer from DRAWER2
71,2026-02-15,SAFE,TRANSFER,-200.00,transfer to PETTY
72,2026-02-15,PETTY,TRANSFER,200.00,transfer from SAFE
73,2026-02-16,PETTY,SUPPLY,-35.40,supplies
74,2026-02-17,PETTY,SUPPLY,-42.10,supplies
75,2026-02-18,PETTY,SUPPLY,-18.75,supplies
76,2026-02-19,PETTY,SUPPLY,-60.00,supplies
77,2026-02-20,PETTY,SUPPLY,-25.00,supplies
78,2026-02-21,SAFE,PAYROLL,-1200.00,payroll week 1
79,2026-02-28,SAFE,PAYROLL,-1200.00,payroll week 2
80,2026-02-28,SAFE,RENT,-900.00,rent
81,2026-03-01,SAFE,SALES,750.00,deposit
82,2026-03-01,PETTY,SALES,30.00,deposit
83,2026-03-02,DRAWER1,SALES,155.28,sales day 1
84,2026-03-02,DRAWER2,SALES,83.13,sales day 1
85,2026-03-03,DRAWER1,SALES,160.53,sales day 2
86,2026-03-03,DRAWER2,SALES,86.23,sales day 2
87,2026-03-04,DRAWER1,SALES,165.78,sales day 3
88,2026-03-04,DRAWER2,SALES,89.33,sales day 3
89,2026-03-05,DRAWER1,SALES,171.03,sales day 4
90,2026-03-05,DRAWER2,SALES,92.43,sales day 4
91,2026-03-06,DRAWER1,SALES,176.28,sales day 5
92,2026-03-06,DRAWER2,SALES,95.53,sales day 5
93,2026-03-07,DRAWER1,SALES,181.53,sales day 6
94,2026-03-07,DRAWER2,SALES,98.63,sales day 6
95,2026-03-08,DRAWER1,SALES,186.78,sales day 7
96,2026-03-08,DRAWER2,SALES,101.73,sales day 7
97,2026-03-09,DRAWER1,SALES,192.03,sales day 8
98,2026-03-09,DRAWER2,SALES,104.83,sales day 8
99,2026-03-10,DRAWER1,SALES,197.28,sales day 9
100,2026-03-10,DRAWER2,SALES,107.93,sales day 9
101,2026-03-11,DRAWER1,SALES,202.53,sales day 10
102,2026-03-11,DRAWER2,SALES,111.03,sales day 10
103,2026-03-12,DRAWER1,REFUND,-12.50,refund
104,2026-03-12,DRAWER2,REFUND,-7.25,refund
105,2026-03-13,DRAWER1,REFUND,-9.99,refund
106,2026-03-13,DRAWER2,REFUND,-4.01,refund
107,2026-03-14,DRAWER1,TRANSFER,-1000.00,transfer to SAFE
108,2026-03-14,SAFE,TRANSFER,1000.00,transfer from DRAWER1
109,2026-03-14,DRAWER2,TRANSFER,-500.00,transfer to SAFE
110,2026-03-14,SAFE,TRANSFER,500.00,transfer from DRAWER2
111,2026-03-15,SAFE,TRANSFER,-200.00,transfer to PETTY
112,2026-03-15,PETTY,TRANSFER,200.00,transfer from SAFE
113,2026-03-16,PETTY,SUPPLY,-35.40,supplies
114,2026-03-17,PETTY,SUPPLY,-42.10,supplies
115,2026-03-18,PETTY,SUPPLY,-18.75,supplies
116,2026-03-19,PETTY,SUPPLY,-60.00,supplies
117,2026-03-20,PETTY,SUPPLY,-25.00,supplies
118,2026-03-21,SAFE,PAYROLL,-1200.00,payroll week 1
119,2026-03-28,SAFE,PAYROLL,-1200.00,payroll week 2
120,2026-03-28,SAFE,RENT,-900.00,rent
</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>
