Commit 28c861f
authored
fix(generation): stop the module_page prompt tripping its own validator, and bound the spotlight importer list (#1606)
* fix(generation): stop the module_page prompt from using banned vocabulary
The module_page system prompt asked the model to "Ground every claim in the
supplied material". "the supplied material" is a literal match for the
supplied_context artifact rule, so when the model echoed the instruction's own
wording the finished page was rejected and thrown away with its tokens already
spent. Every observed failure was a module_page, always the same phrase.
Reword the instruction to point at the files and signals below instead, and
drop the same adjective from the scope-line sentence so the vocabulary is not
reinforced anywhere in the prompt.
Add a guard so this cannot come back: every system prompt, the corrective
directive, and every generation template are asserted not to match any
ArtifactRule pattern. The same class of bug had already shipped once before,
documented in the comment directly above the offending line.
Back that with one corrective re-ask. A rejected page has been paid for, and
the only recovery was --resume regenerating it from scratch, so a single retry
that names the rule the last attempt broke is cheaper than losing it. The
re-ask names the rule but not the words that tripped it, since handing those
back re-plants the vocabulary. A token-limit failure is not retried: the second
call carries the same max_tokens and would truncate in the same place. A second
failure raises exactly as before, so the stub-fallback path is unchanged.
* fix(generation): bound the importer list on a symbol spotlight page
symbol_spotlight.j2 rendered one bullet per importing file with no bound. On
this repository tests/conftest.py has 939 importers, so its three spotlight
pages came out at ~46.6k characters each, of which 45.7k was the importer list
alone. EMBED_TEXT_MAX_CHARS is 30,000, so the tail was dropped from the vector
and the pages were searchable only by their first few hundred importers. The
stored content was intact; the recall was not.
file_page.j2 already bounds its "Used by" section, over the same data, at 25
with an "and N more" line. Apply that bound here rather than inventing a
second one. The summary sentence above the list keeps counting every importer,
so truncating the list does not truncate the fact.
Three of 4,253 pages were over the cap, all three this one file.
* fix(generation): account for the attempt a corrective retry discards
The retry rebound the response, so the rejected attempt's tokens were dropped
from the run report. Billing was always right, since the provider cost tracker
sees both calls, but the reported total came out one whole generation short for
every page that needed a second attempt. Carry the discarded counts forward
onto the response that survives.
Mark the recovered page with self_repair. The report already reads that key and
renders a "Self-repaired pages" row, and nothing has ever written it, so the
row has been permanently zero. It is also the only way to tell a page the
backstop rescued from a page it lost: the artifact tallies count the rejection
either way.
Reword one line of the corrective directive off "the material you were given".
It is a phrase away from the rule it is quoting, and it is the sentence in the
whole prompt most likely to be echoed back.1 parent 946a9dc commit 28c861f
7 files changed
Lines changed: 425 additions & 16 deletions
File tree
- packages/core/src/repowise/core/generation
- page_generator
- templates
- tests/unit/generation
Lines changed: 60 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| |||
398 | 402 | | |
399 | 403 | | |
400 | 404 | | |
401 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
402 | 448 | | |
403 | 449 | | |
404 | 450 | | |
405 | 451 | | |
406 | 452 | | |
407 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
408 | 459 | | |
409 | 460 | | |
410 | 461 | | |
| |||
498 | 549 | | |
499 | 550 | | |
500 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
501 | 557 | | |
502 | 558 | | |
503 | 559 | | |
| |||
Lines changed: 26 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
| |||
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
Lines changed: 42 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
27 | 52 | | |
28 | 53 | | |
29 | 54 | | |
| |||
129 | 154 | | |
130 | 155 | | |
131 | 156 | | |
132 | | - | |
133 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
134 | 164 | | |
135 | 165 | | |
136 | 166 | | |
137 | 167 | | |
138 | 168 | | |
139 | 169 | | |
140 | | - | |
| 170 | + | |
| 171 | + | |
141 | 172 | | |
142 | 173 | | |
143 | 174 | | |
| |||
182 | 213 | | |
183 | 214 | | |
184 | 215 | | |
185 | | - | |
| 216 | + | |
| 217 | + | |
186 | 218 | | |
187 | 219 | | |
188 | 220 | | |
| |||
193 | 225 | | |
194 | 226 | | |
195 | 227 | | |
196 | | - | |
197 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
198 | 232 | | |
199 | | - | |
| 233 | + | |
200 | 234 | | |
201 | 235 | | |
202 | 236 | | |
| |||
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| |||
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
43 | | - | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
46 | 56 | | |
47 | 57 | | |
48 | 58 | | |
| |||
0 commit comments