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
- 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.
- 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.
- 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.
- 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
storiesattributes, 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
<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="lexer.l"> %{ #include <assert.h> #include "jv_alloc.h" #include "compile.h"
struct lexer_param;
#include "parser.h" /* Generated by bison. */
#define YY_USER_ACTION \ do { \ yylloc->start = yyget_extra(yyscanner); \ yylloc->end = yylloc->start + yyleng; \ yyset_extra(yylloc->end, yyscanner); \ } while (0);
%}
%s IN_PAREN %s IN_BRACKET %s IN_BRACE %s IN_QQINTERP %x IN_QQSTRING %x IN_COMMENT %{ static int enter(int opening, int state, yyscan_t yyscanner); static int try_exit(int closing, int state, yyscan_t yyscanner); %}
%option noyywrap nounput noinput nodefault %option noyyalloc noyyrealloc noyyfree %option reentrant %option extra-type="int" %option bison-bridge bison-locations %option prefix="jq_yy" %option stack
%%
"#" { yy_push_state(IN_COMMENT, yyscanner); } <IN_COMMENT>{ \\(\\|\r?\n)|. { } \r?\n { yy_pop_state(yyscanner); } } <IN_COMMENT><<EOF>> { yy_pop_state(yyscanner); }
"!=" { return NEQ; } "==" { return EQ; } "as" { return AS; } "import" { return IMPORT; } "include" { return INCLUDE; } "module" { return MODULE; } "def" { return DEF; } "if" { return IF; } "then" { return THEN; } "else" { return ELSE; } "elif" { return ELSE_IF; } "and" { return AND; } "or" { return OR; } "end" { return END; } "reduce" { return REDUCE; } "foreach" { return FOREACH; } "//" { return DEFINEDOR; } "try" { return TRY; } "catch" { return CATCH; } "label" { return LABEL; } "break" { return BREAK; } "$loc" { return LOC; } "|=" { return SETPIPE; } "+=" { return SETPLUS; } "-=" { return SETMINUS; } "=" { return SETMULT; } "/=" { return SETDIV; } "%=" { return SETMOD; } "//=" { return SETDEFINEDOR; } "<=" { return LESSEQ; } ">=" { return GREATEREQ; } ".." { return REC; } "?//" { return ALTERNATION; } "."|"?"|"="|";"|","|":"|"|"|"+"|"-"|""|"/"|"%"|"\$"|"<"|">" { return yytext[0];}
"["|"{"|"(" { return enter(yytext[0], YY_START, yyscanner); }
"]"|"}"|")" { return try_exit(yytext[0], YY_START, yyscanner); }
"@"[a-zA-Z0-9_]+ { yylval->literal = jv_string_sized(yytext + 1, yyleng - 1); return FORMAT; }
([0-9]+(\.[0-9]*)?|\.[0-9]+)([eE][+-]?[0-9]+)? { yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL; }
"\"" { yy_push_state(IN_QQSTRING, yyscanner); return QQSTRING_START; }
<IN_QQSTRING>{ "\\(" { return enter(QQSTRING_INTERP_START, YY_START, yyscanner); } "\"" { yy_pop_state(yyscanner); return QQSTRING_END; } (\\[^u(]|\\u[a-zA-Z0-9]{0,4})+ { /* pass escapes to the json parser */ jv escapes = jv_string_fmt("\"%.*s\"", (int)yyleng, yytext); yylval->literal = jv_parse_sized(jv_string_value(escapes), jv_string_length_bytes(jv_copy(escapes))); jv_free(escapes); return QQSTRING_TEXT; } [^\\\"]+ { yylval->literal = jv_string_sized(yytext, yyleng); return QQSTRING_TEXT; } . { return INVALID_CHARACTER; } }
([a-zA-Z_][a-zA-Z_0-9]::)[a-zA-Z_][a-zA-Z_0-9]* { yylval->literal = jv_string(yytext); return IDENT;} \.[a-zA-Z_][a-zA-Z_0-9]* { yylval->literal = jv_string(yytext+1); return FIELD;} \$([a-zA-Z_][a-zA-Z_0-9]::)[a-zA-Z_][a-zA-Z_0-9]* { yylval->literal = jv_string(yytext+1); return BINDING;}
[ \r\n\t]+ {}
. { return INVALID_CHARACTER; }
%% /* perhaps these should be calls... / / "true" { return TRUE; } "false" { return FALSE; } "null" { return NULL; } */ static int try_exit(int c, int state, yyscan_t yyscanner) { char match = 0; int ret; switch (state) { case IN_PAREN: match = ret = ')'; break; case IN_BRACKET: match = ret = ']'; break; case IN_BRACE: match = ret = '}'; break;
case IN_QQINTERP: match = ')'; ret = QQSTRING_INTERP_END; break;
default: // may not be the best error to give return INVALID_CHARACTER; } assert(match); if (match == c) { yy_pop_state(yyscanner); return ret; } else { // FIXME: should we pop? Give a better error at least return INVALID_CHARACTER; } }
static int enter(int c, int currstate, yyscan_t yyscanner) { int state = 0; switch (c) { case '(': state = IN_PAREN; break; case '[': state = IN_BRACKET; break; case '{': state = IN_BRACE; break; case QQSTRING_INTERP_START: state = IN_QQINTERP; break; } assert(state); yy_push_state(state, yyscanner); return c; }
void* yyalloc(size_t sz, void* extra) { return jv_mem_alloc(sz); } void* yyrealloc(void* p, size_t sz, void* extra) { return jv_mem_realloc(p, sz); } void yyfree(void* p, void* extra) { jv_mem_free(p); } </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>