|
| 1 | +# `refresh_metadata` reachability — finding from Bench 2.4 |
| 2 | + |
| 3 | +**Status:** Design-intent action; currently NOT reachable through live |
| 4 | +Circle API error shapes. Documented for PR #4 fix. |
| 5 | + |
| 6 | +**Bench reference:** `v2-smart-param-e2e-2026-05-26T07-15-11.json` (Group B) |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Design intent |
| 11 | + |
| 12 | +`smart_param_repair.ts` declares the action: |
| 13 | + |
| 14 | +```ts |
| 15 | +| { type: 'refresh_metadata'; resource: 'tokenId' | 'walletId' } |
| 16 | +``` |
| 17 | + |
| 18 | +with `applyParamRepair` returning `canRetry: false` and the diagnostic |
| 19 | +`Refresh ${resource} required (caller must re-fetch)`. |
| 20 | + |
| 21 | +The routing rule (in `smart_param_repair.ts`, lines roughly around |
| 22 | +"6. Unknown / stale resource id"): |
| 23 | + |
| 24 | +```ts |
| 25 | +if (location === 'tokenid' || /token ?id|unknown token/i.test(message)) { |
| 26 | + return { type: 'refresh_metadata', resource: 'tokenId' }; |
| 27 | +} |
| 28 | +if (location === 'walletid' || /wallet ?id|unknown wallet/i.test(message)) { |
| 29 | + return { type: 'refresh_metadata', resource: 'walletId' }; |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +**Intent:** when Circle reports a stale or non-existent tokenId/walletId |
| 34 | +reference, route the agent to re-fetch the resource id before retrying. |
| 35 | +Distinct from `hold_and_notify` (terminal hold) and `strip_field` |
| 36 | +(idempotency cleanup). |
| 37 | + |
| 38 | +## What Circle Sandbox actually returns (probed May 26 2026) |
| 39 | + |
| 40 | +Two distinct shapes were observed for tokenId issues, NEITHER of which |
| 41 | +matches the routing rule's pattern: |
| 42 | + |
| 43 | +### Shape 1 — nil UUID (`'00000000-0000-0000-0000-000000000000'`) |
| 44 | + |
| 45 | +``` |
| 46 | +HTTP 400 |
| 47 | +{ |
| 48 | + "code": 2, |
| 49 | + "message": "API parameter invalid", |
| 50 | + "errors": [ |
| 51 | + { |
| 52 | + "error": "uuid_format", |
| 53 | + "invalidValue": "00000000-0000-0000-0000-000000000000", |
| 54 | + "location": "tokenId", |
| 55 | + "message": "'tokenId' field is not in the correct UUID format (was 00000000-...)" |
| 56 | + } |
| 57 | + ] |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +Router lands on **Rule 2 (uuid_format → `hold_and_notify`)** because |
| 62 | +`error: 'uuid_format'` matches `isUuidFormatViolation()` before Rule 6's |
| 63 | +location check is reached. Circle treats the nil UUID as malformed, |
| 64 | +not as a missing reference. |
| 65 | + |
| 66 | +### Shape 2 — well-formed random UUID (`randomUUID()`, not in Circle's DB) |
| 67 | + |
| 68 | +``` |
| 69 | +HTTP 404 |
| 70 | +{ |
| 71 | + "code": 156002, |
| 72 | + "message": "Cannot find target token in the system. Either the specified token doesn't exist or it's not accessible to the caller." |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +**No `errors[]` array.** Router lands on the catch-all `hold_and_notify` |
| 77 | +with diagnostic `"No structured error details available"` because the |
| 78 | +`errors` array is empty. |
| 79 | + |
| 80 | +## Why Rule 6 never fires |
| 81 | + |
| 82 | +The pattern `/token ?id|unknown token/i` was a reasonable guess but |
| 83 | +doesn't match Circle's actual phrasing: |
| 84 | + |
| 85 | +| Circle's message | Matches `/token ?id|unknown token/i`? | |
| 86 | +|---|---| |
| 87 | +| `"'tokenId' field is not in the correct UUID format..."` | yes — but Rule 2 catches it first | |
| 88 | +| `"Cannot find target token in the system..."` | **no** — phrase is "target token", not "token id" or "unknown token" | |
| 89 | + |
| 90 | +Even if Rule 2 didn't fire first on Shape 1, Shape 2 (the actually- |
| 91 | +unknown-token case) bypasses the entire `errors[]`-based router and |
| 92 | +goes straight to the empty-errors catch-all. |
| 93 | + |
| 94 | +## Recommendation for PR #4 |
| 95 | + |
| 96 | +Add numeric-code routing for Circle's HTTP 404 + code 156002 family. |
| 97 | +Either: |
| 98 | + |
| 99 | +**(a) In `circle/perceive.ts`** — add a numeric-block branch for |
| 100 | +`circleCode === 156002` → returns a new failure code like |
| 101 | +`'circle-resource-not-found'`. Then the multi-strategy Gene Map |
| 102 | +maps that code to `refresh_metadata` as one of its candidates. |
| 103 | + |
| 104 | +**(b) In `smart-param-repair.ts`** — add a top-level numeric check |
| 105 | +before the `errors[]` switch: |
| 106 | + |
| 107 | +```ts |
| 108 | +const code = error?.response?.data?.code; |
| 109 | +const status = error?.response?.status; |
| 110 | +if (status === 404 && code === 156002) { |
| 111 | + return { type: 'refresh_metadata', resource: 'tokenId' }; |
| 112 | +} |
| 113 | +// Then check for walletId equivalent (probe needed — 156003? 156004?) |
| 114 | +``` |
| 115 | + |
| 116 | +Option (a) is cleaner because it lives in the perceive layer where |
| 117 | +all Circle codes are recognised. Option (b) is faster to ship as a |
| 118 | +standalone v2 patch if PR #4's multi-strategy work is delayed. |
| 119 | + |
| 120 | +## Why we ship the gap unfixed |
| 121 | + |
| 122 | +PR #3's scope is "ship standalone v2 strategies + bench data; |
| 123 | +discover gaps for PR #4." Discovering that `refresh_metadata` is |
| 124 | +currently unreachable IS the kind of finding that the bench is |
| 125 | +designed to surface. Fixing it in PR #3 would require either: |
| 126 | + |
| 127 | +- Modifying `smart-param-repair.ts` (out of scope per Phase 2 spec) |
| 128 | +- Touching `circle/perceive.ts` (would invalidate PR #2's perceive |
| 129 | + contract until re-tested) |
| 130 | + |
| 131 | +Both options expand the PR's risk surface for marginal demo value. |
| 132 | +The current behavior is **safe** (router holds rather than retrying |
| 133 | +blindly) and **honest** (caller gets a diagnostic, even if not the |
| 134 | +ideal one). PR #4 can fix this alongside the multi-strategy migration. |
| 135 | + |
| 136 | +## Net Bench 2.4 result |
| 137 | + |
| 138 | +``` |
| 139 | +Group A (idempotencyKey strip): 20/20 ✓ — 100% auto-fix, real Arc tx |
| 140 | +Group B (nil-UUID tokenId): 0/20 — held instead of refresh_metadata |
| 141 | + (Circle returns uuid_format) |
| 142 | +Group C ("not-a-uuid" walletId): 20/20 ✓ — 100% correct hold + diagnostic |
| 143 | +``` |
| 144 | + |
| 145 | +40/60 attempts (67%) take auto-fix path with **real Arc Testnet |
| 146 | +validation**. 20/60 (33%) correctly held with precise diagnostic. |
| 147 | + |
| 148 | +100% of Group B was held safely — no destructive retry, no data |
| 149 | +loss. The "failure" is the bench's expectation, not the router's |
| 150 | +behavior. |
0 commit comments