Skip to content

fix(memory): device-fence PAL finding auto-close + harden device identity - #187

Merged
sandstream merged 1 commit into
mainfrom
claude/headroom-kit-integration-cmjw7t
Jun 30, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/headroom-kit-integration-cmjw7t

Conversation

@sandstream

Copy link
Copy Markdown
Owner

What

Track C — adversarial hardening of the new 3.0 surface. Two findings in the device-coupled PAL, both fixed here.

HIGH — finding auto-close was device-blind (a real security blocker could be silently cleared across devices)

palSyncFindings auto-closed findings purely by source-tag + scope, with no origin_device predicate. And findingPalId derived the id from only sourceTag + dedupKey (repo-independent), so on a shared/synced store the finding id was identical across machines. Consequence: a kit check on device B that didn't see device A's open finding would permanently close A's blocker — the exact inverse of what device-coupling is meant to guarantee. As a bonus bug, two different repos that merely shared a directory basename reconciled into each other's findings.

Fix:

  • fold scope into the finding id → different repos get distinct ledger rows
  • scope by the absolute project root, not its basename (findings-track.ts, health-track.ts)
  • device-fence the auto-close: origin_device = thisDevice OR origin_device IS NULL (legacy pre-v5 NULL-origin rows stay reconcilable by any device)
  • re-attribute origin on reopen so the device observing a recurrence is the one reminded

A genuinely-cleared finding now lingers until the owning device re-scans — fail-safe (a stale reminder, never a dropped blocker).

MEDIUM — device identity was a guessable hostname hash

deviceId() was sha256(hostname+user): guessable by any peer on a shared store (enabling cross-device surface/suppression of items) and unstable across hostname churn (a DHCP lease or rename would silently orphan a device's own items). Now:

  • prefers a random id persisted once to <memoryDir>/device-id (0600) — unguessable, survives hostname drift
  • validates the KIT_DEVICE_ID override against [A-Za-z0-9_-]{1,64} (malformed → ignored, not trusted)
  • hostname hash kept only as a last-resort fallback when the id file can't be written

Also

Restores the ## [3.0.0] - 2026-06-30 CHANGELOG header that an earlier [Unreleased] edit (shipped in #186) accidentally dropped, which had orphaned the entire 3.0.0 release block under [Unreleased].

Tests

3 new regression tests: device B does NOT close device A's finding on a shared store (and the owning device still can); same finding in two repos → two rows; legacy NULL-origin findings reconcilable by any device. Full suite 1979 green, prettier clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg


Generated by Claude Code

…tity

Track C adversarial hardening of the 3.0 surface.

HIGH — palSyncFindings auto-closed findings by source-tag + scope only, with no
origin_device predicate. Since the finding id was derived from sourceTag+dedupKey
(repo-independent), it was identical across machines on a shared/synced store, so
a scan on device B that didn't see device A's open finding would permanently
close A's security blocker; two repos sharing a basename also collided.
  - fold scope into the finding id (distinct rows per repo)
  - scope by absolute project root, not basename (findings-track, health-track)
  - device-fence the auto-close (origin_device = thisDevice OR NULL); legacy
    NULL-origin rows stay reconcilable by any device
  - re-attribute origin on reopen so the observing device is reminded
  A cleared finding now lingers until the owning device re-scans — fail-safe.

MEDIUM — deviceId() was sha256(hostname+user): guessable by a peer on a shared
store and unstable across hostname churn (silently orphaning a device's items).
Now prefers a random id persisted to <memoryDir>/device-id (0600); validates the
KIT_DEVICE_ID override against [A-Za-z0-9_-]{1,64}; hostname hash is last resort.

Also restores the `## [3.0.0]` CHANGELOG header dropped by the #186 Unreleased
edit (the 3.0.0 block was orphaned under [Unreleased]).

3 new regression tests; full suite 1979 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit fefc95b into main Jun 30, 2026
17 checks passed
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.

2 participants