Skip to content

fix: count { success: false } results as failures in the effect tracker (GIT-104) - #32

Merged
1 commit merged into
mainfrom
bugfix/GIT-104-effect-tracker-false-success
Sep 21, 2026
Merged

1 commit merged into
mainfrom
bugfix/GIT-104-effect-tracker-false-success

Conversation

@nTEG-dev

Copy link
Copy Markdown
Member

Linear: https://linear.app/nteg-labs/issue/GIT-104

What

Makes health report failed writes as failures. Before this change, EffectTracker.track() counted any resolved promise as a success. Tracked writers that catch their own errors and resolve anyway were therefore reported as successes.

  • track(): a resolved value of the form { success: false } is now recorded as a failure. The message comes from error, then message, then display. The value is still returned to the caller, and rejections are handled as before.
  • Tracked writers that swallowed errors now let the tracker see them:
    • writeTriples attempts every triple, then rejects with a summary if any failed.
    • generateVariantsForScar rejects if a variant insert failed. It used Promise.allSettled and always resolved.
    • Cache writes under track() use a new rejecting writeResult(). setResult() keeps swallowing for its direct callers (check, tests).
    • The session_close transcript task now returns its save result, so { success: false } is visible.
  • recordScarUsageBatch now puts the error text on its { success: false } result.

track() call-site audit (18 sites)

Call site Path / target Wrapped fn on error Before After
tools/session-close.ts:1484 scar_usage / session_close_batch returns {success:false} (record-scar-usage-batch.ts:201-209) counted as success failure via {success:false}
tools/create-thread.ts:347 triple_write / thread_creation swallows (per-triple try/catch in writeTriples) counted as success rejects → failure
tools/resolve-thread.ts:236 triple_write / thread_resolution swallows (same) counted as success rejects → failure
tools/resolve-thread.ts:249 triple_write / thread_resolution_cascade swallows (same) counted as success rejects → failure
tools/create-decision.ts:95 triple_write / decision swallows (same) counted as success rejects → failure
tools/create-learning.ts:242 triple_write / learning swallows (same) counted as success rejects → failure
tools/create-learning.ts:258 variant_generation / learning swallows (Promise.allSettled, logs only) counted as success rejects → failure
services/cache.ts:226 cache_set / scar_search swallows (setResult try/catch) counted as success rejects (writeResult) → failure
services/cache.ts:252 cache_set / decisions swallows (same) counted as success rejects → failure
services/cache.ts:278 cache_set / wins swallows (same) counted as success rejects → failure
services/cache.ts:316 cache_set / sessions swallows (same) counted as success rejects → failure
services/cache.ts:339 cache_set / scar_usage swallows (same) counted as success rejects → failure
tools/session-close.ts:1369 transcript / session_close swallows (a {success:false} save result was dropped; the fn returned undefined) counted as success returns result → failure
tools/session-close.ts:1435 embedding / session_close throws (embed throws on API errors, directPatch throws) correct unchanged
tools/contribute-feedback.ts:118 feedback / remote-submit throws (submitFeedbackRemote throws on non-2xx) correct unchanged
services/metrics.ts:168 metrics / <tool> throws (directUpsert) correct unchanged
services/metrics.ts:363 relevance_update / <session> throws (listRecords / directUpsert) correct unchanged

(lib/telemetry.ts has its own unrelated track() method; it isn't the effect tracker.)

Venue check: blank Supabase (setup.sql only, no edge functions)

Driver: tests/e2e/blank-supabase.mjs (draft PR, test/GIT-83-blank-supabase-driver), flow mode.

Before (main d47a625): the netlog shows POST /rest/v1/scar_usage → 404 and POST /rest/v1/knowledge_triples → 400, but health reports them as succeeded:

  metrics              4/5 succeeded (1 failed)
  cache_set            1/1 succeeded
  triple_write         1/1 succeeded
  embedding            1/1 succeeded
  scar_usage           1/1 succeeded
  ⚠ 1 total failures across: metrics

After (this branch): the same two requests are now reported:

  cache_set            1/1 succeeded
  metrics              6/6 succeeded
  triple_write         0/1 succeeded (1 failed)
  embedding            1/1 succeeded
  scar_usage           0/1 succeeded (1 failed)
  ⚠ 2 total failures across: triple_write, scar_usage
  Recent failures:
    [scar_usage/session_close_batch] Supabase upsert error: 404 - ... Could not find the table 'public.scar_usage' ...
    [triple_write/thread_creation] 1/1 triples failed: Supabase upsert error: 400 - ... invalid input syntax for type uuid: "t-00fb1833"

The metrics 409 is the intermittent GIT-73 race. It didn't hit this run.

Expect health to show more failures after this merges. It isn't a regression: the failures already happened and are now counted. Those failures are fixed by GIT-84 (scar_usage), GIT-105 (triples) and GIT-106 (variants).

Tests

  • npx tsc --noEmit -p .: no errors
  • npm run test:unit (with HOME set to a temp dir): 76 files / 1224 tests passed. main is 74 / 1213, so this adds +11 tests in 2 files:
    • 6 effect-tracker outcome accounting: {success:false} counts as a failure, {success:true} and plain values count as successes, a rejection counts as a failure, plus message preference and the summary.
    • 5 tracked writers surface failures: writeTriples and generateVariantsForScar reject on a partial failure, and the tracker counts it.

Unit-test note: beforeEach(() => mock.mockReset()) combined with this repo's clearMocks/restoreMocks config made vitest 1.6 fail a passing test with the mock's error. The config already resets mocks between tests, so the new tests don't use beforeEach.

No version bump and no publish.

🤖 Generated with Claude Code

…er (GIT-104)

track() recorded any resolved promise as a success. Several tracked writers
catch their own errors and resolve anyway, so `health` reported failed writes
as succeeded. On a blank Supabase, scar_usage 404s and knowledge_triples 400s
were both counted as successes.

- track(): a resolved value of the form { success: false } is recorded as a
  failure (message from error, then message, then display). The value is still
  returned to the caller. Rejections are unchanged.
- Tracked writers that swallowed errors now let the tracker see them:
  - writeTriples attempts every triple, then rejects with a summary if any
    failed.
  - generateVariantsForScar rejects if a variant insert failed.
  - Cache writes under track() use a rejecting writeResult(). setResult()
    keeps swallowing for its direct callers.
  - The session_close transcript task returns the save result.
- recordScarUsageBatch reports the error text on failure.

Tests: +11 (6 effect-tracker outcome accounting, 5 tracked-writer failure
surfacing).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@nTEG-dev nTEG-dev closed this pull request by merging all changes into main in b1b3cb9 Sep 21, 2026
@nTEG-dev
nTEG-dev deleted the bugfix/GIT-104-effect-tracker-false-success branch September 23, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant