Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
80e8bd4
feat(tui): add quark timeline experiment
kitlangton Jul 17, 2026
53b236d
refactor(tui): extract session timeline state
kitlangton Jul 18, 2026
6548844
chore(quark): sync vendored quark with diff gating and codegen
kitlangton Jul 18, 2026
afd4f63
feat(tui): move assistant content into per-part quark slots
kitlangton Jul 18, 2026
6f7fc0c
chore: fix drive script type narrowing
kitlangton Jul 18, 2026
ce5e158
chore(quark): sync vendored keyed and layout with standalone
kitlangton Jul 18, 2026
624ebeb
fix(tui): preserve part collection identity across sync
kitlangton Jul 18, 2026
d0c6fc2
fix(tui): preserve prompts during session hydration
kitlangton Jul 18, 2026
3c9ce8a
docs: move experiment records to the quark repo
kitlangton Jul 18, 2026
95ce143
chore(quark): insource reactive kernel from standalone
kitlangton Jul 18, 2026
5e3eb0d
chore(quark): sync reactive kernel and rename package to @opencode-ai…
kitlangton Jul 18, 2026
d16737b
chore(quark): sync tests with standalone
kitlangton Jul 18, 2026
d063f6b
perf(quark): sync shared wrapper methods from standalone
kitlangton Jul 18, 2026
d064501
test(quark): bind detached subscribe in solid adapter instrumentation
kitlangton Jul 18, 2026
6ad6800
refactor(tui): simplify quark migration after review
kitlangton Jul 18, 2026
a2b3be0
refactor(tui): adopt reactive first index and read-only keyed surface
kitlangton Jul 18, 2026
5b77532
chore(tui): sync lockfile with quark package rename
kitlangton Jul 18, 2026
196892c
fix(tui): follow the current permission request in usePermissionInput
kitlangton Jul 18, 2026
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
10 changes: 10 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions packages/quark/THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Third-Party Notices

## alien-signals

