Align shared reference and opaque cursor contracts

This commit is contained in:
jb
2026-09-19 10:01:47 -04:00
parent 348aa420ec
commit 240e16a258
6 changed files with 191 additions and 57 deletions
+17 -1
View File
@@ -10,8 +10,9 @@ import {
validateConsentCallback,
validateDatasetJobFence,
validateCompleteReportPins,
validateInventoryCursorUse,
} from '../src/lib/domain/capabilities';
import { afterEndInventoryCursorState, afterEndInventoryResult, ambiguousType, appendDatasetState, authorization, consent, datasetState, inventoryCursor, inventoryCursorState, inventoryQuery, inventoryResult, approvedMoneyPolicy, singletonRows, syntheticResource, systemJob, walletResult } from '../fixtures/contracts/t02';
import { absentLocation, afterEndInventoryCursorState, afterEndInventoryResult, ambiguousType, appendDatasetState, authorization, borrowedInventoryCursorLookup, changedQueryInventoryCursorLookup, changedRevisionInventoryCursorLookup, consent, datasetState, inventoryCursor, inventoryCursorLookup, inventoryCursorState, inventoryQuery, inventoryResult, approvedMoneyPolicy, singletonRows, systemListedStationPlaceholder, syntheticResource, systemJob, verifiedNamelessStation, walletResult } from '../fixtures/contracts/t02';
describe('T02 typed contract fixtures', () => {
test('separates snapshot generations from append checkpoints and unknown upstream time', () => {
@@ -48,6 +49,10 @@ describe('T02 typed contract fixtures', () => {
expect(inventoryQuery.sort.tieBreaker).toBe('item_id');
expect(inventoryQuery.authorizationRevisions['character:90000000000000001']).toBe(7);
expect(inventoryCursorState.pin.callerUserId).toBe('fixture-user-a');
expect(validateInventoryCursorUse(inventoryCursorState, inventoryCursorLookup)).toEqual({ valid: true });
expect(validateInventoryCursorUse(inventoryCursorState, borrowedInventoryCursorLookup)).toEqual({ valid: false, reason: 'caller_mismatch' });
expect(validateInventoryCursorUse(inventoryCursorState, changedQueryInventoryCursorLookup)).toEqual({ valid: false, reason: 'query_mismatch' });
expect(validateInventoryCursorUse(inventoryCursorState, changedRevisionInventoryCursorLookup)).toEqual({ valid: false, reason: 'authorization_mismatch' });
expect(inventoryCursorState.pin.authorizationEpochs['character:90000000000000001']).toBe(1);
expect(inventoryResult.status).toBe('ready');
if (inventoryResult.status === 'ready') {
@@ -76,6 +81,17 @@ describe('T02 typed contract fixtures', () => {
expect(singletonRows.map((row) => row.isSingleton)).toEqual([true, false, null]);
});
test('station evidence preserves verified, system-listed, and absent states', () => {
expect(verifiedNamelessStation.name).toBeNull();
expect(verifiedNamelessStation.evidence).toBe('verified');
expect(verifiedNamelessStation.sourceVerified).toBe(true);
expect(systemListedStationPlaceholder.evidence).toBe('system_listed');
expect(systemListedStationPlaceholder.sourceVerified).toBe(false);
expect(absentLocation.kind).toBe('unknown');
expect(absentLocation.sourceVerified).toBeNull();
expect(absentLocation.parentId).toBeNull();
});
test('ambiguous entity matches remain explicit instead of selecting by name', () => {
expect(ambiguousType.status).toBe('ambiguous');
if (ambiguousType.status === 'ambiguous') expect(ambiguousType.candidates).toHaveLength(2);