Storage Operations Status

June 14, 2026 ยท View on GitHub

Last Reviewed: 2026-05-26 Audience: Engineering, Procurement, Security Vetting, CISO Scope: Local persistence and file system operations in the storage boundary

Executive Summary

This document tracks storage-side operations in git-lrc as an auditable inventory for enterprise due diligence.

  • Storage boundary: local file system and local SQLite only (no outbound API calls in this package).
  • Modes represented: file, db.
  • Operation count tracked: 43 operations.
  • Severity distribution: High 10, Medium 13, Low 20.
  • Primary sensitive data in scope: API keys and connector state in config, review metadata in SQLite, hook scripts and metadata, update lock/state metadata.
  • Highest-risk operation classes: credential file read/write, recursive deletion, permission changes, direct SQL execution wrappers.
  • Primary compensating controls already present: atomic writes for critical files, SQLite WAL mode and busy timeout, explicit chmod utility usage, typed wrapper functions and contextual error wrapping.
  • High-priority updates added in this review: mode-specific permission tests, backward-compatible schema version marker note, optional dry-run/logged branch delete API, optional confirmation-gated full delete API, review-session SQL mutation routing through ExecSQL, and pending-update integrity hash validation with legacy compatibility.
  • Current diff note: worktree hook-runtime and local hook-management fixes update hook/appcore/git path resolution only; no new storage operation APIs were added in this increment.
  • Current diff note: storage hook lifecycle evidence links were revalidated after the worktree hook-management update; inventory scope is unchanged.

Severity Rubric

  • High: operation can expose credentials, alter integrity-critical state, perform broad deletion, change permissions, or mutate persistent review/session records.
  • Medium: operation mutates non-critical persisted state or reads/writes operational data that can impact behavior but is lower sensitivity.
  • Low: operation creates directories, reads low-sensitivity input, or performs cleanup with limited impact.

Risk Acknowledgement Rules

  • Every operation row must state known risk and compensation status.
  • High-severity rows must include explicit compensation or explicit suggestion marker.
  • Suggestion marker format: Suggestion:
  • Acceptable residual risk must be called out when controls are considered sufficient.

Inventory: Config And Credential I/O

OperationModeData HandledPurposeSeverityRisk AcknowledgementCompensation StatusEvidence
ReadConfigFilefileTOML config bytes including API key and connector stateLoad CLI configuration from ~/.lrc.tomlHighCredential disclosure risk if file is too permissiveCompensated by strict mode enforcement via chmod path; residual risk acceptable with 0600 policystorage/config_io.go
WriteFileAtomicallyfileGeneric file bytes (used for durable state/config writes)Persist file content using temp-and-rename patternHighIntegrity risk from partial/truncated writesCompensated by atomic temp-then-rename; residual risk acceptable for local FS assumptionsstorage/files.go
ChmodfileFile mode bits (0600/0755 style permissions)Enforce permission model on config and scriptsHighMisconfiguration risk if wrong mode is appliedCompensated by centralized wrapper plus mode-specific tests for secret and executable paths; residual risk acceptablestorage/files.go
MkdirAllfileDirectory pathsCreate required storage folders safelyLowLow risk of directory sprawl/path misuseCompensated by controlled internal callsites; acceptable riskstorage/files.go

Inventory: Review And Attestation Database

