Skip to content

fix(vault): code review cleanup batch (L1-L8) - #537

Closed
libravault-pipeline-bot[bot] wants to merge 5 commits into
devfrom
fix/code-review-cleanup-batch-l1-l8
Closed

libravault-pipeline-bot[bot] wants to merge 5 commits into
devfrom
fix/code-review-cleanup-batch-l1-l8

Conversation

@libravault-pipeline-bot

Copy link
Copy Markdown
Contributor

Summary

Batch fix for issue #530's 8 low-severity code review findings (L1-L8) across core/vaultcrypto, core/vaultstore, core/vaultcontent, feature/vault, and a few sampled elsewhere. Pushing incrementally — this draft opens after the first fix (L1); the rest land as follow-up commits on this branch.

  • L1 — VaultPlayerViewModel.onSkipForward collapsed "+30s" to 0 when duration is unknown (C.TIME_UNSET is negative, so clamping against duration.coerceAtLeast(0) clamped the target to 0). Extracted the target computation to a pure skipForwardTarget() helper, unit-tested directly.
  • L2 — Unlock throttle off-by-one (failedAttempts <= FREE_ATTEMPTS made the first 4 failures free, not 3) + wall-clock trust doc note
  • L3 — Keystore-key-deleted race (between forExistingKey() and unwrap()) escaping as a raw crash instead of UnlockOutcome.KeystoreKeyLost
  • L4 — VaultFileReader retaining vmk as a field, never zeroing derived key material on close()
  • L5 — SecureScreenEffect(enabled = remember { ... }) only reads the setting once per composition
  • L6 — allowBackup="false" vs. dead backup_rules.xml/data_extraction_rules.xml
  • L7 — Mermaid WebView: uncapped reportHeight(px), AssetsPathHandler exposing all bundled assets
  • L8 — Exported PlaybackService accepts all controllers (non-vault playback only)

Risk

