Commit 80baacf
committed
#249 — Shared error-code taxonomy
* docs/errors.yaml: single source of truth for every error code we
emit across backend and AI service.
* app/backend/src/common/errors/codes.ts: TypeScript enum + meta
table + codeForHttpStatus/httpStatusForCode helpers.
* app/backend/src/common/errors/codes.spec.ts: parity test that
walks docs/errors.yaml and asserts the TS binding matches every
entry, plus a first-declared-wins lookup lock.
* app/ai-service/schemas/codes.py: Python mirror of the TS binding
(enum + dataclass meta + identical reverse-lookup semantics).
* app/ai-service/tests/test_codes.py: parity test mirroring
codes.spec.ts. Both YAML parsers are byte-for-byte equivalent in
shape and produce the same set of entries for docs/errors.yaml.
* app/ai-service/main.py: HTTPException, validation, body-size, and
fallback exception handlers now route through
ErrorCode.<X>.value / code_for_http_status(...) instead of ad-hoc
literal strings.
* app/backend/src/common/filters/http-exception.filter.ts: doc
comment pinning the wire-format contract (code: number, the existing
public envelope shape) so a future PR cannot accidentally break it.
#233 — Cap allowed_tokens at MAX_ALLOWED_TOKENS
* app/onchain/contracts/aid_escrow/src/lib.rs:
- new pub const MAX_ALLOWED_TOKENS: u32 = 32 (re-exported for tests).
- new Error::TooManyAllowedTokens = 23 variant.
- set_config rejects oversized allowlists with
Error::TooManyAllowedTokens BEFORE the per-token validate_token
loop, so a malicious admin can neither bloat wasm storage
nor burn host cost.
* app/onchain/contracts/aid_escrow/tests/aid_escrow_tests.rs:
- set_config_rejects_too_many_allowed_tokens (vec of length
MAX + 1, asserts TooManyAllowedTokens)
- set_config_passes_cap_check_at_max_boundary (vec of length
MAX made of dummy AidEscrow writes to lmts, asserts InvalidToken
rather than TooManyAllowedTokens to prove the cap is exclusive).
Both tests reference aid_escrow::MAX_ALLOWED_TOKENS directly so
future tweaks to the cap cannot silently drift out of spec.
Both contracts public wire formats are unchanged.
Closes #249
Closes #233
1 parent 243f30d commit 80baacf
9 files changed
Lines changed: 1079 additions & 5 deletions
File tree
- app
- ai-service
- schemas
- tests
- backend/src/common
- errors
- filters
- onchain/contracts/aid_escrow
- src
- tests
- docs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
351 | | - | |
| 352 | + | |
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
| |||
376 | 377 | | |
377 | 378 | | |
378 | 379 | | |
379 | | - | |
| 380 | + | |
380 | 381 | | |
381 | 382 | | |
382 | 383 | | |
| |||
1036 | 1037 | | |
1037 | 1038 | | |
1038 | 1039 | | |
1039 | | - | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
1040 | 1045 | | |
1041 | 1046 | | |
1042 | 1047 | | |
| |||
1053 | 1058 | | |
1054 | 1059 | | |
1055 | 1060 | | |
1056 | | - | |
| 1061 | + | |
| 1062 | + | |
1057 | 1063 | | |
1058 | 1064 | | |
1059 | 1065 | | |
| |||
1078 | 1084 | | |
1079 | 1085 | | |
1080 | 1086 | | |
1081 | | - | |
| 1087 | + | |
| 1088 | + | |
1082 | 1089 | | |
1083 | 1090 | | |
1084 | 1091 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 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 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
0 commit comments