Commit b1bc36f
authored
fix(cli): the codex harvest reads the checkout, so a session reports the branch it is on (langwatch#7415)
* fix(cli): the codex harvest reads the checkout, so a session reports the branch it is on
A codex session could not attribute to a pull request. The harvest built its
session-context record from the rollout's session_meta alone, and codex writes
git identity there only when the session STARTED inside a repository, then never
revises it.
Both halves of that hurt. Every agent on our box starts codex a directory above
its checkouts, so session_meta carries `git: null` and the session reported no
repository for its whole life, however many pull requests it reviewed. A session
that does start inside a checkout is no better off over time: it reports the
branch it opened with, so a reviewer moving from one pull request to the next
keeps naming the first.
The harvest runs on the machine that ran the turn, moments after it, so it now
reads the working directory itself through the same helper the claude hook uses,
and keeps the transcript's values as the fallback for a rollout harvested away
from its checkout.
Verified on the agents box: a codex turn in a checkout on a pull request's branch
reported github.com/langwatch/langwatch@feat/home-pill-setup-menu, and the
pull-request usage API attributed 38,473 tokens to that pull request. Before this
the same session reported nothing at all.
Claude-Session: https://claude.ai/code/session_01BUKKUiZbSBHmrLK9JJj4Ba
* test(cli): one contextAttr helper, taking named parameters
The new module-scope helper took positional parameters, against the repo
convention for functions with several arguments, and it collided with a
describe-scoped helper of the same name that already took named ones. The
inner one shadowed it, so the file carried two helpers with one name and
two different signatures.
There is now one helper, at module scope, taking named parameters. It keeps
the inner one's guard on the logs POST being present, which reports a
missing session-context record instead of throwing a TypeError that hides
which expectation failed.
Claude-Session: https://claude.ai/code/session_01BUKKUiZbSBHmrLK9JJj4Ba1 parent b682b88 commit b1bc36f
3 files changed
Lines changed: 214 additions & 30 deletions
File tree
- sdks/typescript/src/cli/utils/governance
- __tests__
- specs/ai-governance/cli-wrappers
Lines changed: 119 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
113 | 144 | | |
114 | 145 | | |
115 | 146 | | |
| |||
353 | 384 | | |
354 | 385 | | |
355 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 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 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
356 | 475 | | |
357 | 476 | | |
358 | 477 | | |
| |||
444 | 563 | | |
445 | 564 | | |
446 | 565 | | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | 566 | | |
466 | 567 | | |
467 | 568 | | |
| |||
Lines changed: 69 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
| |||
216 | 221 | | |
217 | 222 | | |
218 | 223 | | |
| 224 | + | |
219 | 225 | | |
220 | 226 | | |
221 | 227 | | |
| |||
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
| 245 | + | |
239 | 246 | | |
240 | 247 | | |
241 | 248 | | |
| |||
371 | 378 | | |
372 | 379 | | |
373 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
374 | 419 | | |
375 | 420 | | |
376 | 421 | | |
| |||
380 | 425 | | |
381 | 426 | | |
382 | 427 | | |
| 428 | + | |
383 | 429 | | |
384 | | - | |
385 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
386 | 440 | | |
387 | 441 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | 442 | | |
392 | 443 | | |
393 | 444 | | |
394 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
395 | 450 | | |
396 | 451 | | |
397 | 452 | | |
398 | 453 | | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
| 454 | + | |
| 455 | + | |
405 | 456 | | |
406 | 457 | | |
407 | 458 | | |
| |||
411 | 462 | | |
412 | 463 | | |
413 | 464 | | |
414 | | - | |
| 465 | + | |
415 | 466 | | |
416 | 467 | | |
417 | 468 | | |
| |||
484 | 535 | | |
485 | 536 | | |
486 | 537 | | |
| 538 | + | |
487 | 539 | | |
488 | 540 | | |
489 | 541 | | |
| |||
537 | 589 | | |
538 | 590 | | |
539 | 591 | | |
| 592 | + | |
540 | 593 | | |
541 | 594 | | |
542 | 595 | | |
| |||
547 | 600 | | |
548 | 601 | | |
549 | 602 | | |
| 603 | + | |
550 | 604 | | |
551 | 605 | | |
552 | 606 | | |
| |||
561 | 615 | | |
562 | 616 | | |
563 | 617 | | |
| 618 | + | |
564 | 619 | | |
565 | 620 | | |
566 | 621 | | |
| |||
585 | 640 | | |
586 | 641 | | |
587 | 642 | | |
| 643 | + | |
588 | 644 | | |
589 | 645 | | |
590 | 646 | | |
| |||
606 | 662 | | |
607 | 663 | | |
608 | 664 | | |
| 665 | + | |
609 | 666 | | |
610 | 667 | | |
611 | 668 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
141 | 148 | | |
142 | 149 | | |
143 | 150 | | |
144 | 151 | | |
145 | 152 | | |
146 | 153 | | |
147 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
148 | 174 | | |
149 | 175 | | |
150 | 176 | | |
| |||
0 commit comments