Repository navigation
feat(ios): add VaultRegistry and UnlockAttemptThrottle for Encrypted Vaults - #305
Conversation
📱 iOS Build Status: PASSED✅ iOS Simulator Build & Unit Tests - success iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
QA verification — PR #305 vs issue #301Acceptance criteria (from #301)
Tests runNo macOS/Xcode toolchain is available in this sandbox either (same limitation the PR description flags), so I did not run this repo's All 20 tests in Confirmed the tests aren't vacuous (AGENTS.md "prove a new test can fail" / this repo's Pocket-TTS mock-past-the-bug history) by breaking two things and re-running:
Both breaks were reverted after confirming red, no repo files were touched ( The diff is iOS-only (4 new files under Regressions / other checks
AGENTS.md conventions — violation foundTests exist for non-trivial changes (pass), Conventional Commits format (pass), no hardcoded versions (pass, N/A). But: "Keep
Fix: rebase this branch onto current The two production files and their tests are solid on their own merits — this is a process gap, not a code defect — but per AGENTS.md ("flag violations even if functionally the change works") and given the safety intent it defeats if unaddressed, I can't pass this as-is. QA verdict: FAIL |
| QA failed its first round — routing back to the dev agent for one automated retry. |
d930fc3 to
60e21a9
Compare
60e21a9 to
02ac244
Compare
📱 iOS Build Status: PASSED✅ iOS Simulator Build & Unit Tests - success iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
Dev agent — addressed QA round 1 feedbackQA's only finding was a process gap, not a code defect: this branch was still based on the pre-#300 commit of Fixed:
Note for anyone reading the Actions history: the first re-push (via the default Production code and tests are unchanged from the original submission — only the base commit and PR description moved. |
|
This PR's branch is stale relative to |
|
Automated pipeline health check: Diagnosed the stale-branch comment above — not self-healing it, flagging for a human instead. This is the documented #254 stale-branch/OIDC pattern ( Net: a human needs to rebase this branch onto current Generated by Claude Code |
…Vaults Swift equivalents of Android's core:vaultstore VaultRegistry.kt and UnlockAttemptThrottle.kt, split out of #201/#190 as the two pieces of that scope with no cryptographic risk of their own. - VaultRegistry: plaintext JSON list of which vaults exist (id, display name, created-at), backed by a file under a caller-supplied base directory. Mirrors the Android type's atomic write-to-temp-then-rename and accepted-residual-leak reasoning (docs/threat-model.md). - UnlockAttemptThrottle: same pure exponential-backoff math as Android's object, unit-testable with no I/O. Its state (failedAttempts, lastAttemptEpochMillis) is persisted per-vault by the new UnlockAttemptThrottleStore, matching the "per-vault config file" location docs/threat-model.md already documents for this data - kept as its own small file rather than folded into a VaultConfig type, since iOS has no such crypto-config persistence yet. Both types depend only on Foundation - no Keystore/Secure Enclave, no networking - and are exercised by new XCTest suites mirroring Android's VaultRegistryTest.kt/UnlockAttemptThrottleTest.kt coverage, including a persistence round-trip test for the throttle store. No Xcode/macOS toolchain is available in the dev-agent's sandbox, so the new files were verified with the Linux Swift toolchain instead: a type-check compile, a standalone runtime sanity script exercising both types end-to-end, and the actual test files running green under a throwaway SwiftPM package (20/20 passed), with one assertion deliberately broken first to confirm it fails red. CI's "iOS App Build & Test" job (xcodebuild against the real Xcode project) is the authoritative run. Closes #301
02ac244 to
ed2e83a
Compare
|
Human rebase (via Claude Code), per the pipeline health check's ask above. Rebased onto current |
QA verification — PR #305 vs issue #301Investigation method note: No macOS/Xcode toolchain is available in this Acceptance criteria (from #301)
What I ranBuilt the exact committed files (2 production + 2 test files, byte-identical copies from the working tree — nothing rewritten) into a throwaway SwiftPM package and ran All 20 tests (6 Confirmed the tests can actually fail (AGENTS.md "prove a new test can fail" rule), independently of the PR author's own claimed check: mutated Went red as expected, then reverted. The test suite genuinely exercises the real backoff math, not a mock. Regression / related-area check
Risk-classification note (verified, not just trusted)The PR body claims this branch was rebased onto
AGENTS.md conventions
No gaps found against the issue's acceptance criteria or the repo's testing conventions. QA verdict: PASS |
📱 iOS Build Status: PASSED✅ iOS Simulator Build & Unit Tests - success iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
Principal review — PR #305Verdict: human-merge ( Risk label sanity checkCommits landed after Ground-truth verification (not taking the PR/QA claims at face value)
FindingsNo CONFIRMED blocking defects. One minor, non-blocking observation for whoever builds the first caller on top of these types:
The two production types and their tests are solid: no crypto/Keychain/networking imports, atomic writes, tests mirror the Kotlin suite 1:1 and were confirmed non-vacuous by the QA agent's break-and-reverify pass. Routing to human-merge is purely the |
Summary
Swift equivalents of Android's
core:vaultstoreVaultRegistry.ktandUnlockAttemptThrottle.kt, split out of #201 (2/6 of #190's iOS Encrypted Vaults breakdown) as the two pieces of that scope with no cryptographic risk of their own. Depends on #200/#220 (crypto core) only for naming/style consistency, not behavior — noVaultCryptotypes are imported.New files under
ios/LibraVaultApp/LibraVault/LibraVault/Sources/VaultStore/:VaultRegistry.swift— plaintext JSON list of which vaults exist (id, display name, created-at epoch millis), persisted asvaults.jsonunder a caller-supplied base directory, withadd/remove/rename/list/vaultDir. Deliberately plaintext, same accepted-residual-leak reasoning as Android'svaults.json— seedocs/threat-model.md's "Accepted residual leaks" section. No key material or vault content ever touches this type. Writes useData.write(to:options:.atomic)for the same write-to-temp-then-rename atomicity Android's version gets fromFile.renameTo.UnlockAttemptThrottle.swift— the same pure exponential-backoff math as Android's object (3 free attempts, doubling delay capped at 5 minutes), takingfailedAttempts/lastAttemptEpochMillis/nowEpochMillisand returning a delay — no I/O, unit-testable with no device. Its state is persisted per-vault by a newUnlockAttemptThrottleStore(unlock-throttle.jsoninside the vault's own directory), matching the "per-vault config file, alongside the vault it protects" locationdocs/threat-model.md's data-inventory table already documents for this data. This is a standalone store rather than folded into aVaultConfig-equivalent type, because iOS has no such crypto-config persistence type yet (that's a different, not-yet-built piece of [Feature] iOS Encrypted Vaults 2/6: VaultStore equivalent + leak-closure guarantee #201) — it can be migrated into one later without changingUnlockAttemptThrottle's pure math.New tests under
ios/LibraVaultApp/LibraVault/LibraVaultTests/:VaultRegistryTests.swiftandUnlockAttemptThrottleTests.swift(covering both the pure throttle math and the newUnlockAttemptThrottleStorepersistence round-trip), mirroring the Android suites' case coverage (insertion order, duplicate-id rejection, no-op remove/rename of unknown ids, no stray.tmpfile after a write, delay growth/cap/non-negativity, throttle state surviving a freshread()call standing in for a process restart).Both new production types depend only on
Foundation— no Keychain, no Secure Enclave, no networking — satisfying the issue's "unit-testable without a real device" acceptance criterion.No
.pbxprojchanges needed:Sources/is aPBXFileSystemSynchronizedRootGroupin this project, so new files under it are picked up by Xcode automatically.Verification note
This dev-agent's sandbox has no macOS/Xcode toolchain, so I could not run the project's actual
xcodebuild testlocally. Instead I verified with the Linux Swift 6.3 toolchain (which has no access to the realLibraVaultXcode target or its@testable import):swiftctype-checked both new production files cleanly.UnlockAttemptThrottle's math (matching Android'sUnlockAttemptThrottleTest.ktfixture values, including the exponent cap) andVaultRegistry/UnlockAttemptThrottleStore's file round-trips end-to-end, asserting on real behavior rather than just compiling.min(base, max)instead ofmin(base << exponent, max)) and re-ran —testDelayIncreasesWithMoreConsecutiveFailureswent red as expected, confirming the test can actually fail, perAGENTS.md's "prove a new test can fail" rule.None of this substitutes for CI's "iOS App Build & Test" job (
xcodebuildagainst the real Xcode project onmacos-26), which is the authoritative signal for this PR and the one I could not reproduce locally. Flagging this explicitly rather than claiming full local verification.Risk / sensitive-path note
Issue #301 states this change "lands under
Sources/VaultStore/**, which #300 just made a forced-human-merge path." At the time this PR was opened, #300 was still open/unimplemented, so this diff initially classified asrisk:low. #300 has since merged todev(346f61a, 2026-08-19T05:21:09Z), addingios/LibraVaultApp/LibraVault/LibraVault/Sources/VaultStore/**toagent-policy.yml'ssensitive_paths— a glob every file in this diff matches. QA caught that this branch was still based on the pre-#300 commit, soclassify_pr_risk.pywas evaluating a stale copy of the policy and had appliedrisk:low.Fixed by rebasing this branch onto current
dev(clean rebase, no conflicts — the four new files here don't overlap #300's one-line policy change or #296). The diff itself is unchanged: still exactly the 4 new files underSources/VaultStore/**, 358 insertions, 0 deletions. With the branch now current,classify_pr_risk.pywill re-run against the real policy on this push and should applyrisk:high, forcing human merge as #300 intends. Flagging this explicitly so the principal review agent doesn't have to rediscover it from the diff alone.Acceptance criteria (from #301)
UnlockAttemptThrottleTest.ktcases) and persists across app restartCloses #301