OperationModeData HandledPurposeSeverityRisk AcknowledgementCompensation StatusEvidence
OpenAttestationReviewDBdbSQLite handle for review sessionsOpen persistent review DB with WAL behaviorHighDB integrity/availability risk on contention or corruptionCompensated by WAL mode and busy timeout in open path; residual risk acceptablestorage/attestation_review_db_io.go
InitializeAttestationReviewSchemadbSQL DDL for review_sessionsCreate required schema for branch review trackingHighSchema drift risk impacts audit evidence correctnessCompensated by centralized init path with explicit schema version marker note and backward-compatible marker check; missing marker remains non-fatal for legacy schemasstorage/attestation_review_db_io.go
InsertAttestationReviewSessionRowdbbranch, tree_hash, action, diff files, review_id, timestampRecord review session evidenceHighAudit trail tampering/inconsistency riskCompensated by single writer path and typed insert wrapper; residual risk acceptablestorage/attestation_review_db_io.go
QueryAttestationReviewSessionCountByBranchdbAggregate countReport branch review volumeMediumReporting accuracy risk if stale or partial stateCompensated by direct DB query on canonical table; acceptable riskstorage/attestation_review_db_io.go
QueryAttestationReviewedSessionsByBranchdbOrdered review session rowsRetrieve historical review evidence by branchMediumEvidence retrieval ordering/completeness riskCompensated by explicit ordering query; acceptable riskstorage/attestation_review_db_io.go
DeleteAttestationReviewSessionsByBranchdbBranch-scoped review rowsPurge branch review historyHighData loss and forensic gap riskCompensated by scoped delete API plus optional (opt-in) dry-run and audit logging options; default path has no additional logging overheadstorage/attestation_review_db_io.go
DeleteAllAttestationReviewSessionsdbEntire review_sessions tableAdministrative full wipe of review historyHighHigh-impact irreversible evidence loss riskPartially compensated by optional caller confirmation gate API with legacy delete path preserved for backward compatibility; residual risk remains high unless callers adopt confirmation policystorage/attestation_review_db_io.go
OpenSQLitedbGeneric SQLite connection and PRAGMA stateStandardized DB opener utilityHighBroad DB behavior risk if PRAGMA policy regressesCompensated by centralized opener policy and wrapped errors; residual risk acceptablestorage/files.go
ExecSQLdbSQL statement plus argsExecute SQL with wrapped errorsHighSQL misuse risk from broad execution capabilityCompensated by using ExecSQL for all review_sessions mutation paths in storage (schema init, insert, branch delete, full delete); direct db.Exec remains only inside ExecSQL wrapperstorage/files.go

Inventory: Hook Lifecycle Storage

