Repository navigation
Expand file tree
/
Copy path0007_install_proof.sql
More file actions
30 lines (29 loc) · 1.76 KB
/
Copy path0007_install_proof.sql
File metadata and controls
30 lines (29 loc) · 1.76 KB
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
-- codegraph telemetry — the proof a machine's installed day is worked out from.
--
-- 0006 kept one day per machine, `installed_day`, and moved it as events arrived.
-- Which day it ended on then depended on the order they arrived in: an upgrade
-- stored before the agent start of the same day dated a machine to its first day,
-- and the same two rows read the other way round dated it to the day of the
-- upgrade, as a new user. The pass over stored rows and the ingest path disagreed
-- on the commonest case there is.
--
-- So the proof is kept, each kind by its earliest day, and the day is worked out
-- from it. A minimum does not care about order, and neither does a rule applied
-- to three minimums and the machine's first day (INSTALLED_DAY_SQL in
-- src/rollup.ts):
--
-- * a machine first seen before the records now held begin has been a user
-- since its first day, if it is one at all: the rows that could say when it
-- was installed are gone;
-- * an upgrade with no first-time install on or before it, and no agent start
-- before it, proves an install older than anything on record: its first day;
-- * otherwise the earlier of its first-time install and its first agent start.
--
-- Three nullable columns with no default: none of these statements reads or
-- rewrites the table.
-- The earliest day the installer set CodeGraph up on a machine that had no setup.
ALTER TABLE machine_first_seen ADD COLUMN fresh_install_day TEXT;
-- The earliest day an agent started the engine on it (the MCP server, a tool call, the prompt hook).
ALTER TABLE machine_first_seen ADD COLUMN agent_day TEXT;
-- The earliest day of an upgrade: the `upgrade` command, or an installer run that found a setup to refresh.
ALTER TABLE machine_first_seen ADD COLUMN upgrade_day TEXT;