Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update transaction logging and journal access
  • Loading branch information
Gozala committed Jul 18, 2025
commit c2c69287cf5baedd27eb06f1a634b935ef67cac9
2 changes: 1 addition & 1 deletion packages/runner/src/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export function txToReactivityLog(
tx: IExtendedStorageTransaction,
): ReactivityLog {
const log: ReactivityLog = { reads: [], writes: [] };
for (const activity of tx.log()) {
for (const activity of tx.journal.activity()) {
if ("read" in activity && activity.read) {
log.reads.push({
space: activity.read.space,
Expand Down
19 changes: 6 additions & 13 deletions packages/runner/src/storage/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ export type StorageTransactionStatus =
* invariants have being invalidated, or reject and fail commit.
*/
export interface IStorageTransaction {
/**
* The transaction journal containing all read and write activities.
* Provides access to transaction operations and dependency tracking.
*/
readonly journal: ITransactionJournal;

/**
* Describes current status of the transaction. Returns a union type with
* status field indicating the current state:
Expand Down Expand Up @@ -521,19 +527,6 @@ export interface IExtendedStorageTransaction extends IStorageTransaction {
value: JSONValue | undefined,
): void;

/**
* Returns the transaction journal.
*
* The journal contains a list of activities (reads and writes) that have been made to the transaction.
* It is used to track the dependencies of the transaction.
*
* If the transaction is aborted, the activity reflects the attempted reads and
* writes. If the transaction is committed, the activity reflects the actual reads
* and writes.
*
* @deprecated - Use ITransactionJournal.activity() instead
*/
log(): Iterable<Activity>;
}

export interface ITransactionReader {
Expand Down
8 changes: 4 additions & 4 deletions packages/runner/src/storage/transaction-shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,12 @@ export class StorageTransaction implements IStorageTransaction {
export class ExtendedStorageTransaction implements IExtendedStorageTransaction {
constructor(private tx: IStorageTransaction) {}

status(): StorageTransactionStatus {
return this.tx.status();
get journal(): ITransactionJournal {
return this.tx.journal;
}

log(): Iterable<Activity> {
return this.tx.status().journal.activity();
status(): StorageTransactionStatus {
return this.tx.status();
}

reader(space: MemorySpace): Result<ITransactionReader, ReaderError> {
Expand Down
4 changes: 4 additions & 0 deletions packages/runner/src/storage/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class StorageTransaction implements IStorageTransaction {
this.#state = state;
}

get journal() {
return this.#state.journal;
}

status(): StorageTransactionStatus {
return status(this);
}
Expand Down