Skip to content

New devices show trust_weight 1.00, then silently drop to 0.50 #15

Description

@jbrahy

A freshly enrolled device reports trust_weight = 1.00, then becomes 0.50 the first time cmd/recompute runs. Nothing is broken, but it looks broken, and it cost real time to explain during the first device session.

Cause: the schema column default and the formula disagree.

  • internal/db/migrations/0001_init.up.sql defaults trust_weight to 1.00
  • internal/trust.Compute returns TrustBase = 0.5 for a device with no reports and no tenure — tenure contributes ageDays/30 * 0.5, volume reportCount * 0.05, both zero at enrolment

So every device starts optimistic and is corrected downward within fifteen minutes. Anyone watching the table sees an unexplained halving.

What to do

Pick one and make it deliberate:

  1. Align the default to 0.50 so the stored value matches what the formula would compute. Simplest, and makes the two sources of truth agree.
  2. Compute the weight at insert rather than relying on a column default, so there is only one source of truth.
  3. Keep 1.00 deliberately as a grace period for new devices, and document it as intentional in both the migration and internal/trust.

Option 3 is defensible — being briefly generous to a new device is a reasonable product choice — but right now it is not a choice, it is an accident.

Note that changing the default needs a new migration (0006_*); do not edit 0001, which has already been applied in production.

Where to look

  • internal/trust/trust.goCompute, TrustBase
  • internal/db/migrations/0001_init.up.sql — the devices table
  • internal/store — where devices are inserted

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendGo / MySQL sidegood-first-issueSmall, well-scoped, no deep system knowledge required. Start here.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions