# 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="full_test.sh">
#!/bin/sh
# full_test.sh — scoring entry point. Do not filter, skip, or reinterpret.
#
# `drydock uat` runs `sh sources/full_test.sh` from the completed application root and takes its
# exit code and output as the score. The interface check is separate from the conformance run so
# that a missing or non-executable program and a genuine conformance failure are distinguishable
# in the evidence. JQ is the harness's only knowledge of the implementation language; the
# harness itself is language-neutral.
set -eu
if [ ! -x ./jq ]; then
    echo "error: no executable ./jq at the application root." >&2
    echo "The deliverable is an executable named jq that reads JSON on stdin." >&2
    exit 1
fi
JQ="$PWD/jq" exec python3 sources/run_conformance.py
</source>

<stories>
  <story id="foundation" implements="ARCHITECTURE.md">Establish the Python application structure and interpreter boundaries.</story>
  <story id="corpus-staging" implements="FEATURE-CorpusStaging.md">Stage and validate the supplied conformance assets.</story>
  <story id="lexer" implements="FEATURE-Lexer.md">Tokenize jq programs including strings and interpolation.</story>
  <story id="parser" implements="FEATURE-Parser.md">Parse and statically validate jq programs.</story>
  <story id="core" implements="FEATURE-GeneratorCore.md">Evaluate basic filters as ordered generators.</story>
  <story id="constructors" implements="FEATURE-Collections.md">Construct and access jq arrays and objects.</story>
  <story id="operators" implements="FEATURE-Operators.md">Evaluate jq arithmetic and comparison operators.</story>
  <story id="control" implements="FEATURE-Control.md">Evaluate conditional and error-control expressions.</story>
  <story id="bindings" implements="FEATURE-Bindings.md">Support lexical bindings, destructuring, and user functions.</story>
  <story id="paths" implements="FEATURE-Paths.md">Generate and retrieve jq paths.</story>
  <story id="assignment" implements="FEATURE-Assignment.md">Update and delete values through jq paths.</story>
  <story id="loops" implements="FEATURE-GeneratorControl.md">Implement reductions and generator control.</story>
  <story id="conversion" implements="FEATURE-Conversion.md">Implement jq type and conversion builtins.</story>
  <story id="collection-builtins" implements="FEATURE-CollectionBuiltins.md">Implement array and object utility builtins.</story>
  <story id="strings" implements="FEATURE-Strings.md">Implement string and regular-expression builtins.</story>
  <story id="formats" implements="FEATURE-Formats.md">Implement jq format and encoding filters.</story>
  <story id="numeric" implements="FEATURE-Numeric.md">Implement mathematical and numeric edge-case builtins.</story>
  <story id="dates" implements="FEATURE-Dates.md">Implement jq date and time builtins.</story>
  <story id="traversal" implements="FEATURE-Traversal.md">Implement recursive traversal and streaming utilities.</story>
  <story id="io" implements="FEATURE-InputDiagnostics.md">Implement jq input, environment, and diagnostic filters.</story>
  <story id="sql" implements="FEATURE-SqlBuiltins.md">Implement SQL-style filters and builtin inventory.</story>
  <story id="cli" implements="FEATURE-Command.md">Deliver the standalone jq command interface.</story>
  <story id="documentation" implements="FEATURE-Documentation.md">Document the command and verification interface.</story>
  <story id="scoped-integration" implements="FEATURE-ScopedConformance.md">Execute the remaining cross-feature conformance slices.</story>
  <story id="terminal-verification" implements="VERIFICATION.md">Verify the completed interpreter against the scoring script.</story>
</stories>
