oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# Live database structural check, 2026-11-26
2
3Branch `fix/check-db`, from main `8a3f1d92`. The one-shot `equipo check-db`
4runs before configuration, mail, migrations or application boot. No live
5instance was checked and no deployment was performed by this branch.
6
7## Live path and read-only behavior
8
9CARLOS supplies `CARLOS_DB` to the command from the serving instance's actual
10`dbPath`: `carlos/platform/internal/activator/cmdunit.go`, `ExecBackend.cmdVars`.
11This command requires that path to be absolute and a regular file. It has no
12fallback to a replica, a default filename or the application's boot resolver.
13The filename is URL-encoded before adding the fixed SQLite `mode=ro` option.
14It does not use `immutable`, which would miss committed WAL changes.
15
16One read transaction runs `PRAGMA quick_check(100)`, then
17`PRAGMA integrity_check(100)`, followed by page count, page size and journal
18mode. There are no setters, migrations, checkpoints or writes. The deadline is
1960 seconds, including opening and reading. The serving writer remains usable.
20WAL size is observed if visible; otherwise it is null, as are failed metadata
21reads. SQLite diagnostics, filenames, table/index names, expressions and row
22contents never appear in the output.
23
24The bounded JSON carries status, a reviewed failure message, per-check status,
25error count, a limit flag, at most five b-tree/page coordinates, metadata and
26elapsed milliseconds. Per-check results distinguish `findings`, `error` and
27`findings_and_error`, as well as `ok` and `not_run`. The count is the number of
28observed diagnostics and query/metadata failures, not unique corrupt pages:
29both checks can report the same damage. Each check stops at 100 findings.
30Failure, timeout and inability to write the report all exit nonzero.
31
32Known limitation: constraint violations may not be reported; this checks file
33structure. A CHECK-constraint fixture was not reported by the pinned SQLite
34driver. Per the controller's ruling, it is not an assertion or a claim of
35coverage. The permanent byte-flipped b-tree fixture proves structural damage
36is detected. The command doc comment records the same limitation.
37
38## Operator invocations after deployment
39
40Staging:
41
42```sh
43carlos run --app equipo-staging --account bds \
44 --console https://console.carloku.com \
45 --instance equipo-staging.bds.oncarlos.com --timeout 75s -- check-db
46```
47
48Production:
49
50```sh
51carlos run --app equipo --account oficina \
52 --console https://console.carloku.com \
53 --instance equipo.bds.oncarlos.com --timeout 75s -- check-db
54```
55
56These app/account/host values come from `scripts/staging-thin.py` and
57`scripts/upgrade-thin.sh`. Use the instance host, not the public alias. The
5875-second outer timeout allows the 60-second check to return its JSON.
59The local installed CARLOS CLI predates `run`; these commands require the
60run-capable CLI used by the controller. Platform source confirms its syntax.
61
62## Copy
63
64All seven `CopyDB*` messages and their Plan 3 inventory rows carry
65`COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26)`, explicitly approved by the
66controller. Per-check status values are machine-readable enums. No unreviewed
67operator prose or raw database errors are emitted.
68
69## Tests and mutations
70
71Tests were written first; the initial run failed to compile on the missing
72check-db symbols. Implemented tests cover an intact live WAL database, a
73flipped b-tree page, write refusal even with `query_only` disabled, reading
74committed WAL data, clean missing/invalid paths, command dispatch without app
75configuration, diagnostic redaction and bounds, findings versus query errors,
76the command's own deadline, and output failure.
77
78Local commands use `GOMAXPROCS=2 GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0` and `-p 1`.
79Each mutation is applied alone, runs
80`go test -p 1 ./cmd/equipo -run TestCheckDB -count=1`, and is restored. A kill
81requires a runtime assertion failure; compilation errors do not count.
82
83Mutation results and final gate results are recorded below before handoff.
84Full local suites and simulators are deliberately avoided under the
85controller's loaded-machine ruling. Linux CI is the full gate. This CLI-only
86change adds no route, schema, protocol or performance endpoint record.
87
88All 17 mutations were killed at runtime:
89
90- Change `mode=ro` to `mode=rw`; add `immutable=1`.
91- Remove the command's deadline; change the fixed 60-second bound.
92- Remove the five-issue bound; emit raw diagnostic text; exceed 100 findings.
93- Skip quick_check; skip integrity_check.
94- Ignore the final row error; report a query failure as success.
95- Ignore output failure; return success despite integrity findings.
96- Remove the absolute-path check; remove the regular-file check.
97- Remove check-db dispatch; accept extra arguments.
98
99Restored focused tests passed (`TestCheckDB|TestCheckGitHub`).
100`make fmt-check budget copy-release-check` passed. The sole size allowance
101change is the measured nine source lines for approved operator copy:
102`internal/equipo` 23239 to 23248. No timing budget changes.
103Post-commit dead-reference results and Linux CI are reported with the pushed
104SHA in the handoff.
105
106## Inventory gate follow-up
107
108CI at `70831711` caught a missing entry in the inventory test's explicit
109key/date acceptance list. The seven new keys now require the exact approved
110`COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26)` status in that list. No generic
111scanner rule was widened. `git fetch origin` and `git merge origin/main`
112reported already up to date at main `8a3f1d92`.
113
114`go test -p 1 ./internal/plan3test -run '^TestPlan3ReleaseBoundaries$' -count=1`
115passed (4.262s), and `python3 scripts/plan3-copy-check.py` passed. The measured
116Plan 3 test budget increases by two lines, 11976 to 11978, for that acceptance
117entry. The earlier statement about the sole size allowance applies to the
118initial implementation; this follow-up also adjusts the measured test count.
119