Skip to content

fix(db): default new-device trust_weight to 0.50 (#15) - #23

Merged
jbrahy merged 3 commits into
Hushield:mainfrom
MrBeldum:fix/trust-weight-default-15
Sep 10, 2026
Merged

fix(db): default new-device trust_weight to 0.50 (#15)#23
jbrahy merged 3 commits into
Hushield:mainfrom
MrBeldum:fix/trust-weight-default-15

Conversation

@MrBeldum

@MrBeldum MrBeldum commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

New devices omitted trust_weight on insert and inherited DEFAULT 1.00, then dropped to 0.50 on first recompute (trust.TrustBase).

  • Migration 0006 sets the column default to 0.50 (does not rewrite 0001)
  • api.upsertDevice now writes trust.TrustBase explicitly on enrolment
  • Tests cover schema default + enrolment insert path

Fixes #15

Test plan

  • Migration count / COLUMN_DEFAULT assertions updated
  • TestUpsertDevice_EnrolmentTrustMatchesTrustBase + happy-path trust check
  • go test ./internal/trust/ ./internal/api/ ./internal/db/ (DB tests skip without MySQL locally)

Align the devices.trust_weight column default with trust.TrustBase so
enrolment no longer shows 1.00 until the first recompute.

Fixes Hushield#15
Omit reliance on the column default alone: upsertDevice now writes
trust.TrustBase explicitly, and tests cover both the insert path and the
schema default after migration 0006.
@jbrahy
jbrahy merged commit 52184d5 into Hushield:main Sep 10, 2026
jbrahy added a commit that referenced this pull request Sep 12, 2026
CI's govulncheck step fails on five Go standard library vulnerabilities
present in 1.26.5 and fixed in 1.26.6: GO-2026-6089, GO-2026-5972,
GO-2026-5026 and two others reached through net/http, encoding/asn1 and
crypto/tls from cmd/server, internal/push, internal/attest and
internal/api.

This is what has actually been failing CI, and it matters more than a
red badge: govulncheck runs BEFORE "go test (race + cover)", and its
failure SKIPS the test step entirely. Every run since these advisories
landed reported a failure without ever executing a single Go test. That
is how the stale e2e expectation in 52184d5 (#23) reached main claiming
"CI covers those" -- CI had stopped running the tests it was said to
cover.

Worth considering separately: a security scanner that silently disables
the test suite when it trips is the wrong ordering. Running go test
before govulncheck, or continue-on-error on the scan, would keep test
results visible while a stdlib advisory is outstanding.

go.mod pins the version and CI reads it via go-version-file, so this one
line moves both.

Verified under 1.26.6: govulncheck reports no vulnerabilities, gofmt and
go vet are clean, and go test ./... -race -cover passes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PBmEXErCWYt3WZCZKaS7m9
jbrahy added a commit that referenced this pull request Sep 12, 2026
…expectations (#25)

CI was failing at govulncheck on five Go stdlib vulnerabilities in 1.26.5,
fixed in 1.26.6. govulncheck runs BEFORE "go test", and its failure SKIPS the
test step, so every run since those advisories reported a failure without
executing a single Go test.

- build: bump the Go toolchain to 1.26.6. go.mod pins it and CI reads it via
  go-version-file, so one line moves both.
- fix(api): restore the e2e block path. 52184d5 (#23) changed new-device
  trust_weight from 1.00 to TrustBase (0.50) and left
  TestEndToEnd_FullLifecycle asserting the old arithmetic. numberA now uses
  six reporters so it genuinely blocks (six score 6.0 against a threshold of
  5.0; five would hit it exactly, which decay makes unsafe), numberB uses
  three to clear the same margin problem, and a guard fails loudly naming any
  scoring constant that moves again.

Note for follow-up: ordering a security scanner ahead of the test suite means
a stdlib advisory silently disables all test feedback. Running go test first,
or continue-on-error on the scan, would avoid a repeat.

Consequence of #23 that the stale assertion was hiding: a number now needs
FIVE fresh-device scam reports to auto-block, up from three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New devices show trust_weight 1.00, then silently drop to 0.50

2 participants