lilactown / lilactown/harmony

More control over thunks added to a branch

Open
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently, it's not ergonomic to drop a thunk `add`ed.

This could be helpful in a number of cases:
- Dropping a thunk after encountering an error while attempting to commit
- Dynamically reordering a transaction? Reorganizing multiple transactions?? (This seems wild but possible)
- Rolling back a branch to a previous state before committing

This could be accomplished a couple different ways:

- Add operations like `dropNext()`, `skipNext()`, `flush(n)` (move queue pointer to `n`), `drop(n)`, which give fine-grained control over the mutable thunk queue within the branch, in the same vein as `flushNext()`
- Make branches immutable; each operation returns a _new branch_

Immutable branches are strictly more powerful, but have a couple of problems be measured:
1. copy-on-write on each operation. This is probably small in comparison to the other parts of the system.
2. how do we handle stale versions of a particular branch being committed?

```javascript
let bX = branch();
let counter = ref(0);

let bX0 = bX.add(() => {
alter(counter, n => n + 1);
});

let bX1 = bX0.add(() => {
alter(counter, n => n + 1);
});

let bX2 = bX1.commit();

bX0.commit(); // ERROR! Stale
```

Should we prevent `bX0` from being rebased, since a future version of it has already been comitted? Or should we treat each branch returned by `add` as completely separate?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the branch(), add(), and commit() entry points first to understand how queued thunks and branch versions are represented. Decide whether queue controls or immutable branches are the intended direction, including stale-branch behavior, then define the expected semantics for dropping, reordering, and rollback before adding coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.