OperationModeData HandledPurposeSeverityRisk AcknowledgementCompensation StatusEvidence
EnsureHooksPathDirfile.git/hooks directory pathEnsure Git hooks root existsLowLow risk from directory creation side effectsCompensated by predictable git path target; acceptable riskstorage/hook_io.go
EnsureManagedHooksDirfile.git/hooks/lrc directoryProvision lrc-managed hook directoryLowLow risk of local repo state mutationCompensated by dedicated managed subdirectory; acceptable riskstorage/hook_io.go
EnsureHooksBackupDirfile.git/hooks/.lrc_backups directoryProvision backup location for displaced hooksLowLow risk of backup directory growthCompensated by scoped location and cleanup routines; acceptable riskstorage/hook_io.go
EnsureRepoLRCStateDirfile.git/lrc directoryProvision repo-local lrc state storageLowLow risk from creating local state directoryCompensated by deterministic repo-local path; acceptable riskstorage/hook_io.go
ReadHookFilefileHook script bytesInspect existing hook script contentMediumMedium risk of parsing/handling untrusted local hook contentCompensated by read-only behavior and bounded scope; acceptable riskstorage/hook_io.go
ReadHookMetaFilefileHook metadata JSON bytesLoad metadata used for hook managementMediumMetadata poisoning risk from local tamperingPartially compensated by controlled metadata format; Suggestion: add schema validation checkstorage/hook_io.go
EnsureClaudeManagedHooksDirfileUser-global Claude hook directoryProvision lrc-managed Claude hook assets under user-owned stateLowLow risk from creating deterministic user-owned state directoryCompensated by scoped path under ~/.lrc and idempotent mkdir semantics; acceptable riskstorage/claude_io.go
ReadClaudeSettingsFilefileUser-scoped Claude settings JSONInspect existing Claude user settings before managed merge/updateMediumMedium risk of mishandling unrelated user settings if parsing assumptions are wrongPartially compensated by JSON merge logic that preserves unrelated fields; residual risk acceptablestorage/claude_io.go
WriteClaudeSettingsFilefileUser-scoped Claude settings JSONPersist managed Claude PreToolUse hook without clobbering unrelated settingsMediumMedium risk of user settings corruption if write path or serialization is wrongCompensated by atomic replace semantics and targeted managed-entry updates; residual risk acceptablestorage/claude_io.go
WriteClaudeHookScriptfileUser-global Claude hook scriptInstall lrc-managed Claude validator and wrapper scriptsMediumMedium risk if installed script path or permissions are wrong and Claude command interception breaksCompensated by atomic writes, deterministic paths, and executable mode; residual risk acceptablestorage/claude_io.go
WriteClaudeSkillFilefileUser-global Claude skill fileInstall lrc-managed personal-global /lrc Claude skillLowLow to medium risk if generated skill text is stale or misleadingCompensated by deterministic generated content and uninstall symmetry; acceptable riskstorage/claude_io.go
RemoveHookMetaFilefileHook metadata fileCleanup metadata during uninstall/resetLowLow risk of leaving stale metadata if delete failsCompensated by cleanup intent and low criticality; acceptable riskstorage/hook_io.go
RemoveManagedHooksDirfile.git/hooks/lrc directory treeRemove lrc-managed hooks during uninstallMediumMedium risk of accidental broad deletionCompensated by fixed managed directory target; acceptable riskstorage/file_delete_io.go
RemoveHooksBackupDirfile.git/hooks/.lrc_backups directory treeRemove hook backup tree during cleanupMediumMedium risk of losing restoration artifactsPartially compensated by explicit backup path boundary; Suggestion: optional backup retention switchstorage/file_delete_io.go
RemoveHookBackupFilefileIndividual backup scriptRemove stale backup filesMediumMedium risk of removing needed backup artifactCompensated by explicit file-target deletion path; acceptable riskstorage/file_delete_io.go
RemoveHookScriptFilefileIndividual hook scriptRemove managed hook scriptsMediumMedium risk of removing expected hook behaviorCompensated by managed-hook ownership model; acceptable riskstorage/file_delete_io.go
RemoveClaudeHookScriptfileUser-global Claude hook scriptRemove lrc-managed Claude validator and wrapper scripts during uninstallMediumMedium risk of breaking Claude interception if the wrong script path is targetedCompensated by deterministic lrc-managed asset path and scoped uninstall flow; residual risk acceptablestorage/claude_io.go
RemoveClaudeSkillFilefileUser-global Claude skill fileRemove lrc-managed personal-global /lrc Claude skill during uninstallLowLow risk of stale Claude command surface if cleanup failsCompensated by deterministic managed path and symmetric uninstall flow; acceptable riskstorage/claude_io.go
RemoveRepoHooksDisabledMarkerfileMarker file in repo stateClear local marker used to disable hook path behaviorLowLow risk of local behavior drift if marker handling failsCompensated by simple marker semantics; acceptable riskstorage/file_delete_io.go
RemoveRepoHooksStateMarkerfileMarker file in repo stateCanonicalize repo-local hook surface state markers during enable and disable transitionsLowLow risk of stale local surface state if marker cleanup failsCompensated by idempotent delete semantics and single-marker canonicalization; acceptable riskstorage/file_delete_io.go
RemoveDirIfEmptyfileDirectory pathDefensive cleanup only if emptyLowLow risk of unintended deletionCompensated by emptiness check guard; acceptable riskstorage/hook_io.go

Inventory: Review Inputs, Temporary Files, And Cleanup

