Skip to content

State: atomic save/load with secure dir + quarantine + advisory lock #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 20, 2025

Conversation

heusalagroupbot
Copy link
Collaborator

Scope

  • Adds atomic snapshot save with fsync and latest.json pointer
  • Implements load with integrity checks and quarantine
  • Introduces coarse advisory lock and secure dir validation

Why

  • Reliable, secure persistence for state bundle

Testing

  • Focused: === RUN TestLoadLatestStateBundle_OK
    --- PASS: TestLoadLatestStateBundle_OK (0.02s)
    === RUN TestLoadLatestStateBundle_RejectsInsecureDir
    --- PASS: TestLoadLatestStateBundle_RejectsInsecureDir (0.01s)
    === RUN TestLoadLatestStateBundle_MissingLatest
    --- PASS: TestLoadLatestStateBundle_MissingLatest (0.00s)
    === RUN TestLoadLatestStateBundle_CorruptLatest
    --- PASS: TestLoadLatestStateBundle_CorruptLatest (0.00s)
    === RUN TestLoadLatestStateBundle_UnknownVersion
    --- PASS: TestLoadLatestStateBundle_UnknownVersion (0.02s)
    === RUN TestLoadLatestStateBundle_MissingSnapshot
    --- PASS: TestLoadLatestStateBundle_MissingSnapshot (0.00s)
    === RUN TestLoadLatestStateBundle_PermissionDenied
    --- PASS: TestLoadLatestStateBundle_PermissionDenied (0.01s)
    === RUN TestLoadLatestStateBundle_SnapshotHashMismatch_QuarantineBoth
    --- PASS: TestLoadLatestStateBundle_SnapshotHashMismatch_QuarantineBoth (0.02s)
    === RUN TestLoadLatestStateBundle_CorruptSnapshotJSON_QuarantineBoth
    --- PASS: TestLoadLatestStateBundle_CorruptSnapshotJSON_QuarantineBoth (0.01s)
    === RUN TestSaveStateBundle_WritesFilesAtomicallyWithPermsAndPointer
    --- PASS: TestSaveStateBundle_WritesFilesAtomicallyWithPermsAndPointer (0.02s)
    === RUN TestSaveStateBundle_AdvisoryLock_AllowsSingleWriter
    === PAUSE TestSaveStateBundle_AdvisoryLock_AllowsSingleWriter
    === RUN TestSaveStateBundle_InvalidBundle
    --- PASS: TestSaveStateBundle_InvalidBundle (0.00s)
    === RUN TestSaveStateBundle_SanitizesSecretsAndRejectsInsecureDir
    --- PASS: TestSaveStateBundle_SanitizesSecretsAndRejectsInsecureDir (0.01s)
    === CONT TestSaveStateBundle_AdvisoryLock_AllowsSingleWriter
    --- PASS: TestSaveStateBundle_AdvisoryLock_AllowsSingleWriter (0.11s)
    PASS
    ok github.com/hyperifyio/goagent/internal/state 0.265s

Relation

Tracking

  • Will record under and on develop.

goagent bot added 2 commits August 19, 2025 17:40
…ync; quarantine + coarse advisory lock; tests and secure dir checks
heusalagroupbot pushed a commit that referenced this pull request Aug 19, 2025
@heusalagroupbot
Copy link
Collaborator Author

Detected dependency: blocked by #50 — State: versioned StateBundle schema. Reason: save/load builds on the schema introduced in #50; please review/merge #50 first. I’ll park behavior‑changing edits here and proceed with safe prep only while continuing the sweep on unblocked PRs.

Copy link

@thejhh thejhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine

@thejhh thejhh marked this pull request as ready for review August 20, 2025 19:50
@thejhh thejhh merged commit 5c0326c into main Aug 20, 2025
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