- MCP
- blame on this site's /mcp
- CLI
- abso blame worker/project/overlaps.ts --json
- JSON
- /christopher/abso-core/blame/worker/project/overlaps.ts?format=json
109 linesFirst import 85% · engine 7% · capacity 4% · codex-capacity-chair 2% · infra-split 2%Last change capacity in version 212,
109 lines from 5 changes in 5 versions.
2// the news when a draft first touches one. Reads and news writes go through
3// OverlapHost; today the host is Project. overlapsOf is the pure match.
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare5import { type AtomId, type Graph, isStartNode, type ReadView } from "../../src/engine/index.ts";
7import { type NewsItem, overlapItems } from "./news.ts";
8import type { AgentState, Entry, Overlap, Starting } from "./project-types.ts";
10/** Another agent in the same space, as overlaps see it. */
11export interface OverlapPeer {
12 name: string;
13 /** Files its unpublished changes touch. */
14 files: ReadonlySet<string>;
15 /** How many of its unpublished changes touch `file`. */
16 changesIn: (file: string) => number;
17 /** Its live starting note. */
18 note: Starting | undefined;
19}
21/** What draft-file overlaps and their news need from a project. */
22export interface OverlapHost {
23 readonly graph: Graph;
24 readonly agents: ReadonlyMap<string, AgentState>;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare25 agentView(agent: AgentState): ReadView;
engine55Issue 6: status no longer builds every agent's view. On abso's log (13,148 entries, 48 agents) status went from about 330 ms to 1 ms median (30 ms max) in Node.
- markedCollisions skips the view when the agent has no marked files (most have none). This was most of the cost.
- draftFiles skips the view when the draft is empty, and Project keeps each agent's draft files under their view key plus the draft, so they're worked out again only when either moves. Overlaps and overlap news use the kept ones too.
- New test (draft-files-kept): status from a warm project equals a cold load after every step, in shared and with two agents in one named draft (Pinch's case). A weaker key fails it.Compare27 /** draftFiles below, kept per agent by the host. */
28 draftFiles(agent: AgentState): Set<string>;
30 queueNews(agent: AgentState, items: readonly NewsItem[], entries: Entry[]): void;
31}
33/** What a starting note can name: its files (globs included) and the paths written in its text. */
34export const notePatterns = (note: Starting | undefined): string[] =>
35 note ? [...new Set([...note.files, ...pathsInText(note.text)])] : [];
37/**
38 * Peers with unpublished changes in a file `patterns` match, or a starting
infra-split37Comments and test names give each reason in plain words, without naming who raised it
Notes like "(#37, Builder 5)" or "(AVCS - Security)" become "(#37)" or go, and a private commit hash after a name goes with it. Issue numbers and references such as git's CVE-2019-1353 stay. Only comments and test names change; no behavior changes.Compare39 * note that can name the same file (#37: notes name files by glob,
41 */
42export function overlapsOf(peers: readonly OverlapPeer[], patterns: readonly string[]): Overlap[] {
43 if (patterns.length === 0) return [];
44 const out: Overlap[] = [];
45 for (const other of peers.toSorted((a, b) => (a.name < b.name ? -1 : 1))) {
46 const found = new Map<string, Overlap>();
47 for (const file of [...other.files].toSorted()) {
48 if (!patterns.some((p) => matchesPattern(p, file))) continue;
49 found.set(file, { agent: other.name, file, changes: other.changesIn(file) });
50 }
51 for (const theirs of notePatterns(other.note)) {
52 for (const p of patterns) {
53 if (!patternsMeet(p, theirs)) continue;
54 // Name the file as plainly as either side gives it.
55 const file = /[*?]/.test(p) ? theirs : p;
56 found.set(file, found.get(file) ?? { agent: other.name, file });
57 }
58 }
59 for (const o of [...found.values()].toSorted((a, b) => (a.file < b.file ? -1 : 1))) {
60 out.push({ ...o, ...(other.note ? { starting: other.note.text } : {}) });
61 }
62 }
63 return out;
64}
66/** The files the agent's unpublished changes touch, in its own view. */
67export function draftFiles(host: OverlapHost, agent: AgentState): Set<string> {
68 const files = new Set<string>();
engine55Issue 6: status no longer builds every agent's view. On abso's log (13,148 entries, 48 agents) status went from about 330 ms to 1 ms median (30 ms max) in Node.
- markedCollisions skips the view when the agent has no marked files (most have none). This was most of the cost.
- draftFiles skips the view when the draft is empty, and Project keeps each agent's draft files under their view key plus the draft, so they're worked out again only when either moves. Overlaps and overlap news use the kept ones too.
- New test (draft-files-kept): status from a warm project equals a cold load after every step, in shared and with two agents in one named draft (Pinch's case). A weaker key fails it.Compare69 const draft = host.draft(agent);
70 // No draft, no view to build: most agents in a big project have nothing unpublished.
71 if (draft.length === 0) return files;
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export.
- where looks deleted lines up by number (graph.deletedNumbers, View.fileOfNumber, View.lineNumberOf). It takes the agent's view once instead of once per line, since each read weighed every cached view. It finds the draft's lines by writer (View.visibleWriters), with no text or id read per line.
- Draft files (overlaps.ts) go by number the same way.
- An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this).
- Draft collisions:
- build the union view only when two drafts share a file;
- work out each agent's touched files and its "shared now plus draft" view once;
- find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history;
- have the definition rule keep a draft's uses, and the newer work's definitions, across partners.
- A stored list read in order reads its length once, not before every element.
draft-reads-stored.test.ts checks where and collisions against the in-memory project. It covers edits, a whole file deleted, a line collision, one name defined twice, and bases before and after a move. 135 of 136 related tests pass; none fail.
On website's export (1,387 entries) the answers match Project.load:
- status: 17 s to 4.5 s
- where: over 60 s to 8.8 s
- drafts: 14 s to 5.3 s
- collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare73 // By number where the view can (abso Capacity): a draft deleting a big generated file looked up each line's id.
74 const byNumber = (view as { fileOfNumber?(n: number): string }).fileOfNumber?.bind(view);
engine55Issue 6: status no longer builds every agent's view. On abso's log (13,148 entries, 48 agents) status went from about 330 ms to 1 ms median (30 ms max) in Node.
- markedCollisions skips the view when the agent has no marked files (most have none). This was most of the cost.
- draftFiles skips the view when the draft is empty, and Project keeps each agent's draft files under their view key plus the draft, so they're worked out again only when either moves. Overlaps and overlap news use the kept ones too.
- New test (draft-files-kept): status from a warm project equals a cold load after every step, in shared and with two agents in one named draft (Pinch's case). A weaker key fails it.Compare75 for (const id of draft) {
77 for (const run of atom.inserts) files.add(isStartNode(run.parent) ? run.file : view.fileOf(run.parent));
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export.
- where looks deleted lines up by number (graph.deletedNumbers, View.fileOfNumber, View.lineNumberOf). It takes the agent's view once instead of once per line, since each read weighed every cached view. It finds the draft's lines by writer (View.visibleWriters), with no text or id read per line.
- Draft files (overlaps.ts) go by number the same way.
- An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this).
- Draft collisions:
- build the union view only when two drafts share a file;
- work out each agent's touched files and its "shared now plus draft" view once;
- find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history;
- have the definition rule keep a draft's uses, and the newer work's definitions, across partners.
- A stored list read in order reads its length once, not before every element.
draft-reads-stored.test.ts checks where and collisions against the in-memory project. It covers edits, a whole file deleted, a line collision, one name defined twice, and bases before and after a move. 135 of 136 related tests pass; none fail.
On website's export (1,387 entries) the answers match Project.load:
- status: 17 s to 4.5 s
- where: over 60 s to 8.8 s
- drafts: 14 s to 5.3 s
- collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare78 if (byNumber) for (const n of host.graph.deletedNumbers(id)) files.add(byNumber(n));
79 else for (const line of atom.deletes) files.add(view.fileOf(line));
81 }
82 return files;
83}
85/** Other agents in the agent's space whose unpublished changes or starting note meet `patterns`. */
86export function overlaps(host: OverlapHost, agent: AgentState, patterns: readonly string[]): Overlap[] {
87 if (patterns.length === 0) return [];
88 const peers = [...host.agents.values()]
89 .filter((other) => other !== agent && other.space === agent.space)
90 .map((other) => ({
91 name: other.name,
engine55Issue 6: status no longer builds every agent's view. On abso's log (13,148 entries, 48 agents) status went from about 330 ms to 1 ms median (30 ms max) in Node.
- markedCollisions skips the view when the agent has no marked files (most have none). This was most of the cost.
- draftFiles skips the view when the draft is empty, and Project keeps each agent's draft files under their view key plus the draft, so they're worked out again only when either moves. Overlaps and overlap news use the kept ones too.
- New test (draft-files-kept): status from a warm project equals a cold load after every step, in shared and with two agents in one named draft (Pinch's case). A weaker key fails it.Compare92 files: host.draftFiles(other),
init0Start the project93 changesIn: (file: string) => host.draft(other).filter((id) => host.graph.filesOf(id).includes(file)).length,
94 note: host.liveNote(other),
95 }));
96 return overlapsOf(peers, patterns);
97}
99/**
100 * News the first time a draft touches a file someone else in its space has
infra-split37Comments and test names give each reason in plain words, without naming who raised it
Notes like "(#37, Builder 5)" or "(AVCS - Security)" become "(#37)" or go, and a private commit hash after a name goes with it. Issue numbers and references such as git's CVE-2019-1353 stay. Only comments and test names change; no behavior changes.Compare101 * unpublished changes in, or a starting note on (#37): one line per file and agent, once per draft. It tells; it never stops
103 */
104export function overlapNews(host: OverlapHost, agent: AgentState, before: ReadonlySet<string>, entries: Entry[]): void {
engine55Issue 6: status no longer builds every agent's view. On abso's log (13,148 entries, 48 agents) status went from about 330 ms to 1 ms median (30 ms max) in Node.
- markedCollisions skips the view when the agent has no marked files (most have none). This was most of the cost.
- draftFiles skips the view when the draft is empty, and Project keeps each agent's draft files under their view key plus the draft, so they're worked out again only when either moves. Overlaps and overlap news use the kept ones too.
- New test (draft-files-kept): status from a warm project equals a cold load after every step, in shared and with two agents in one named draft (Pinch's case). A weaker key fails it.Compare105 const now = host.draftFiles(agent);
107 if (fresh.length === 0) return;
108 host.queueNews(agent, overlapItems(host.draft(agent)[0] ?? "", overlaps(host, agent, fresh)), entries);
109}