Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.32"
".": "0.1.34"
}
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Each owning file's comments and tests hold the detail; read them before touching
`src/proposal.js`; usage comes from acpx's stderr line or a harness store (`src/acpx.js`), printed only by
`src/commands/usage.js`.
- **Evidence floors live in `buildProposal`** (`src/proposal.js`): every non-`extract`/`move` edit needs
`minGapEvidence` distinct sessions from `summary.sources`; deletions need `harm`-class sessions; a pure
`minGapEvidence` distinct observers from fold-issued sources; deletions need `harm`-class observers; a pure
deletion inside a skill file is refused. Extraction and deletion never share one decision. Never add a
lexical or text-shape classifier to these gates, and non-compliance never counts as harm. The >= 20%
relevance placement table (`src/prompts/synthesis.md`) stays prompt guidance, never a `buildProposal` gate.
Expand All @@ -47,7 +47,7 @@ Each owning file's comments and tests hold the detail; read them before touching
- **Corpus mix is interactive vs non-interactive, never an unknown bucket** (`src/interaction.js`).
- **backpass must never analyze itself**: keep `SELF_SESSION_SENTINEL` (`src/prompts.js`) at the start of every
model-facing prompt (`src/discovery/self.js` drops those sessions).
- **Gap evidence**: one ledger sighting per (gap, transcript) (`src/gap-ledger.js`); record before pruning;
- **Gap evidence**: native ledger contributions retain their own provenance (`src/gap-ledger.js`); record before pruning;
never surface uncorroborated singletons; gap identity is judged by the consolidation call, with bigram
similarity only as fallback; there is no orchestrator-memory write path.
- **Fold uses only selected, fresh evidence** (`foldForRun` in `src/commands/propose.js`, `isEvidenceFresh`).
Expand Down Expand Up @@ -80,7 +80,7 @@ Each owning file's comments and tests hold the detail; read them before touching
- **The live TUI is an enhancement layer** (`src/tui/`): output must be identical with it inactive (non-TTY, CI,
`NO_COLOR`, `--quiet`, `--json`), with clean stdout.
- **Rejection identity** (`src/state.js`): a refused add/rewrite/remove stays suppressed on the same kind and file
when measured `gapIds` or `instructionIds` overlap, until a strictly higher session count; extract/move stay
when measured `gapIds` or `instructionIds` overlap, until a strictly higher observer count; extract/move stay
hunk-key only. Optional reject reasons never revive an edit and are not evidence floors.
- Cursor IDE support is deferred; see the header of `src/discovery/adapters/cursor-ide.js`.

Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [0.1.34](https://github.com/kunchenguid/backpass/compare/backpass-v0.1.33...backpass-v0.1.34) (2026-10-13)


### Bug Fixes

* **discovery:** associate sessions in repos with separate git directories ([#206](https://github.com/kunchenguid/backpass/issues/206)) ([29c46e7](https://github.com/kunchenguid/backpass/commit/29c46e7209fbfd5a8739d343163b8250d67b14c6))

## [0.1.33](https://github.com/kunchenguid/backpass/compare/backpass-v0.1.32...backpass-v0.1.33) (2026-10-12)


### Features

* **discovery:** add opt-in OMP session discovery to the Pi adapter ([#151](https://github.com/kunchenguid/backpass/issues/151)) ([9a4a773](https://github.com/kunchenguid/backpass/commit/9a4a773c0eaebfdb3ea4950a8a0f53d447ad8b60))

## [0.1.32](https://github.com/kunchenguid/backpass/compare/backpass-v0.1.31...backpass-v0.1.32) (2026-09-30)


Expand Down
121 changes: 78 additions & 43 deletions README.md

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions docs/upstream-sync-2026-10-15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Backpass upstream sync: integration addendum

The sync retains merge commit `731d6808517bbfee64d7606b72f1ff64ed2f2c67` and upstream
`e6a030a550be438e5b81a1ba91e01abc90faad07` as ancestry. Incoming changes add opt-in OMP
collection and observer deduplication, separate-git-directory discovery, and upstream
release metadata. House external-source, trace-only, private-run, credential-route,
SSH, and nested-memory capabilities remain required.

The five content-conflict resolutions combine the following behavior:

| File | Integration verdict |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `README.md` | Document upstream OMP collection and shared observers alongside the house evidence and scope rules. |
| `src/commands/propose.js` | Use current discovery's interaction metadata after house freshness admission; resolve current observers in the filtered view before consolidation, preserving durable history. |
| `src/discovery/index.js` | Retain house remote and external discovery paths while adding upstream OMP metadata, ancestor cache dependencies, and observer aliases across synced stores. |
| `src/fold.js` | Accept upstream observer deduplication for corroboration, harm, domain votes, and skill citations; retain eligible native projects, maximum risk, and nested ownership. |
| `src/gap-ledger.js` | Retain durable house provenance and freshness isolation while resolving current upstream shared observers in filtered views. Distinct native contributions and incompatible freshness stamps stay separately stored. |

Native transcript identities drive direct and persisted ownership, representative
quotes, root ownership, and proposal routing. A child working only in `apps/api` can
support that file even when its observer parent worked at the root. Related native
contributions retain their individual projects and coverage status: coverage in one
project cannot suppress an uncovered contribution in another. Counter definitions and
coverage eligibility are owned by [`src/fold.js`](../src/fold.js). Representative quotes carry
both observer and project witnesses through the proposal floors. Instruction and gap
quotes use the same bounded selection rule, scaled to the configured evidence and
project floors. Synthesis and report rendering emit that selected set without a second
truncation, so an independent witness cannot disappear between storage and the prompt.

Ledger migration and recording had also combined a child's historical wording with
its newly readable parent's source and content stamps. Recording, normalization,
and consolidation now combine only compatible contributions and retain their maximum
recurrence risk with the same reducer used by direct folding. Filtering checks the
original native source and stamps; stale wording stays durable without entering the
current model view. Source, external revision, and evidence-route boundaries remain
in force. The unsafe combined storage representation is replaced; no house capability
is retired.

The filtered ledger view resolves current observer identities before consolidation,
including when a parent header disappears and later returns while a child's analysis
is stale. This changes only the view's observer attribution; durable source identities,
content digests, revisions, evidence keys, and first-seen times remain intact. Analysis,
consolidation, and fold share the filtered-view boundary, while direct folds still
resolve supplied observations against current records.

The clean proposal overlap keeps observer-based evidence floors and native-based
ownership as separate maps. No new proposal gate or text classifier is introduced.
Remote-discovery, analysis-reuse, and interaction regressions assert individual native
provenance and a single related observer vote instead of one storage row per observer.
Behavioral regressions also cover project eligibility in both coverage directions,
contribution order, maximum risk, project-floor proposal acceptance, quote limits,
root ownership across nested passes, and parent-header restoration before consolidation.
Emitted instruction and gap evidence is fed into the real proposal gates at default and
higher evidence/project floors. Persisted recording, normalization, and consolidation
regressions cover high/low ordering and exclude stale high-risk contributions.
These are offline synthetic checks, with no account-integration claim. The outer
executor owns the full check, final PR conflict report, and house CI.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backpass",
"version": "0.1.32",
"version": "0.1.34",
"packageManager": "pnpm@11.5.0",
"description": "Gradient descent for your agent memory - analyzes past agent session transcripts and proposes evidence-backed edits to AGENTS.md / CLAUDE.md",
"type": "module",
Expand Down
6 changes: 5 additions & 1 deletion src/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { assertPrivatePath, evidenceKey, isEvidenceFresh, safeFileName } from ".
import { analysisRoute, routeForPick } from "./provenance.js";
import { emitProgress } from "./progress.js";
import { UserError, color, info, warn } from "./logger.js";
import { transcriptIdentity } from "./transcript.js";
import { corroborationIdentityOf, transcriptIdentity } from "./transcript.js";

/**
* Stage 1 of the pipeline (design section 3): one cheap model call per transcript,
Expand Down Expand Up @@ -511,6 +511,10 @@ export async function analyzeTranscripts({
harness: transcript.harness,
id: transcript.id,
identity: transcriptIdentity(transcript),
parentSessionId: transcript.parentSessionId || null,
corroborationIdentity: corroborationIdentityOf(transcript),
corroborationNativeId: transcript.corroborationNativeId || null,
corroborationStartedAt: transcript.corroborationStartedAt ?? null,
path: transcript.path,
mtimeMs: transcript.mtimeMs,
bytes: transcript.bytes,
Expand Down
66 changes: 47 additions & 19 deletions src/commands/propose.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import {
filterGapLedger,
ledgerGapObservations,
mergeGapEntries,
normalizeGapLedgerSessions,
pruneGapLedger,
recordGapObservations,
} from "../gap-ledger.js";
import { synthesizeProposal } from "../synthesize.js";
import { ProposalViolation } from "../proposal.js";
import { formatCorpusMix, INTERACTIVE, NON_INTERACTIVE } from "../interaction.js";
import { classifyInteraction, formatCorpusMix, INTERACTIVE, NON_INTERACTIVE } from "../interaction.js";
import { UserError, color, info, json, out, terminalSafe } from "../logger.js";
import { budgetBar, formatTokens } from "../tokens.js";
import { emitProgress } from "../progress.js";
Expand All @@ -19,7 +20,7 @@ import { printUsage } from "./usage.js";
import { closeRemoteDiscovery, discoverForRun } from "./scan.js";
import { capTranscripts } from "../sample.js";
import { isEvidenceFresh } from "../state.js";
import { transcriptIdentity } from "../transcript.js";
import { corroborationIdentityOf, transcriptIdentity } from "../transcript.js";
import { pruneHostCache } from "../discovery/cache.js";
import { analysisRoute, assertSourceCurrent, proposalProvenance, routeForPick } from "../provenance.js";
import { checkRunContext } from "../run-context.js";
Expand All @@ -37,6 +38,9 @@ import { checkRunContext } from "../run-context.js";
* cap remain on disk. Folding those records would inflate `analyzedSessions` beyond the
* sampled corpus or score positional instruction aliases against an index they never saw.
* Legacy records stay excluded until ordinary discovery and analysis backfill them.
* Current discovery's interaction and corroboration fields are overlaid only after
* admission, so stale stamps and observer identities from missing ancestors do not
* survive in the fold.
*/
export async function foldForRun(ctx, memoryFile, memoryHash, skills = [], transcripts = [], { route = null } = {}) {
const { state, minGapEvidence, gapLedgerMaxAge } = ctx.config;
Expand All @@ -45,7 +49,6 @@ export async function foldForRun(ctx, memoryFile, memoryHash, skills = [], trans
ctx.sessionSource || transcripts.some((transcript) => transcript.sourceKind === "external")
? await analysisRoute(ctx.config)
: null;
const selected = new Set(selectedByIdentity.keys());
const evidence = state.listEvidence();
const identitiesByLegacyId = new Map();
for (const record of evidence) {
Expand All @@ -54,30 +57,53 @@ export async function foldForRun(ctx, memoryFile, memoryHash, skills = [], trans
if (!identitiesByLegacyId.has(legacyId)) identitiesByLegacyId.set(legacyId, new Set());
identitiesByLegacyId.get(legacyId).add(transcriptIdentity(record.transcript));
}
const selectedGapSessions = new Set(selected);
const selectedGapSessions = new Set();
const selectedObserversByNative = new Map();
const legacyIds = new Set();
for (const transcript of transcripts) {
selectedGapSessions.add(corroborationIdentityOf(transcript));
const nativeIdentity = transcript.identity || transcript.id;
if (!selectedObserversByNative.has(nativeIdentity)) selectedObserversByNative.set(nativeIdentity, new Set());
selectedObserversByNative.get(nativeIdentity).add(corroborationIdentityOf(transcript));
const identities = identitiesByLegacyId.get(transcript.id);
if (identities?.size === 1 && identities.has(transcriptIdentity(transcript))) {
selectedGapSessions.add(transcript.id);
legacyIds.add(transcript.id);
if (!selectedObserversByNative.has(transcript.id)) selectedObserversByNative.set(transcript.id, new Set());
selectedObserversByNative.get(transcript.id).add(corroborationIdentityOf(transcript));
}
}
const relevant = evidence.filter((e) => {
const currentTranscript = selectedByIdentity.get(transcriptIdentity(e.transcript));
return (
e.memoryPath === memoryFile.path &&
e.memoryHash === memoryHash &&
(e.transcript?.interaction === INTERACTIVE || e.transcript?.interaction === NON_INTERACTIVE) &&
currentTranscript &&
isEvidenceFresh(e, currentTranscript, memoryHash, evidenceRoute)
);
});
const relevant = [];
for (const record of evidence) {
const currentTranscript = selectedByIdentity.get(transcriptIdentity(record.transcript));
if (
record.memoryPath !== memoryFile.path ||
record.memoryHash !== memoryHash ||
(record.transcript?.interaction !== INTERACTIVE && record.transcript?.interaction !== NON_INTERACTIVE) ||
!currentTranscript ||
!isEvidenceFresh(record, currentTranscript, memoryHash, evidenceRoute)
) {
continue;
}
const transcript = {
...record.transcript,
interactionSignals: currentTranscript.interactionSignals,
interaction: classifyInteraction(currentTranscript),
parentSessionId: currentTranscript.parentSessionId || null,
corroborationIdentity: corroborationIdentityOf(currentTranscript),
corroborationNativeId: currentTranscript.corroborationNativeId || null,
corroborationStartedAt: currentTranscript.corroborationStartedAt ?? null,
};
relevant.push({ ...record, transcript });
}

const traceOnly =
Boolean(ctx.sessionSource) || transcripts.some((transcript) => transcript.sourceKind === "external");
const ledger = state.readGapLedger();
recordGapObservations(ledger, relevant, { skills });
normalizeGapLedgerSessions(ledger, transcripts, { legacyIds });
recordGapObservations(ledger, relevant, { skills, legacyIds, transcripts });
const gapView = filterGapLedger(structuredClone(ledger), relevant, transcripts, {
sourceKind: traceOnly ? "external" : "native",
legacyIds,
});
// Consolidate after recording, so the pass sees this run's sightings too: two
// sessions coining the same brand-new gap in one parallel fan-out can only line up
Expand All @@ -99,9 +125,11 @@ export async function foldForRun(ctx, memoryFile, memoryHash, skills = [], trans
}
state.writeGapLedger(ledger);

const gapObservations = ledgerGapObservations(gapView, memoryFile.path, skills).filter((observation) =>
selectedGapSessions.has(observation.sessionId),
);
const gapObservations = ledgerGapObservations(gapView, memoryFile.path, skills).filter((observation) => {
if (!selectedGapSessions.has(observation.sessionId)) return false;
const observers = selectedObserversByNative.get(observation.sourceSessionId);
return !observers || (observers.size === 1 && observers.has(observation.sessionId));
});
const summary = foldEvidence(relevant, {
minGapEvidence,
minGapProjects: ctx.scope?.kind === "user" ? ctx.config.minGapProjects || 1 : 0,
Expand Down
8 changes: 8 additions & 0 deletions src/commands/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,16 @@ async function cmdScanCore(ctx) {
mix,
...(runContext ? { runContext } : {}),
transcripts: transcripts.map((transcript) => {
/** @type {Record<string, unknown>} */
const serialized = { ...transcript };
delete serialized.remote;
// Observer fields appear only when related transcripts share one (OMP subagents),
// so a plain store serializes exactly as before.
if (serialized.corroborationIdentity === serialized.identity) {
delete serialized.corroborationIdentity;
delete serialized.corroborationNativeId;
delete serialized.corroborationStartedAt;
}
return serialized;
}),
});
Expand Down
9 changes: 7 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export const DEFAULT_CONFIG = {
maxEditsPerRun: null,
minGapEvidence: 2,
/**
* Gap observations persist across runs in `.backpass/gap-ledger.json`, but only
* observations from the current selected sample count toward `minGapEvidence`.
* Retirement age for durable gap sightings; identity and admission rules live in
* `src/gap-ledger.js`.
* A session's observations retire past this age (a duration like 90d, `all` to never expire).
*/
gapLedgerMaxAge: "90d",
Expand Down Expand Up @@ -119,6 +119,8 @@ export const DEFAULT_CONFIG = {
* is refused by name. Absolute paths; `~` is expanded.
*/
opencodeStores: [],
/** Include Oh My Pi's default session store in Pi discovery; opt-in only. */
includeOmp: false,
minUserTurns: 2,
includeCursorIde: false,
},
Expand Down Expand Up @@ -473,6 +475,9 @@ function validate(config, { kind = "project", repoRoot = null } = {}) {
}
config.discovery.harnesses = config.discovery.harnesses.filter((h) => known.has(h));
parseSince(config.discovery.since);
if (typeof config.discovery.includeOmp !== "boolean") {
throw new UserError("config.discovery.includeOmp must be a boolean");
}
if (!Array.isArray(config.discovery.cloneRoots) || config.discovery.cloneRoots.some((p) => typeof p !== "string")) {
throw new UserError("config.discovery.cloneRoots must be an array of paths");
}
Expand Down
8 changes: 5 additions & 3 deletions src/consolidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { warn } from "./logger.js";
* paraphrase (measured on a production ledger: 89 entries containing at least six
* multi-session gaps, highest cross-session score 0.34 against the 0.45 bar). The model
* is asked only "same gap or not", the merge itself is mechanical (`mergeGapEntries`),
* unknown ids and malformed groups are dropped, and a session is never double-counted
* unknown ids and malformed groups are dropped, and an observer is never double-counted
* however the entries merge. Strict admission is untouched: merging changes how
* sightings line up, never how many distinct sessions a proposal needs.
* sightings line up, never how many distinct observers a proposal needs.
*
* Exactly one call per run, and only when at least two entries exist. Failure is
* fail-soft with a warning: the run degrades to lexical identity (the pre-consolidation
Expand All @@ -38,7 +38,9 @@ let callCounter = 0;
function renderEntries(entries) {
return entries
.map((entry) => {
const sessions = Object.keys(entry.sessions).length;
const sessions = new Set(
Object.entries(entry.sessions).map(([identity, observation]) => observation.observerId || identity),
).size;
const mistake = firstMistake(entry);
return (
`[${entry.id}] (sessions=${sessions}) ${entry.proposedInstruction}` +
Expand Down
Loading
Loading