fix(cow): asOf() fails with "COW not enabled" due to property name mismatch

HistoricalStorageAdapter was looking for underscore-prefixed properties
(_commitLog, _blobStorage, _treeObject) but BaseStorage sets them without
underscores (commitLog, blobStorage). This caused all asOf() calls to fail.

Changes:
- Fix property access: use commitLog/blobStorage instead of _commitLog/_blobStorage
- Remove unused treeObject property (TreeObject is dynamically imported)
- Remove unused TreeObject static import

Reported by: Soulcraft Workshop Team

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
David Snelling 2025-12-02 11:22:04 -08:00
parent 0ba6da405e
commit b3ae18be00

View file

@ -30,7 +30,6 @@
import { BaseStorage } from '../baseStorage.js' import { BaseStorage } from '../baseStorage.js'
import { CommitLog } from '../cow/CommitLog.js' import { CommitLog } from '../cow/CommitLog.js'
import { TreeObject } from '../cow/TreeObject.js'
import { BlobStorage } from '../cow/BlobStorage.js' import { BlobStorage } from '../cow/BlobStorage.js'
import { import {
HNSWNoun, HNSWNoun,
@ -127,7 +126,6 @@ export class HistoricalStorageAdapter extends BaseStorage {
// Historical commit state (loaded lazily) - must match BaseStorage visibility // Historical commit state (loaded lazily) - must match BaseStorage visibility
public commitLog?: CommitLog public commitLog?: CommitLog
public treeObject?: TreeObject
public blobStorage?: BlobStorage public blobStorage?: BlobStorage
constructor(options: HistoricalStorageAdapterOptions) { constructor(options: HistoricalStorageAdapterOptions) {
@ -146,11 +144,11 @@ export class HistoricalStorageAdapter extends BaseStorage {
*/ */
public async init(): Promise<void> { public async init(): Promise<void> {
// Get COW components from underlying storage // Get COW components from underlying storage
this.commitLog = (this.underlyingStorage as any)._commitLog // v6.2.4: Fixed property names - use public properties without underscore prefix
this.treeObject = (this.underlyingStorage as any)._treeObject this.commitLog = this.underlyingStorage.commitLog
this.blobStorage = (this.underlyingStorage as any)._blobStorage this.blobStorage = this.underlyingStorage.blobStorage
if (!this.commitLog || !this.treeObject || !this.blobStorage) { if (!this.commitLog || !this.blobStorage) {
throw new Error( throw new Error(
'Historical storage requires underlying storage to have COW enabled. ' + 'Historical storage requires underlying storage to have COW enabled. ' +
'Call brain.init() first to initialize COW.' 'Call brain.init() first to initialize COW.'