@@ -146,14 +146,17 @@ describe("verifyCompactionSummary", () => {
146146 expect ( kinds ) . toContain ( "exactName" ) ;
147147 } ) ;
148148
149- test ( "auth as a goal token does not match authored" , ( ) => {
149+ test ( "auth as a goal token does not match authored, author, or preauth " , ( ) => {
150150 const facts = extractContinuationFacts ( [ textTurn ( "user" , "Fix auth now" ) ] ) ;
151- const report = verifyCompactionSummary (
151+ for ( const summary of [
152152 "The authored notes: next step module plan is set." ,
153- facts ,
154- ) ;
155- expect ( report . supported ) . toBe ( false ) ;
156- expect ( report . misses . some ( ( m ) => m . kind === "goal" ) ) . toBe ( true ) ;
153+ "The author notes: next step module plan is set." ,
154+ "The preauth notes: next step module plan is set." ,
155+ ] ) {
156+ const report = verifyCompactionSummary ( summary , facts ) ;
157+ expect ( report . supported ) . toBe ( false ) ;
158+ expect ( report . misses . some ( ( m ) => m . kind === "goal" ) ) . toBe ( true ) ;
159+ }
157160 } ) ;
158161
159162 test ( "denying failure while errors were dropped is a contradiction" , ( ) => {
@@ -212,8 +215,55 @@ describe("verifyOrRepair", () => {
212215 const outcome = verifyOrRepair ( "Fix auth now. Work continues." , facts , 90 ) ;
213216 expect ( outcome . aborted ) . toBe ( true ) ;
214217 expect ( outcome . repaired ) . toBe ( false ) ;
215- const shipped = verifyCompactionSummary ( outcome . summary , facts ) ;
216- expect ( shipped . misses . some ( ( m ) => m . kind === "exactName" ) ) . toBe ( true ) ;
218+ expect ( outcome . misses . some ( ( m ) => m . kind === "exactName" ) ) . toBe ( true ) ;
219+ } ) ;
220+
221+ test ( "a roomy cap repairs and keeps the exact-name basename" , ( ) => {
222+ const facts = extractContinuationFacts ( [
223+ textTurn ( "user" , "Fix auth now" ) ,
224+ {
225+ role : "assistant" ,
226+ content : [
227+ {
228+ type : "tool_call" ,
229+ id : "c1" ,
230+ name : "read_file" ,
231+ arguments : { path : "src/very-long-unique-path/exact-file.ts" } ,
232+ } ,
233+ ] ,
234+ timestamp : 2 ,
235+ } ,
236+ ] ) ;
237+ const outcome = verifyOrRepair (
238+ "Fix auth now. Work continues." ,
239+ facts ,
240+ 4000 ,
241+ ) ;
242+ expect ( outcome . aborted ) . toBe ( false ) ;
243+ expect ( outcome . repaired ) . toBe ( true ) ;
244+ expect ( outcome . summary ) . toContain ( "exact-file.ts" ) ;
245+ } ) ;
246+
247+ test ( "a constraint-only residual after a sliced repair aborts" , ( ) => {
248+ const facts = extractContinuationFacts ( [
249+ textTurn ( "user" , "Fix auth now" ) ,
250+ textTurn ( "assistant" , "Working on auth now." ) ,
251+ textTurn ( "user" , "Do not commit generated artifacts ever." ) ,
252+ textTurn ( "assistant" , "Working on auth now." ) ,
253+ ] ) ;
254+ expect (
255+ facts . constraints . some ( ( c ) => c . includes ( "generated artifacts" ) ) ,
256+ ) . toBe ( true ) ;
257+ const summary = "Fix auth now. Working on auth now." ;
258+ const misses = verifyCompactionSummary ( summary , facts ) . misses ;
259+ expect ( misses . map ( ( m ) => m . kind ) ) . toEqual ( [ "constraint" ] ) ;
260+ const full = repairSummary ( summary , facts , misses ) ;
261+ const cap = full . indexOf ( "Constraints:" ) ;
262+ expect ( cap ) . toBeGreaterThan ( 0 ) ;
263+ const outcome = verifyOrRepair ( summary , facts , cap ) ;
264+ expect ( outcome . aborted ) . toBe ( true ) ;
265+ expect ( outcome . repaired ) . toBe ( false ) ;
266+ expect ( outcome . misses . some ( ( m ) => m . kind === "constraint" ) ) . toBe ( true ) ;
217267 } ) ;
218268
219269 test ( "repairSummary names only what the handoff missed" , ( ) => {
0 commit comments