OperationModeData HandledPurposeSeverityRisk AcknowledgementCompensation StatusEvidence
ReadInitialMessageFilefileInitial review prompt textLoad user-provided message for review request flowLowLow sensitivity text read riskCompensated by local read-only operation; acceptable riskstorage/review_input_io.go
ReadDiffFilefileDiff bytesLoad diff payload before review submissionMediumMedium confidentiality risk for code diff contentPartially compensated by local-only read path; Suggestion: document max retention expectationsstorage/review_input_io.go
CreateTempReviewHTMLFilefileTemporary HTML file handle/contentCreate temporary location for rendered review outputLowLow to medium leakage risk if temp files lingerPartially compensated by cleanup operations; Suggestion: enforce cleanup-on-exit where possiblestorage/review_input_io.go
RemoveTempHTMLFilefileTemporary HTML fileCleanup rendered review temp artifactLowLow risk if cleanup fails and file remainsCompensated by dedicated cleanup call; acceptable riskstorage/file_delete_io.go
RemoveSetupLogFilefileSetup log fileCleanup setup diagnostics artifactLowLow risk if diagnostic artifact persistsCompensated by cleanup path and low sensitivity default; acceptable riskstorage/file_delete_io.go
RemoveReauthLogFilefileRe-auth log fileCleanup auth diagnostics artifactLowLow to medium risk if logs capture sensitive contextPartially compensated by explicit deletion utility; Suggestion: verify log redaction policystorage/file_delete_io.go
RemoveEditorWrapperScriptfileTemporary shell wrapper scriptCleanup git editor wrapper used during review flowLowLow risk from temporary script persistenceCompensated by explicit cleanup path; acceptable riskstorage/file_delete_io.go
RemoveEditorBackupStateFilefileEditor backup state JSONCleanup backup state artifactLowLow risk from stale local state fileCompensated by explicit cleanup path; acceptable riskstorage/file_delete_io.go
RemoveCommitMessageOverrideFilefileCommit message override fileCleanup pending override from commit pipelineLowLow risk from stale override file affecting UXCompensated by cleanup routine; acceptable riskstorage/file_delete_io.go
RemoveCommitPushRequestFilefilePush-request marker fileCleanup post-commit push markerLowLow risk of stale marker stateCompensated by simple marker cleanup semantics; acceptable riskstorage/file_delete_io.go
RemoveFileIfExistsfileGeneric target file pathRemove installer artifacts with dry-run supportMediumMedium risk of deleting user-local files when wrong target is suppliedCompensated by explicit callsite-owned target lists and existence checks before removal; residual risk acceptablestorage/uninstall_io.go
RemoveLRCInstallerShellSourceLinesfileShell rc file contentRemove installer-owned lrc startup snippetsMediumMedium risk of modifying user shell startup filesCompensated by marker-based line matching constrained to installer signatures; residual risk acceptablestorage/uninstall_io.go
RemoveManagedFishLRCConfigfilefish conf.d file content/pathRemove installer-managed fish integration fileLowLow risk because removal is gated on managed-file marker contentCompensated by strict marker check before delete; acceptable riskstorage/uninstall_io.go
RemoveDirIfEmptyIfExistsfileDirectory pathRemove now-empty installer directory without recursionLowLow risk of unintended deletion because operation is empty-dir constrainedCompensated by explicit emptiness check before removal; acceptable riskstorage/uninstall_io.go

Inventory: Self-Update State And Lock Files

OperationModeData HandledPurposeSeverityRisk AcknowledgementCompensation StatusEvidence
ReadPendingUpdateStateBytesfileUpdate state JSON (version, binary path, timestamp, integrity hash)Read staged update metadata for upgrade flowMediumMedium integrity risk if state is tampered locallyCompensated by integrity hash verification when present plus legacy-state compatibility when absent; residual risk acceptable for local tamper-evidence modelstorage/file_read_io.go
ReadUpdateLockMetadataBytesfileLock metadata JSON (pid, uid, command, version)Read lock metadata for update concurrency awarenessMediumMedium risk if lock semantics are informational onlyPartially compensated by visibility into lock owner; Suggestion: document/enforce lock semantics in callerstorage/file_read_io.go
OpenFileForReadfileFile handle in read modeControlled read access helperLowLow risk helper abstractionCompensated by narrow read-only intent; acceptable riskstorage/file_read_io.go

Control Signals For Security Review

  • Boundary separation: storage package centralizes local persistence operations, simplifying audit scope.
  • Atomic persistence available: WriteFileAtomically reduces partial-write risk for critical state.
  • Permission control available: Chmod utility enables restricted modes for secrets and executable scripts.
  • DB durability and contention controls: SQLite WAL mode and busy timeout are configured through opener utilities.
  • Error context wrapping: most storage wrappers include operation-specific context in error paths.

Known Gaps And Follow-Ups

GapWhy It MattersFollow-Up
Duplicate query paths for review sessions exist across storage filesDuplicate logic can drift and confuse auditorsIdentify canonical path and deprecate duplicate wrapper set
Explicit schema migration workflow for review DB is not documented in this packageHarder to reason about schema evolution controlsSchema version marker note is now present; next step is a migration policy reference in docs
Lock metadata read path is documented, lock enforcement semantics are not explicit hereConcurrency guarantees for update flow may be unclearDocument enforcement owner and decision path in update docs
Some cleanup calls intentionally ignore non-critical errorsMay reduce forensic clarity in uninstall/cleanup incidentsDocument which cleanup failures are intentionally non-fatal

Review Cadence

  • Update this file when any function is added/removed/renamed in the storage package.
  • Re-evaluate severity when data sensitivity changes or when operation side effects change.
  • Security review trigger: any new High operation or any change touching credentials, permissions, deletion scope, or DB mutation behavior.