The internal reactive kernel in `src/reactivity.ts` adapts the dependency
graph algorithm of [alien-signals](https://github.com/stackblitz/alien-signals)
3.2.1: the intrusive doubly-linked dependency and subscriber links with
versioned in-place reuse, and the iterative `propagate` and `checkDirty`
graph walks. alien-signals is not a runtime dependency of Quark.

```
MIT License

Copyright (c) 2024-present Johnson Chu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
195 changes: 195 additions & 0 deletions packages/quark/bench/collection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
import { Layout } from "../src/layout"
import { createHarness, type Workload } from "./harness"

type Job = {
readonly id: number
readonly labels: readonly number[]
readonly status: "running" | "retrying"
readonly value: number
}

const size = 1_000
const iterations = 200_000
const initial = Array.from({ length: size }, (_, id): Job => ({
id,
labels: [id],
status: id === 750 ? "retrying" : "running",
value: 0,
}))
const JobLayout = Layout.struct({
id: Layout.key(Layout.number),
labels: Layout.array(Layout.number),
status: Layout.string,
value: Layout.number,
})
const Jobs = Layout.collection(JobLayout, ({ members, first }) => ({
labels: members(["labels"], (job) => job.labels),
retry: first(["status"], (job) => job.status === "retrying"),
}))
const LabeledJobs = Layout.collection(JobLayout, ({ members }) => ({
labels: members(["labels"], (job) => job.labels),
}))
const JobPlan = Layout.compile(JobLayout)
const bench = createHarness({ warmup: 10_000, width: 38 })

function manualValueUpdate(): Workload {
const jobs = JobPlan.make(initial)
const labels = new Set(initial.flatMap((job) => job.labels))
const retry = jobs.get(750)!
return {
run(index) {
const id = index % size
jobs.modify(id, (job) => ({ ...job, value: index + 1 }))
},
consume: () => Number(labels.has(500)) + retry().id + jobs.get(iterations % size)!().value,
}
}

function indexedValueUpdate(): Workload {
const jobs = Jobs.make(initial)
return {
run(index) {
const id = index % size
jobs.modify(id, (job) => ({ ...job, value: index + 1 }))
},
consume: () =>
Number(jobs.hasMember("labels", 500)) + jobs.first("retry")()!.id + jobs.get(iterations % size)!().value,
}
}

function manualMemberAppend(): Workload {
const jobs = JobPlan.make(initial)
const labels = new Map(initial.flatMap((job) => job.labels.map((label) => [label, 1])))
const members = new Map(initial.map((job) => [job.id, new Set(job.labels)]))
return {
run(index) {
const id = index % size
const label = size + index
jobs.modify(id, (job) => {
const next = [...job.labels.slice(-7), label]
const previous = members.get(id)!
const current = new Set(next)
previous.forEach((member) => {
if (current.has(member)) return
const count = labels.get(member)!
if (count === 1) labels.delete(member)
if (count > 1) labels.set(member, count - 1)
})
current.forEach((member) => {
if (!previous.has(member)) labels.set(member, (labels.get(member) ?? 0) + 1)
})
members.set(id, current)
return { ...job, labels: next }
})
},
consume: () => Number(labels.has(size + iterations - 1)) + jobs.get(iterations % size)!().labels.length,
}
}

function indexedMemberAppend(): Workload {
const jobs = LabeledJobs.make(initial)
return {
run(index) {
const id = index % size
const label = size + index
jobs.modify(id, (job) => ({
...job,
labels: [...job.labels.slice(-7), label],
}))
},
consume: () =>
Number(jobs.hasMember("labels", size + iterations - 1)) + jobs.get(iterations % size)!().labels.length,
}
}

function manualGrowingAppend(): Workload {
const jobs = JobPlan.make([{ id: 0, labels: [], status: "running", value: 0 }])
const labels = new Set<number>()
let label = 0
return {
run() {
const next = label++
jobs.modify(0, (job) => ({ ...job, labels: [...job.labels, next] }))
labels.add(next)
},
consume: () => Number(labels.has(label - 1)) + jobs.get(0)!().labels.length,
}
}

function indexedGrowingAppend(): Workload {
const jobs = LabeledJobs.make([{ id: 0, labels: [], status: "running", value: 0 }])
let label = 0
return {
run() {
const next = label++
jobs.modify(0, (job) => ({ ...job, labels: [...job.labels, next] }), {
members: { labels: { add: [next] } },
})
},
consume: () => Number(jobs.hasMember("labels", label - 1)) + jobs.get(0)!().labels.length,
}
}

function automaticGrowingAppend(): Workload {
const jobs = LabeledJobs.make([{ id: 0, labels: [], status: "running", value: 0 }])
let label = 0
return {
run() {
const next = label++
jobs.modify(0, (job) => ({ ...job, labels: [...job.labels, next] }))
},
consume: () => Number(jobs.hasMember("labels", label - 1)) + jobs.get(0)!().labels.length,
}
}

function collectionSet(indexed: boolean, changed: boolean): Workload {
const jobs = indexed ? Jobs.make(initial) : JobPlan.make(initial)
return {
run(index) {
const id = index % size
const current = jobs.values()
const job = current[id]
jobs.set(current.with(id, { ...job, value: changed ? job.value + 1 : job.value }))
},
consume: () => jobs.values()[0].value + jobs.values().length,
}
}

console.log(`Compiled collection benchmark (${size} items, ${bench.samples} samples)\n`)

const value = bench.compare(iterations, [
{ name: "Handwritten value update", make: manualValueUpdate },
{ name: "Compiled indexed value update", make: indexedValueUpdate },
])
const member = bench.compare(iterations, [
{ name: "Handwritten member append", make: manualMemberAppend },
{ name: "Compiled indexed member append", make: indexedMemberAppend },
])
const growing = bench.compare(2_000, [
{ name: "Handwritten growing append", make: manualGrowingAppend },
{ name: "Automatic indexed growing append", make: automaticGrowingAppend },
{ name: "Indexed delta growing append", make: indexedGrowingAppend },
])
const equivalentSet = bench.compare(2_000, [
{ name: "Bare keyed equivalent set", make: () => collectionSet(false, false) },
{ name: "Compiled indexed equivalent set", make: () => collectionSet(true, false) },
])
const changedSet = bench.compare(2_000, [
{ name: "Bare keyed changed set", make: () => collectionSet(false, true) },
{ name: "Compiled indexed changed set", make: () => collectionSet(true, true) },
])

console.log("\nRatios to handwritten (lower is faster)")
console.log(`Value update: ${value.ratio(1, 0).toFixed(3)}x`)
console.log(`Member append: ${member.ratio(1, 0).toFixed(3)}x`)
console.log(`Automatic growing append: ${growing.ratio(1, 0).toFixed(3)}x`)
console.log(`Delta growing append: ${growing.ratio(2, 0).toFixed(3)}x`)
console.log(`Equivalent collection set: ${equivalentSet.ratio(1, 0).toFixed(3)}x`)
console.log(`Changed collection set: ${changedSet.ratio(1, 0).toFixed(3)}x`)
console.log(`METRIC collection_value_ratio=${value.ratio(1, 0).toFixed(6)}`)
console.log(`METRIC collection_member_ratio=${member.ratio(1, 0).toFixed(6)}`)
console.log(`METRIC collection_automatic_growing_ratio=${growing.ratio(1, 0).toFixed(6)}`)
console.log(`METRIC collection_delta_growing_ratio=${growing.ratio(2, 0).toFixed(6)}`)
console.log(`METRIC collection_equivalent_set_ratio=${equivalentSet.ratio(1, 0).toFixed(6)}`)
console.log(`METRIC collection_changed_set_ratio=${changedSet.ratio(1, 0).toFixed(6)}`)
bench.finish()
60 changes: 60 additions & 0 deletions packages/quark/bench/harness.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export type Workload = {
run(index: number): void
consume(): number
dispose?(): void
}

export type Variant = {
readonly name: string
readonly make: () => Workload
}

export function createHarness(options: { readonly samples?: number; readonly warmup?: number } = {}) {
const samples = options.samples ?? 9
const warmup = options.warmup ?? 500
let checksum = 0

return {
samples,
compare(iterations: number, variants: readonly Variant[]) {
const timings = variants.map(() => [] as number[])
for (let sample = -1; sample < samples; sample++) {
const offset = sample < 0 ? 0 : sample % variants.length
variants
.map((_variant, index) => (index + offset) % variants.length)
.forEach((variantIndex) => {
const workload = variants[variantIndex].make()
for (let index = 0; index < Math.min(iterations, warmup); index++) workload.run(index)
const start = Bun.nanoseconds()
for (let index = 0; index < iterations; index++) workload.run(index)
const elapsed = Bun.nanoseconds() - start
checksum += workload.consume()
workload.dispose?.()
if (sample >= 0) timings[variantIndex].push(elapsed / iterations)
})
}

const medians = variants.map((variant, index) => {
const median = middle(timings[index])
const mad = middle(timings[index].map((value) => Math.abs(value - median)))
const metric = variant.name.toLowerCase().replaceAll(/[^a-z0-9]+/g, "_")
console.log(`${variant.name.padEnd(42)} ${median.toFixed(1).padStart(10)} ns/op +/- ${mad.toFixed(1)} MAD`)
console.log(`METRIC ${metric}_ns_per_op=${median.toFixed(3)}`)
return median
})
return {
medians,
ratio(left: number, right: number) {
return middle(timings[left].map((value, index) => value / timings[right][index]))
},
}
},
finish() {
console.log(`CHECKSUM ${checksum}`)
},
}
}

function middle(values: number[]) {
return values.toSorted((a, b) => a - b)[Math.floor(values.length / 2)]
}
Loading
Loading