Repository navigation
Description
Problem
Before a patch's first publish, changing only shared fixture data erases its unchanged patch-owned rows. This is broader than the documented reset after an owned schema change.
Reproduction
- Prepare an unpublished patch with an owned notes table and a declared shared contacts table.
- Insert a local note and restart without changes. The note survives.
- Change only a title value in fixtures/shared-contacts.sql, leaving the manifest and metadata unchanged.
- Restart. The shared contact updates, but the owned notes table is empty.
Observed through real DevResources.prepare, persistent PGlite and table/shared handlers:
first start: notes=1, contacts=1
unchanged restart: notes=1, contacts=1
fixture row-only edit: notes=0, contacts=1
The independent reviewer also reproduced the loss with a comment-only fixture edit and proved the owned stamp and Prepared input stayed unchanged. An actual owned-schema change resets data as documented. Published consumers retain owned rows after the same fixture change. This is module/handler proof; file deletion is not part of the proven claim.
Standalone reproduction
Save at the repository root as experiment-fixture-owned-data.ts and run node --import tsx --conditions=development experiment-fixture-owned-data.ts. It owns and removes its temporary state.
import * as assert from 'node:assert/strict';
import * as fs from 'node:fs/promises';
import * as path from 'node:path';
import * as NodeServices from '@effect/platform-node/NodeServices';
import * as Effect from 'effect/Effect';
import { Binding } from './packages/runtime/src/dev.ts';
import * as DevResources from './packages/patchy/src/devResources.ts';
import { RELEASE, MANIFEST_VERSION } from './packages/patchy/src/release.ts';
import type { Prepared } from './packages/patchy/src/devPreparation.ts';
const root = await fs.mkdtemp(path.resolve('.audit-fixture-owned-data-'));
const stateDir = path.join(root, '.patchy/dev');
const fixture = path.join(root, 'fixtures/shared-contacts.sql');
const declaration = { kind: 'sharedTable' as const, patchId: 'refsource001', table: 'contacts', id: 'refsource001/contacts', revision: 1 };
const prepared: Prepared = {
patchId: 'localdev0000',
manifest: { release: RELEASE, manifestVersion: MANIFEST_VERSION, tier: 1, tables: { notes: { description: 'Locally created notes by id.', columns: { title: { kind: 'text' } }, indexes: {} } }, files: {}, uses: { contacts: declaration } },
identity: { user: { id: 'local-user', email: '[email protected]', name: 'Local' }, company: { id: 'local-company', handle: 'local', name: 'Local' }, role: 'admin', machine: { id: 'local-machine', name: 'Local machine' } },
metadata: { postgres: {}, shared: { contacts: { declaration, tables: { contacts: { description: 'Contacts by id.', columns: { title: { kind: 'text' } }, indexes: {}, shared: true } }, uses: {} } } }
};
await fs.mkdir(path.dirname(fixture), { recursive: true });
const sql = (title: string) => `INSERT INTO "p_refsource001"."contacts" ("id", "title") VALUES ('invented-contact', '${title}');\n`;
await fs.writeFile(fixture, sql('First contact'));
const session = (label: string, insert = false) => Effect.gen(function* () {
const resources = yield* DevResources.prepare(prepared, root, stateDir);
const binding = Binding.Binding.of({ ...resources.version, identity: { user: prepared.identity.user, company: prepared.identity.company, role: prepared.identity.role }, principal: { userId: prepared.identity.user.id }, correlationId: 'fixture-owned-data' });
const call = (op: keyof typeof resources.handlers, args: unknown) => resources.handlers[op].run(args).pipe(Effect.provideService(Binding.Binding, binding));
if (insert) yield* call('tables.insert', { table: 'notes', row: { title: 'Keep my local work' } });
const notes = yield* call('tables.list', { table: 'notes' });
const contacts = yield* call('shared.list', { alias: 'contacts' });
const result = { notes, contacts };
console.log(label, JSON.stringify(result));
return result as { notes: { rows: unknown[] }, contacts: { rows: Array<{ title: string }> } };
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer));
try {
await Effect.runPromise(session('first-start', true));
const unchanged = await Effect.runPromise(session('unchanged-restart'));
assert.equal(unchanged.notes.rows.length, 1);
await fs.writeFile(fixture, sql('Updated fixture contact'));
const changed = await Effect.runPromise(session('fixture-row-only-edit'));
assert.equal(changed.contacts.rows[0]?.title, 'Updated fixture contact');
assert.equal(changed.notes.rows.length, 1, 'Editing only shared fixture data should not delete the unchanged patch-owned notes table');
} finally {
await fs.rm(root, { recursive: true, force: true });
}Cause and proposed scope
initialize compares the entire stamp when there is no published baseline. That stamp includes shared fixture contents, so it removes the whole local database before per-source refresh can isolate the change.
Use the owned schema portion for the unpublished full-reset decision. Retain the existing resets for real schema changes, identity changes and missing storage. Let changedSources refresh only affected shared sources. No new state framework is needed. This is separate from failed-fixture recovery: every preparation here succeeds.
Audited at ef3e790. Found and independently checked by separate GPT-6 Astra agents in Oh My Pi. Only ordinary offline workflows and synthetic data were used.
Activity
fix(patchy): editing a shared fixture no longer wipes an unpublished …
fix(patchy): editing a shared fixture no longer wipes an unpublished …