about summary refs log tree commit diff
path: root/docs
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-11-15 14:41:16 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-11-15 14:41:16 +0000
commitedaef7fd56e4ce7acd833e929462293478025a34 (patch)
tree3c8cc2166fd3c3e057842fa0d08a8b9d03dcc59f /docs
parent532825fed53fddb4f8f8f750986f7f9ab2a3d5dc (diff)
downloadgenenetwork4-edaef7fd56e4ce7acd833e929462293478025a34.tar.gz
correlation: the matrix endpoint, and the rule that a deploy ends with a monitor run
`POST /compute/correlation/matrix` takes a list of `{dataset, trait_name}`
references -- a collection, as GN2's matrix form posts it, which spans
datasets -- and answers an N x N matrix of r, p and n.

The five decisions that are not obvious, each recorded where a reader will
look for them:

* **One method for the whole matrix.** GN2's `show_corr_matrix.py` flips to
  Spearman mid-row once a Pearson r passes 0.999, which the self-pair always
  does, so its matrix is asymmetric by construction. Here the method is
  chosen once and r[i][j] == r[j][i] exactly.
* **Each unordered pair is computed once and mirrored** -- N(N-1)/2 engine
  calls, not N^2.
* **The diagonal is by construction**: r = 1, p = null, n = the trait's own
  count, so half the traits cannot come back as 1.0000000000000002 with a
  NaN p.
* **Per-cell n is its own matrix**, and a cell under `min_overlap` (default
  6) is null in r and p while its n still says how many points there were.
  GN2 accepts 2, where |r| = 1 by definition.
* **The sample axis is the first trait's group** (#106), resolved once and
  stated in the reply with the number of individuals it kept.

Fetches are one query per dataset (`get_dataset_values_for_traits`,
`get_publish_values_for_traits`), not one per trait: a matrix chooses a
handful out of twenty thousand. Capped at 1 000 traits, because the cost is
quadratic in the correlations and in the reply. No PCA -- the r matrix has
to be trusted on its own first.

Verified twice: cells agree with scipy to the last bit (BXDPublish
10001/10002/10005: 0.6756270426459695, 0.6950450737755965,
0.8819879006700077 against scipy 0.6756270426459695, 0.6950450737755964,
0.8819879006700073), and a cell equals what the row endpoint says for the
same pair (0.6950450737755965 in both). Edge cases exercised: a 1x1 matrix,
`min_overlap` above every cell's n, an unknown trait, `bicor`, and no
traits at all.

The operator checklist now says a deploy ends with `bin/monitor-gn4 --tier
all`, and says why: `/version` can report a commit and a reachable database
while every engine that shells out is dead. The monitor gained a matrix
check whose judge enforces square, symmetric and a unit diagonal.
Diffstat (limited to 'docs')
-rw-r--r--docs/www/operator-checklist.md19
1 files changed, 17 insertions, 2 deletions
diff --git a/docs/www/operator-checklist.md b/docs/www/operator-checklist.md
index 8fe695b..2ff4b82 100644
--- a/docs/www/operator-checklist.md
+++ b/docs/www/operator-checklist.md
@@ -391,8 +391,23 @@ runuser -u wrk -- /home/wrk/tmp/ai-root/factory/gn4-prod/run.sh restart
 `run.sh` also takes `start`, `stop` and `status`; the instances log to
 `factory/gn4-prod/logs/<port>.log` (appending across restarts, so the access
 lines survive a deploy). Deploying is therefore: `guix build -f guix.scm`,
-edit `env.sh`'s `GEN4=`, `run.sh restart`, then check `/version` (it reports
-the commit and `database: reachable`).
+edit `env.sh`'s `GEN4=`, `run.sh restart`.
+
+**Then run the monitor. Every time, without being asked:**
+
+```sh
+bin/monitor-gn4 --token-file /tmp/prodtok.file --tier all
+```
+
+`/version` only says which commit is running; it cannot see that an engine
+lost its tool path, that a config key moved, or that an endpoint now answers
+a shape nobody expected. On 2026-11-15 the service was "deployed and up" with
+`database: reachable` while **every** shell-out engine answered 502 and
+`/search` answered 502 in 1.4 ms, and the only thing that caught it was this
+monitor. A deploy that has not been through it is not finished. Expect
+`39+ ok, 0 failed` and read any skip: the `listener` check skips whenever the
+service runs outside the monitor's PID namespace, which is normal on this box
+and is the only skip that should ever appear.
 
 Everything mutable is under `factory/gn4-prod/` — `tokens.sqlite` (the only
 copy: losing it loses every token), `gemma-cache`, `rqtl-cache`,