Touches core/vaultcrypto/** and core/vaultstore/**, both on agent-policy.yml's sensitive_paths list — this will be force-classified risk:high regardless of size, which is correct here: L3/L4 change behavior in the Keystore-key-loss and key-zeroing paths of the vault unlock/read flow.

Closes #530.

VaultPlayerViewModel.onSkipForward clamped the skip target against
exo.duration.coerceAtLeast(0), which collapses to 0 while duration is
still C.TIME_UNSET (negative) — seeking to the very start of the book
instead of leaving the skip a plain forward nudge. Extracted the
target computation into skipForwardTarget() so it's unit-testable
without a real ExoPlayer.

Part of #530 (L1).
remainingDelayMillis used failedAttempts <= FREE_ATTEMPTS, so the first
FOUR failures (0, 1, 2, 3) all passed through free, contradicting the
FREE_ATTEMPTS = 3 constant's own name. Also documents the wall-clock
trust tradeoff (PRD §7): rolling the system clock forward can skip the
backoff, accepted deliberately since the hardware Keystore/TEE binding
is the actual gate, not this throttle.

Part of #530 (L2).
If the Keystore key is deleted between forExisting()'s existence check
and the subsequent unwrap() call inside unlockWithPin, the resulting
KeyStoreException escaped uncaught instead of mapping to
UnlockOutcome.KeystoreKeyLost — the same recovery-key fallback path
forExisting()'s own KeystoreKeyLostException catch already routes to.
Widened the catch to cover this race, without counting it toward the
failed-attempt throttle (same as the existing early-return path,
since the user didn't supply a wrong credential).

Part of #530 (L3).
vmk was retained as a field though it's only used in init to derive
fileContentKey — dropped to a plain constructor parameter. close()
now zeroes fileContentKey and the cached decrypted chunk instead of
leaving them in memory for as long as the (possibly GC-deferred)
reader instance survives.

Part of #530 (L4).
VaultContentsScreen/VaultReaderScreen/VaultPlayerScreen each read
VaultScreenSecurityPreference.isEnabled(context) once via a keyless
remember { }, so toggling the setting in feature:settings only took
effect the next time the screen recomposed from scratch (leave and
re-enter) — contradicting SecureScreenEffect's own doc comment
("toggling restores normal behavior immediately").

Added VaultScreenSecurityPreference.observe(), the same
OnSharedPreferenceChangeListener + callbackFlow pattern
core.storage.SupporterRepository.observe already uses, and a
rememberScreenSecurityEnabled() composable helper that collects it as
state. All three call sites now recompose live when the setting
changes elsewhere.

Part of #530 (L5).
@github-actions github-actions Bot added the status:needs-info Dev/QA agent needs more detail before proceeding label Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The dev agent's run failed (crashed or exhausted its turn budget) while producing this PR — routed to a human instead of silently advancing an unconfirmed fix to QA. See the workflow run log for what happened.

Copy link
Copy Markdown
Collaborator

Automated pipeline health check: Checked the job log for run 32752636837 (triage-and-implement, issue #530) behind the "crashed or exhausted its turn budget" comment above. This is a genuine hard max-turns cutoff, not a near-miss success or infra flake:

"num_turns": 121,
"stop_reason": "tool_use",
"terminal_reason": "max_turns",
"subtype": "error_max_turns"

dev-agent.yml's triage-and-implement step is currently configured at --max-turns 120 on dev — this is issue #530's first (and only) attempt, and it ran at the current cap and still exhausted it. Per this routine's rules, that's not eligible for a retry at the same cap value.

Worth flagging the pattern: this is the third confirmed hard max-turns exhaustion at cap 120 today (also PR #535/issue #531, PR #490/issue #5), all on genuinely large multi-file/security-sensitive scopes. Needs a fresh human decision — raise the cap again, or split #530's 8-finding batch (L1-L8, already checkbox-tracked in the PR body, only L1 done) into smaller PRs so each fits comfortably under 120 turns. Not self-healing.


Generated by Claude Code

@libravault-xyz

Copy link
Copy Markdown
Collaborator

Splitting this batch to unblock it — hit dev-agent's 120-turn cap after 5 of 8 findings (the PR's checklist under-reported progress; the diff actually has real, tested fixes for L1-L5). Re-filed as 8 independent issues so each fits comfortably under the turn cap: #564 (L1), #565 (L2), #566 (L3), #567 (L4), #569 (L5), #570 (L6), #572 (L7), #574 (L8). L1/L2/L3/L5 reference this PR's diff as a ready-to-rebase or reference implementation; L4 needs reconciling against #539's overlapping VaultFileReader.close() change, already merged to dev. Closing without merging — the branch stays around for reference until each split issue lands.

libravault-pipeline-bot Bot pushed a commit that referenced this pull request Aug 25, 2026
VaultContentsScreen/VaultPlayerScreen each read
VaultScreenSecurityPreference.isEnabled(context) once via a keyless
remember { }, so toggling the setting in feature:settings only took
effect the next time the screen recomposed from scratch (leave and
re-enter) — contradicting SecureScreenEffect's own doc comment
("toggling restores normal behavior immediately").

Added VaultScreenSecurityPreference.observe() in core:storage, the
same OnSharedPreferenceChangeListener + callbackFlow pattern
core.storage.SupporterRepository.observe already uses, and a
rememberScreenSecurityEnabled() composable helper in feature:vault
that collects it as state. Both call sites now recompose live when
the setting changes elsewhere.

Reimplemented against current dev rather than cherry-picking the
referenced PR #537 commit verbatim: #543 (merged after that commit
was written) moved SecureScreenEffect to core:ui and
VaultScreenSecurityPreference to core:storage, and deleted
VaultReaderScreen outright, so the original diff's file paths and
third call site no longer exist. observe() lives on
VaultScreenSecurityPreference itself (core:storage) since core:ui
does not depend on core:storage; rememberScreenSecurityEnabled()
lives in feature:vault, the only module currently gating
SecureScreenEffect on this preference.

Part of #530 (L5). Closes #569.
github-actions Bot added a commit that referenced this pull request Aug 25, 2026
…#571)

* fix(vault): make the "Screen Security" toggle take effect immediately

VaultContentsScreen/VaultPlayerScreen each read
VaultScreenSecurityPreference.isEnabled(context) once via a keyless
remember { }, so toggling the setting in feature:settings only took
effect the next time the screen recomposed from scratch (leave and
re-enter) — contradicting SecureScreenEffect's own doc comment
("toggling restores normal behavior immediately").

Added VaultScreenSecurityPreference.observe() in core:storage, the
same OnSharedPreferenceChangeListener + callbackFlow pattern
core.storage.SupporterRepository.observe already uses, and a
rememberScreenSecurityEnabled() composable helper in feature:vault
that collects it as state. Both call sites now recompose live when
the setting changes elsewhere.

Reimplemented against current dev rather than cherry-picking the
referenced PR #537 commit verbatim: #543 (merged after that commit
was written) moved SecureScreenEffect to core:ui and
VaultScreenSecurityPreference to core:storage, and deleted
VaultReaderScreen outright, so the original diff's file paths and
third call site no longer exist. observe() lives on
VaultScreenSecurityPreference itself (core:storage) since core:ui
does not depend on core:storage; rememberScreenSecurityEnabled()
lives in feature:vault, the only module currently gating
SecureScreenEffect on this preference.

Part of #530 (L5). Closes #569.

* ci: retrigger CI after ready_for_review produced no run

Known pipeline race (#433, precedent: PR #429/#432) — gh pr ready
uses the default GITHUB_TOKEN, so its ready_for_review event never
triggers jvm-tests.yml/ios-app-build.yml. Empty commit via the
elevated token to force a synchronize event instead.

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-info Dev/QA agent needs more detail before proceeding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code review cleanup batch: 8 low-severity findings (L1-L8)

1 participant