592a6262b5eee182d9e684648e3649394ee8a607
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c15d14557c
|
fix(tools): stop testing on the text of other files, and ungate contractaudit
Six tests asserted on the wording and formatting of source and config files rather than on behaviour: four injected text into fixtures and checked that a regex noticed, and two asserted on api.jsx's contents. They break on an extra space, a newline, a rename, or a comment that merely mentions the token -- the single-fetch check had already false-positived on a comment, and I patched it with a comment-stripper instead of deleting it. A test that cannot tell "the code is wrong" from "the file is formatted differently" tests the wrong thing, and the maintenance cost is permanent. Deleted: tools/contractaudit/negative_test.go in full, and the source-scanning "api.jsx holds exactly one fetch call" check with its stripComments helper. The dashboard suite still asserts the browser mutation contract behaviourally, per method, by inspecting the request each one makes -- which is where the real defect was found. 142 UI tests pass; the 45 methods remain fully covered by the two inventories and the completeness check. The tool's own decoding is now testable without a file: parseDeclarations takes an io.Reader, so its rules are exercised with in-memory input, and only the absent-file branch still touches a path (which is never created). contractaudit is no longer part of task check. Its surfaces are discovered by scanning source text, so a rename or reformat elsewhere can change its output with nothing actually wrong -- it reported 16 live routes as unconsumed once, when the dashboard's request helper was renamed. A check that can fail for reasons unrelated to what it measures must not be able to break a build. It now matches tools/reachaudit: advisory, run by hand, --strict available on request. Also removes five unused indirect requires from tools/go.mod (go mod tidy). They were residue from the reflection-based first implementation of the RPC scan, which was replaced by text scanning without tidying. -mod=readonly cannot catch a superfluous require, so nothing would ever have found them. Rewrites docs/prds/contract-conformance-audit.md, which claimed RPC coverage was derived by reflection over the exported client type -- it never was -- listed surface sizes of 43/12/52 against real counts of 45/21/49, described three classification classes where the code has four, invented a five-surface Shape with files that were never written, and blamed raw fetch calls for a 401 defect that did not exist. Each false claim is now recorded in an errata section rather than quietly dropped, and the document states plainly that the audit has found nothing actionable: the 415 refusals and the duplicated client plumbing were both found by reading the handler and reproducing the request. Testing rule added to the document, since this is the second time: assert on the observable effect, never on the content or formatting of generated or hand-authored text and config files. |
||
|
|
18e8f8f0e6
|
fix(ui): unbreak binding approve and the two deletes, and centralise the client
Three dashboard mutations were refused 415 on every use. archied's
authorizeTaskMutation runs before the handler body and answers
"Content-Type must be application/json" unless the request declares a JSON
body -- including when there is no body to send, because that requirement is
what makes a simple cross-origin form post inexpressible. bindingApprove,
mappingDelete and bindingDelete sent Accept and X-Archie-CSRF but no
Content-Type, so approving a binding or deleting a mapping or binding never
worked from the dashboard.
Reproduced against the real handler with the browser's exact headers: 415,
where the same request plus Content-Type returns 200 and arms the binding.
The Go tests missed it because doJSONWithHeaders sets Content-Type
unconditionally, even for a nil body, so no test ever exercised the shape the
client actually sends.
Every api.* method now goes through one request() (and one send()), which
sets Content-Type and the CSRF marker on every mutation rather than only
where a payload happens to exist. The module already claimed to be "the
single place that knows how to talk to archied" while 22 call sites built
their own fetch, headers, timeout and error handling inline and chat.jsx
built a 23rd; that claim is now true, and chat.jsx's stream goes through
api.chatStream so only the URL, headers and failure shape are shared while
chat.jsx keeps its abort/timeout and SSE parsing.
Behaviour deliberately preserved: 204 deletes still parse no body, the
install timeout stays 120s, and 401 still classifies as session-expired. One
intentional change -- a 401 message is now the server's own text ("open the
dashboard URL archied logged at startup") rather than a bare "unauthorised",
since errorMessage already prefers the actionable reason and the classification
is derived from the status either way.
ui/test/api-client.test.js asserts the browser mutation contract for every
method, that reads carry no mutation marker, that a 204 resolves without
parsing, that api.jsx holds exactly one fetch call, and that every api method
is classified by the suite so a new one cannot be added uncovered. ui/dist is
rebuilt, being a committed asset.
I had claimed this work was needed to fix a 401 defect. It was not: all 22 raw
call sites passed res.status to ApiError, so classifyActionError already mapped
401 to session-expired, and chat.jsx never classified at all. The missing
Content-Type was the real defect.
|