hub v0.133.0 (R-859 test approvals end with the test; R-840 bundle on the System page, manifest, alarm); installer 1.31.0 (root files from the config bundle); bundle bootstrap script; golden 0.293.0 evidence; rulings 96–99; drill-r50 removed (evidence)
gates / gates (push) Successful in 29s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-04 20:18:37 +02:00
1 parent 6b820143f8
commit ff1db11db4
45 files changed
+1707 -42

No files matched your search

+103 -9
View File
@@ -53,9 +53,42 @@ func (s *Store) migrateOSUpdates() error {
// Host fast lane (hub v0.131.0): every report and release belongs to a LAYER; old rows are the guest's.
s.db.Exec(`ALTER TABLE os_reports ADD COLUMN layer TEXT NOT NULL DEFAULT 'guest'`)
s.db.Exec(`ALTER TABLE os_releases ADD COLUMN layer TEXT NOT NULL DEFAULT 'guest'`)
// Test approvals end with the test (hub v0.133.0, `11` §5.3.1): an approval made while a TEST override is active
// carries `test`; a start without the override CANCELS every test approval no real one has superseded.
if !s.hasColumn("os_releases", "test") {
if _, err := s.db.Exec(`ALTER TABLE os_releases ADD COLUMN test INTEGER NOT NULL DEFAULT 0`); err != nil {
return err
}
// One-time backfill, from the data: an AUTOMATIC approval earlier than 24 h after its set was first seen
// cannot have passed the ruled wait (24 h + one night) — it was a TEST approval (2026-10-04: the guest and host
// sets, approved 1.5 h after first seen under OS_APPROVE_*). The operator's own Docker button approval of that day
// is NOT backfilled: a person approved it; the override only shortened its precondition (decided by CC
// unattended — operator may reverse). From hub v0.133.0 on, every approval under an override is marked.
s.db.Exec(`UPDATE os_releases SET test = 1 WHERE approved_by = 'auto' AND EXISTS (SELECT 1 FROM os_candidates c
WHERE c.fingerprint = os_releases.fingerprint
AND (julianday(os_releases.approved_at) - julianday(c.first_seen)) * 24 < 24)`)
}
s.db.Exec(`ALTER TABLE os_releases ADD COLUMN cancelled_at TEXT NOT NULL DEFAULT ''`)
s.db.Exec(`ALTER TABLE os_releases ADD COLUMN cancel_reason TEXT NOT NULL DEFAULT ''`)
return nil
}
// hasColumn reports whether table has the column (PRAGMA table_info).
func (s *Store) hasColumn(table, col string) bool {
rows, err := s.db.Query(`SELECT name FROM pragma_table_info(?)`, table)
if err != nil {
return false
}
defer rows.Close()
for rows.Next() {
var n string
if rows.Scan(&n) == nil && n == col {
return true
}
}
return false
}
// OSHostSettings is one box's ring and switch.
type OSHostSettings struct {
HostID string
@@ -191,6 +224,22 @@ type OSRelease struct {
ApprovedAt time.Time
ApprovedBy string
PackagesJSON string
Test bool // approved while a TEST override was active (`11` §5.3.1)
CancelledAt string // "" = in force; a cancelled release is never served (LatestOSRelease skips it)
CancelReason string
}
const osReleaseCols = `id, layer, fingerprint, approved_at, approved_by, packages_json, test, cancelled_at, cancel_reason`
func scanOSRelease(sc interface{ Scan(...any) error }) (*OSRelease, error) {
var r OSRelease
var at string
var test int
if err := sc.Scan(&r.ID, &r.Layer, &r.Fingerprint, &at, &r.ApprovedBy, &r.PackagesJSON, &test, &r.CancelledAt, &r.CancelReason); err != nil {
return nil, err
}
r.ApprovedAt, r.Test = parseSQLiteTime(at), test == 1
return &r, nil
}
// SaveOSRelease stores an approved release.
@@ -199,25 +248,70 @@ func (s *Store) SaveOSRelease(r OSRelease) error {
if layer == "" {
layer = "guest"
}
_, err := s.db.Exec(`INSERT INTO os_releases (id, layer, fingerprint, approved_at, approved_by, packages_json) VALUES (?, ?, ?, ?, ?, ?)`,
r.ID, layer, r.Fingerprint, r.ApprovedAt.UTC().Format("2006-01-02 15:04:05"), r.ApprovedBy, r.PackagesJSON)
test := 0
if r.Test {
test = 1
}
_, err := s.db.Exec(`INSERT INTO os_releases (id, layer, fingerprint, approved_at, approved_by, packages_json, test) VALUES (?, ?, ?, ?, ?, ?, ?)`,
r.ID, layer, r.Fingerprint, r.ApprovedAt.UTC().Format("2006-01-02 15:04:05"), r.ApprovedBy, r.PackagesJSON, test)
return err
}
// LatestOSRelease returns the newest approved release of a layer, or nil.
// LatestOSRelease returns the newest approved release of a layer that is IN FORCE (not cancelled), or nil.
func (s *Store) LatestOSRelease(layer string) (*OSRelease, error) {
var r OSRelease
var at string
err := s.db.QueryRow(`SELECT id, layer, fingerprint, approved_at, approved_by, packages_json FROM os_releases WHERE layer = ? ORDER BY approved_at DESC, id DESC LIMIT 1`, layer).
Scan(&r.ID, &r.Layer, &r.Fingerprint, &at, &r.ApprovedBy, &r.PackagesJSON)
r, err := scanOSRelease(s.db.QueryRow(`SELECT `+osReleaseCols+` FROM os_releases WHERE layer = ? AND cancelled_at = ''
ORDER BY approved_at DESC, id DESC LIMIT 1`, layer))
if err == sql.ErrNoRows {
return nil, nil
}
return r, err
}
// UnsupersededTestReleases returns a layer's test releases still in force and newer than its newest REAL (non-test,
// in-force) release — the ones a start without the TEST override must cancel. Newest first.
func (s *Store) UnsupersededTestReleases(layer string) ([]OSRelease, error) {
rows, err := s.db.Query(`SELECT `+osReleaseCols+` FROM os_releases r WHERE r.layer = ? AND r.test = 1 AND r.cancelled_at = ''
AND r.approved_at >= COALESCE((SELECT MAX(approved_at) FROM os_releases WHERE layer = r.layer AND test = 0 AND cancelled_at = ''), '')
ORDER BY r.approved_at DESC, r.id DESC`, layer)
if err != nil {
return nil, err
}
r.ApprovedAt = parseSQLiteTime(at)
return &r, nil
defer rows.Close()
var out []OSRelease
for rows.Next() {
r, err := scanOSRelease(rows)
if err != nil {
return nil, err
}
out = append(out, *r)
}
return out, rows.Err()
}
// CancelOSRelease marks one release cancelled (it is never served again; its row stays as the record).
func (s *Store) CancelOSRelease(id, reason string, at time.Time) error {
_, err := s.db.Exec(`UPDATE os_releases SET cancelled_at = ?, cancel_reason = ? WHERE id = ? AND cancelled_at = ''`,
at.UTC().Format("2006-01-02 15:04:05"), reason, id)
return err
}
// CancelledOSReleasesSince lists releases cancelled at or after t (the System page shows them), newest first.
func (s *Store) CancelledOSReleasesSince(t time.Time) ([]OSRelease, error) {
rows, err := s.db.Query(`SELECT `+osReleaseCols+` FROM os_releases WHERE cancelled_at != '' AND cancelled_at >= ?
ORDER BY cancelled_at DESC, id DESC`, t.UTC().Format("2006-01-02 15:04:05"))
if err != nil {
return nil, err
}
defer rows.Close()
var out []OSRelease
for rows.Next() {
r, err := scanOSRelease(rows)
if err != nil {
return nil, err
}
out = append(out, *r)
}
return out, rows.Err()
}
// BackdateOSCandidateForTest moves a candidate's first_seen into the past. TEST-ONLY.
+31 -2
View File
@@ -2118,6 +2118,10 @@ type ArtifactManifest struct {
// Recording the hash here does not fix the delivery channel (that is R-50b(b)/(c)) — it makes
// DRIFT VISIBLE, which is the cheap honest first step.
WrapperSHA256 string `json:"wrapper_sha256"`
// BundleSHA256 is the vouched agent version's CONFIG BUNDLE (R-840): every root-owned file the installer writes,
// published beside the binary as felhom-agent/<AgentVersion>/felhom-config-bundle.json. "" = the vouched agent
// carries none (older than v0.143.0). The installer installs exactly this; boxes behind it raise an alarm.
BundleSHA256 string `json:"bundle_sha256"`
}
// hub_settings keys for the artifact manifest (BUNDLE slice). Stored as discrete key/value rows in
@@ -2130,6 +2134,7 @@ const (
settingArtifactGoldenSHA256 = "artifact_golden_sha256"
settingArtifactMinAgent = "artifact_min_agent"
settingArtifactWrapperSHA256 = "artifact_wrapper_sha256" // R-50b(a): the vouched felhom-pbs-apply hash
settingArtifactBundleSHA256 = "artifact_bundle_sha256" // R-840: the vouched agent's config bundle
)
// settingOperatorPasswordHash is the hub_settings key for the operator login password bcrypt hash,
@@ -2178,6 +2183,7 @@ func (s *Store) GetArtifactManifest() ArtifactManifest {
GoldenSHA256: s.getSetting(settingArtifactGoldenSHA256),
MinAgent: s.getSetting(settingArtifactMinAgent),
WrapperSHA256: s.getSetting(settingArtifactWrapperSHA256),
BundleSHA256: s.getSetting(settingArtifactBundleSHA256),
}
}
@@ -2199,7 +2205,30 @@ func (s *Store) SetArtifactManifest(m ArtifactManifest) error {
if err := s.setSetting(settingArtifactMinAgent, m.MinAgent); err != nil {
return err
}
return s.setSetting(settingArtifactWrapperSHA256, m.WrapperSHA256)
if err := s.setSetting(settingArtifactWrapperSHA256, m.WrapperSHA256); err != nil {
return err
}
return s.setSetting(settingArtifactBundleSHA256, m.BundleSHA256)
}
// BundleBehindSince returns since when a box's config bundle has differed from the vouched one (zero = it matches, or
// was never seen behind). R-840's 7-day alarm counts from here.
func (s *Store) BundleBehindSince(hostID string) time.Time {
v := s.getSetting("bundle_behind_since:" + hostID)
if v == "" {
return time.Time{}
}
t, _ := time.Parse(time.RFC3339, v)
return t
}
// SetBundleBehindSince records (or, with a zero time, clears) the first moment a box was seen behind.
func (s *Store) SetBundleBehindSince(hostID string, t time.Time) error {
v := ""
if !t.IsZero() {
v = t.UTC().Format(time.RFC3339)
}
return s.setSetting("bundle_behind_since:"+hostID, v)
}
// EffectiveMinControllerVersion resolves the floor that actually applies to a customer: the
@@ -3487,7 +3516,7 @@ func (s *Store) SaveHostReport(hostID, customerID string, reportJSON []byte, d H
func (s *Store) GetLatestHostReportJSON(customerID string) (string, error) {
var j string
err := s.db.QueryRow(
`SELECT report_json FROM host_reports WHERE customer_id = ? ORDER BY received_at DESC LIMIT 1`,
`SELECT report_json FROM host_reports WHERE customer_id = ? ORDER BY received_at DESC, id DESC LIMIT 1`,
customerID,
).Scan(&j)
if err == sql.ErrNoRows {