@codemem/server 0.50.0-beta.2 → 0.50.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator-maintenance.d.ts","sourceRoot":"","sources":["../../src/application/coordinator-maintenance.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,8BAA8B,EACnC,KAAK,gCAAgC,EACrC,+BAA+B,EAE/B,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,kCAAkC;IAClD,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,QAAQ,GAAG,wBAAwB,GAAG,WAAW,CAAC;CACzD;AAED,MAAM,WAAW,iCAAiC;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EACJ,UAAU,GACV,wBAAwB,GACxB,oBAAoB,GACpB,iBAAiB,GACjB,iBAAiB,GACjB,YAAY,GACZ,QAAQ,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACH;AAED,MAAM,MAAM,4BAA4B,GAAG,CAC1C,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,MAAM,KACf,OAAO,CAAC,kCAAkC,CAAC,CAAC;AA6BjD,eAAO,MAAM,oCAAoC,aAc/C,CAAC;AA2LH,wBAAsB,oCAAoC,CACzD,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,4BAA4B,CAAA;CAAE,GACrF,OAAO,CAAC,iCAAiC,CAAC,CAuB5C;AAED,MAAM,WAAW,sCAAsC;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QACZ,wBAAwB,EAAE,MAAM,CAAC;QACjC,MAAM,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;QAC5D,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B,CAAC,CAAC;CACH;AAkHD,wBAAsB,yCAAyC,CAC9D,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,gCAAgC,CAAC;IAC1C,gBAAgB,CAAC,EAAE,OAAO,+BAA+B,CAAC;CAC1D,GACC,OAAO,CAAC,sCAAsC,CAAC,CAwDjD"}
1
+ {"version":3,"file":"coordinator-maintenance.d.ts","sourceRoot":"","sources":["../../src/application/coordinator-maintenance.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,WAAW,EAEhB,KAAK,8BAA8B,EACnC,KAAK,gCAAgC,EACrC,+BAA+B,EAE/B,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,kCAAkC;IAClD,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,QAAQ,GAAG,wBAAwB,GAAG,WAAW,CAAC;CACzD;AAED,MAAM,WAAW,iCAAiC;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EACJ,UAAU,GACV,wBAAwB,GACxB,oBAAoB,GACpB,iBAAiB,GACjB,iBAAiB,GACjB,YAAY,GACZ,QAAQ,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACH;AAED,MAAM,MAAM,4BAA4B,GAAG,CAC1C,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,MAAM,KACf,OAAO,CAAC,kCAAkC,CAAC,CAAC;AA6BjD,eAAO,MAAM,oCAAoC,aAc/C,CAAC;AA2LH,wBAAsB,oCAAoC,CACzD,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,4BAA4B,CAAA;CAAE,GACrF,OAAO,CAAC,iCAAiC,CAAC,CAuB5C;AAED,MAAM,WAAW,sCAAsC;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QACZ,wBAAwB,EAAE,MAAM,CAAC;QACjC,MAAM,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;QAC5D,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B,CAAC,CAAC;CACH;AAqID,wBAAsB,yCAAyC,CAC9D,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,gCAAgC,CAAC;IAC1C,gBAAgB,CAAC,EAAE,OAAO,+BAA+B,CAAC;CAC1D,GACC,OAAO,CAAC,sCAAsC,CAAC,CAwDjD"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { closeSync, existsSync, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs";
2
2
  import { basename, dirname, isAbsolute, join, posix, resolve, win32 } from "node:path";
3
- import { ACCESS_CLEANUP_OP_TYPE, CodememConfigMutationError, CoordinatorAccountLinkError, CoordinatorReciprocalApprovalRequestChangedError, DEFAULT_TIME_WINDOW_S, FILE_CONTEXT_TRANSPORT_MAX_BYTES, LEGACY_SHARED_REVIEW_SCOPE_ID, LOCAL_DEFAULT_SCOPE_ID, LOCAL_SYNC_CAPABILITY, LOCAL_SYNC_FEATURES, LegacyTeamSetupAdditiveConvergenceError, LegacyTeamSetupDeviceRemovalsUnavailableError, LegacyTeamSetupRosterCapacityError, LocalIdentitySupersededError, MEMORY_FILTER_FIELD_TYPES, MEMORY_FILTER_NAMES, MEMORY_KIND_DESCRIPTIONS, MemoryStore, ObserverClient, PROMPT_TRANSPORT_PROTOCOL_RANGE, REMEMBER_MEMORY_KINDS, RICH_TIER_ANTHROPIC_DEFAULTS, RICH_TIER_DEFAULTS, RawEventIngestValidationError, RecipientPolicyEdgeRequestError, RecipientPolicyTeamCreateError, RecipientPolicyTeamRenameError, RemoteCoordinatorRequestError, SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, SIMPLE_TIER_ANTHROPIC_DEFAULTS, SIMPLE_TIER_DEFAULTS, SYNC_AUTHORIZATION_REFRESH_HEADER, SYNC_CAPABILITY_HEADER, SYNC_FEATURES_HEADER, SYNC_SCOPE_QUERY_PARAM, VERSION, VERSION as VERSION$1, VIEWER_IDENTITY_TARGET_KEYS, VIEWER_SERVICE_DISCRIMINATOR, addSyncScopeToBoundary, analyzeProjectScopeMappingChangeGuardrails, analyzeProjectScopeMappingChangesGuardrails, analyzeProjectScopeMappingDeletionGuardrails, applyLegacyTeamSetupCompletionManifest, applyLegacyTeamSetupCompletionManifestAndReturnActivation, applyLocalIdentitySwitch, applyPeerReplicationOps, areLegacyTeamSetupCompletionPolicyFactsAdditivelyCompatible, assertNoLocalIdentityOverride, automaticRecallHealth, buildAuthHeaders, buildBaseUrl, buildDirectPeerAuthHeaders, buildDistillReport, buildFilterBranchesWithContext, buildFilterClausesWithContext, buildPiFlushSignalFromEvent, buildRawEventEnvelopeFromCodexHook, buildRawEventEnvelopeFromHook, buildRawEventEnvelopeFromPiEvent, buildViewerIdentityTarget, canonicalCoordinatorLegacyTeamCompletionManifestJson, canonicalKeyId, canonicalMemoryKind, canonicalRepositoryProjectIdentity, canonicalWorkspaceIdentity, captureAccountOwnerProfilePins, changeCoordinatorAccount, claimRecipientPolicyActorMutations, claimRecipientPolicyPublicationMutation, classifyRecordedSyncFailure, cleanupNonces, clearLegacyTeamSetupDeviceDecision, clonePromptPackAttempt, coerceObserverCommand, commitDeviceIdentityBindings, commitRecipientPolicyEdges, commitViewerDeviceRemoval, completeCoordinatorDeviceSetup, completeLocalIdentitySwitch, containLegacyTeamSetupCompletionConflict, convertLegacyPairingAssignments, coordinatorAdminReadiness, coordinatorArchiveGroupAction, coordinatorAuthControllerReviewAction, coordinatorCreateAddDeviceInviteAction, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorCreateLegacyTeamCompletionAction, coordinatorCreateScopeAction, coordinatorDisableDeviceAction, coordinatorEnableDeviceAction, coordinatorGetLegacyTeamCompletionAction, coordinatorGrantScopeMembershipAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListConsumedTeamInvitesAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorListLegacyTeamCompletionsAction, coordinatorListRemovedDevicesAction, coordinatorListReviewedRecipientInviteEvidenceAction, coordinatorListScopeMembershipsAction, coordinatorListScopesAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorRenameGroupAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, coordinatorRevokeDeviceAction, coordinatorRevokeScopeMembershipAction, coordinatorStatusSnapshot, coordinatorUnarchiveGroupAction, coordinatorUpdateScopeAction, countShareableProjectMemories, countUnattributedImportedProjectMemories, createCoordinatorReciprocalApproval, createRecipientPolicyTeam, decodeInvitePayload, dedupeOrderedIds, defaultSpaceScopeIdForGroup, deleteProjectScopeSettingsMapping, deriveLegacyTeamSetupCompletionManifest, detectInstallKind, deterministicPolicyTeamId, diagnoseStalePeerReceivedRows, discoverLegacyTeamCandidates, dispatchFileContextTransport, ensureDeviceIdentity, executeShareProvisioning, extractInvitePayload, extractReplicationOps, fetchPeerRemovalLookup, filterReplicationOpsForSyncWithStatus, fingerprintPublicKey, formatHostPort, friendlyDeviceName, fromJson, generateWithOpenCodeV2, getCodememConfigPath, getCodememEnvOverrideValues, getCodememEnvOverrides, getCoordinatorEnrollmentReconciliationIssueSummary, getCoordinatorGroupPreference, getEffectiveCachedScopeAuthorization, getLegacyTeamSetupDraft, getRecipientPolicyAuthorityState, getSemanticIndexDiagnostics, getSyncResetState, getUpdateStatus, ingestRawEvents, inspectFreshLegacyTeamSetupActivation, inspectLegacyTeamSetupActivation, inviteTokenDigest, isAutomaticRecallMeasurement, isCoordinatorAdminDevice, isLegacyTeamCandidateSelectable, isLegacyTeamSetupProjectMappingIdentity, isPeerTrustBindingCompatible, isProjectScopeWithdrawn, isProjectSyncEnablementError, isScopedSyncCapability, judgeDistillReport, legacyDecisionCountsAsOwner, legacyPairingAssignmentsConverted, legacyTeamCandidateId, legacyTeamCandidateProjectInventory, legacyTeamCanonicalProjectRef, legacyTeamDeviceRef, legacyTeamResolvedProjectRef, legacyTeamSetupApiErrorCode, legacyTeamSetupCompletionActorIds, legacyTeamSetupFailureCheck, linkCoordinatorAccount, listAuthorizedScopesForPeer, listCoordinatorJoinRequests, listDeviceIdentityInventory, listInboundScopeRejections, listLegacyRecipientPolicyProjections, listMaintenanceJobs, listObserverProviderOptions, listOpenCodeV2Models, listPerPeerScopeSyncState, listProjectScopeCandidates, listProjectScopeInventory, listProjectScopeSettingsMappings, listRecipientPolicyIntent, listRecipientPolicyReview, listSharingDomainSettingsScopes, loadMemorySnapshotPageForPeer, loadPrivateKey, loadPublicKey, loadReplicationOpsForPeer, loadRuntimeSigningPublicKey, lookupCoordinatorPeers, markLocalIdentitySwitchBound, markLocalIdentitySwitchNotCommitted, memoryFilterValueMatchesType, mergeAddresses, migrateRecipientPolicyIntent, mutateCodememConfigFile, negotiateSyncCapability, newPairingFiltersNeedAdmin, normalizeAddress, normalizeCoordinatorAccountLinkOrigin, normalizeCoordinatorLegacyTeamCompletionManifest, normalizeHumanPresentationName, normalizeSyncCapability, normalizeSyncFeatures, normalizeTeammateName, parseAcceptedProjectIntent, parseBootstrapExpiry, parseFileContextTransportRequest, parsePositiveMemoryId, parseReassignScopePayload, parseRecipientPolicyEdgeCommitRequest, parseStrictInteger, parseSyncScopeRequest, persistShareOperation, personalScopeGrantStatusForPeer, planShareOperation, previewDeviceIdentityBindings, previewLegacyTeamSetupActivation, previewRecipientPolicyEdges, previewRecipientPolicyOnboarding, previewRecipientPolicyOnboardingFromReviewedIntent, probeAvailableCredentials, projectMatchesFilter, projectScopeMappingSavesOnlyNarrow, projectShareLifecycle, projectWithdrawalStates, promptPackArtifactFingerprint, queryPeerRemoval, readAccountLinkDevice, readAccountOwnerAssociation, readAccountOwnerAssociationRetainedAtMs, readCodememConfigFile, readCodememConfigFileForMutation, readCompletedLocalIdentitySwitches, readCoordinatorAccountChangeCapabilities, readCoordinatorAccountLinkStatus, readCoordinatorDeviceRejoinEvents, readCoordinatorDeviceSetup, readCoordinatorRejoinDiscovery, readCoordinatorResolvedAccountOwnerReceiptStatus, readCoordinatorResolvedAccountOwnerStatus, readCoordinatorSyncConfig, readOpenLocalIdentitySwitch, readPeerSyncActivity, readRepositoryIdentitySnapshot, reassignProjectScopeInventoryProject, recipientInviteAuthoritativeIdentityId, recipientPolicyDigest, recipientReviewedIntentDigest, reconcileCoordinatorEnrollmentSnapshot, reconcileRecipientPolicyProject, reconcileShareOperationAcceptance, reconstructLegacyTeamSetupCompletionManifest, recordAutomaticRecall, recordHighestObservedDirectSignatureVersion, recordLocalIdentitySwitch, recordNonce, recordPromptPackArtifacts, recordPromptPackTerminal, recordSyncAttempt, recordSyncTransferObservation, refreshAuthorizedCoordinatorPeerTrust, refreshConfiguredScopeMembershipCache, refreshLegacyTeamCandidate, rejectInboundScopeFailures, removePairingState, removePeerFromThisDevice, removeRevokedPeers, renameRecipientPolicyTeam, replayLegacyTeamSetupActivation, repositoryIdentitiesByWorkspace, repositoryIdentityForWorkspace, requestJson, requireLegacyTeamSetupAccessDeltaWithinLimit, resolveCodememConfigPath, resolveDbPath, resolveObserverDefaultModel, resolveObserverRuntime, resolveProject, resolveProjectRoot, resolveRecipientPolicyReview, resolveRecipientPolicyReviewBulk, resolveRetireTarget, resolveVisibleScopeIds, resumeDeviceRebind, resumeProjectOnThisDevice, retireDeviceLocally, runDeviceRebind, runSyncPass, schema, scopeAuthorizationFailureReason, searchPiSessions, serializeRecipientPolicyActorMutations, serializeRecipientPolicyCoordinatorGroupMutation, serializeRecipientPolicyPublicationMutation, serializeRecipientPolicyTeamMutation, setLegacyTeamSetupDeviceAssignment, setLegacyTeamSetupDeviceDecision, setLegacyTeamSetupProjectMapping, setLocalSyncFeature, setPeerProjectFilterChecked, stopProjectOnThisDevice, summarizeInboundScopeRejections, summaryLikeSqlPredicate, supportsSyncFeature, syncScopeResetRequiredPayload, toJson, tryUpdateRetrievalDelivery, updatePeerAddresses, upsertCoordinatorGroupPreference, upsertProjectScopeSettingsMappings, validateLegacyTeamSetupCompletionManifest, validateLegacyTeamSetupCompletionManifestBinding, validateRawEvents, verifiedLocalKeyId, verifyDirectPeerSignature, verifyRecipientReviewedIntent, verifySignature, wakeRecipientPoliciesForIdentities, wakeRecipientPoliciesForProjectIdentities } from "@codemem/core";
3
+ import { ACCESS_CLEANUP_OP_TYPE, CodememConfigMutationError, CoordinatorAccountLinkError, CoordinatorReciprocalApprovalRequestChangedError, DEFAULT_TIME_WINDOW_S, FILE_CONTEXT_TRANSPORT_MAX_BYTES, LEGACY_SHARED_REVIEW_SCOPE_ID, LOCAL_DEFAULT_SCOPE_ID, LOCAL_SYNC_CAPABILITY, LOCAL_SYNC_FEATURES, LegacyTeamSetupAdditiveConvergenceError, LegacyTeamSetupDeviceRemovalsUnavailableError, LegacyTeamSetupRosterCapacityError, LocalIdentitySupersededError, MEMORY_FILTER_FIELD_TYPES, MEMORY_FILTER_NAMES, MEMORY_KIND_DESCRIPTIONS, MemoryStore, ObserverClient, PROMPT_TRANSPORT_PROTOCOL_RANGE, RECIPIENT_POLICY_SHARED_SCOPE_CODE, REMEMBER_MEMORY_KINDS, RICH_TIER_ANTHROPIC_DEFAULTS, RICH_TIER_DEFAULTS, RawEventIngestValidationError, RecipientPolicyEdgeRequestError, RecipientPolicyTeamCreateError, RecipientPolicyTeamRenameError, RemoteCoordinatorRequestError, SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, SIMPLE_TIER_ANTHROPIC_DEFAULTS, SIMPLE_TIER_DEFAULTS, SYNC_AUTHORIZATION_REFRESH_HEADER, SYNC_CAPABILITY_HEADER, SYNC_FEATURES_HEADER, SYNC_SCOPE_QUERY_PARAM, VERSION, VERSION as VERSION$1, VIEWER_IDENTITY_TARGET_KEYS, VIEWER_SERVICE_DISCRIMINATOR, addSyncScopeToBoundary, analyzeProjectScopeMappingChangeGuardrails, analyzeProjectScopeMappingChangesGuardrails, analyzeProjectScopeMappingDeletionGuardrails, applyLegacyTeamSetupCompletionManifest, applyLegacyTeamSetupCompletionManifestAndReturnActivation, applyLocalIdentitySwitch, applyPeerReplicationOps, areLegacyTeamSetupCompletionPolicyFactsAdditivelyCompatible, assertNoLocalIdentityOverride, automaticRecallHealth, buildAuthHeaders, buildBaseUrl, buildDirectPeerAuthHeaders, buildDistillReport, buildFilterBranchesWithContext, buildFilterClausesWithContext, buildPiFlushSignalFromEvent, buildRawEventEnvelopeFromCodexHook, buildRawEventEnvelopeFromHook, buildRawEventEnvelopeFromPiEvent, buildViewerIdentityTarget, canonicalCoordinatorLegacyTeamCompletionManifestJson, canonicalKeyId, canonicalMemoryKind, canonicalRepositoryProjectIdentity, canonicalWorkspaceIdentity, captureAccountOwnerProfilePins, changeCoordinatorAccount, claimRecipientPolicyActorMutations, claimRecipientPolicyPublicationMutation, classifyRecordedSyncFailure, cleanupNonces, clearLegacyTeamSetupDeviceDecision, clonePromptPackAttempt, coerceObserverCommand, commitDeviceIdentityBindings, commitRecipientPolicyEdges, commitViewerDeviceRemoval, completeCoordinatorDeviceSetup, completeLocalIdentitySwitch, containLegacyTeamSetupCompletionConflict, convertLegacyPairingAssignments, coordinatorAdminReadiness, coordinatorArchiveGroupAction, coordinatorAuthControllerReviewAction, coordinatorCreateAddDeviceInviteAction, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorCreateLegacyTeamCompletionAction, coordinatorCreateScopeAction, coordinatorDisableDeviceAction, coordinatorEnableDeviceAction, coordinatorGetLegacyTeamCompletionAction, coordinatorGrantScopeMembershipAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListConsumedTeamInvitesAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorListLegacyTeamCompletionsAction, coordinatorListRemovedDevicesAction, coordinatorListReviewedRecipientInviteEvidenceAction, coordinatorListScopeMembershipsAction, coordinatorListScopesAction, coordinatorListTeamMemberRemovalsAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorRenameGroupAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, coordinatorRevokeDeviceAction, coordinatorRevokeScopeMembershipAction, coordinatorStatusSnapshot, coordinatorUnarchiveGroupAction, coordinatorUpdateScopeAction, countShareableProjectMemories, countUnattributedImportedProjectMemories, createCoordinatorReciprocalApproval, createRecipientPolicyBoundaryInspector, createRecipientPolicyTeam, decodeInvitePayload, dedupeOrderedIds, defaultSpaceScopeIdForGroup, deleteProjectScopeSettingsMapping, deriveLegacyTeamSetupCompletionManifest, detectInstallKind, deterministicPolicyTeamId, diagnoseStalePeerReceivedRows, discoverLegacyTeamCandidates, dispatchFileContextTransport, ensureDeviceIdentity, executeShareProvisioning, extractInvitePayload, extractReplicationOps, fetchPeerRemovalLookup, filterReplicationOpsForSyncWithStatus, fingerprintPublicKey, formatHostPort, friendlyDeviceName, fromJson, generateWithOpenCodeV2, getCodememConfigPath, getCodememEnvOverrideValues, getCodememEnvOverrides, getCoordinatorEnrollmentReconciliationIssueSummary, getCoordinatorGroupPreference, getEffectiveCachedScopeAuthorization, getLegacyTeamSetupDraft, getRecipientPolicyAuthorityState, getSemanticIndexDiagnostics, getSyncResetState, getUpdateStatus, ingestRawEvents, inspectFreshLegacyTeamSetupActivation, inspectLegacyTeamSetupActivation, inviteTokenDigest, isAutomaticRecallMeasurement, isCoordinatorAdminDevice, isLegacyTeamCandidateSelectable, isLegacyTeamSetupProjectMappingIdentity, isPeerTrustBindingCompatible, isProjectScopeWithdrawn, isProjectSyncEnablementError, isScopedSyncCapability, judgeDistillReport, legacyDecisionCountsAsOwner, legacyPairingAssignmentsConverted, legacyTeamCandidateId, legacyTeamCandidateProjectInventory, legacyTeamCanonicalProjectRef, legacyTeamDeviceRef, legacyTeamResolvedProjectRef, legacyTeamSetupApiErrorCode, legacyTeamSetupCompletionActorIds, legacyTeamSetupFailureCheck, linkCoordinatorAccount, listAuthorizedScopesForPeer, listCoordinatorJoinRequests, listDeviceIdentityInventory, listInboundScopeRejections, listLegacyRecipientPolicyProjections, listMaintenanceJobs, listObserverProviderOptions, listOpenCodeV2Models, listPerPeerScopeSyncState, listProjectScopeCandidates, listProjectScopeInventory, listProjectScopeSettingsMappings, listRecipientPolicyIntent, listRecipientPolicyReview, listSharingDomainSettingsScopes, loadMemorySnapshotPageForPeer, loadPrivateKey, loadPublicKey, loadReplicationOpsForPeer, loadRuntimeSigningPublicKey, lookupCoordinatorPeers, markLocalIdentitySwitchBound, markLocalIdentitySwitchNotCommitted, memoryFilterValueMatchesType, mergeAddresses, migrateRecipientPolicyIntent, mutateCodememConfigFile, negotiateSyncCapability, newPairingFiltersNeedAdmin, normalizeAddress, normalizeCoordinatorAccountLinkOrigin, normalizeCoordinatorLegacyTeamCompletionManifest, normalizeHumanPresentationName, normalizeSyncCapability, normalizeSyncFeatures, normalizeTeammateName, parseAcceptedProjectIntent, parseBootstrapExpiry, parseFileContextTransportRequest, parsePositiveMemoryId, parseReassignScopePayload, parseRecipientPolicyEdgeCommitRequest, parseStrictInteger, parseSyncScopeRequest, peerFacingScopeResetReason, persistShareOperation, personalScopeGrantStatusForPeer, planShareOperation, previewDeviceIdentityBindings, previewLegacyTeamSetupActivation, previewRecipientPolicyEdges, previewRecipientPolicyOnboarding, previewRecipientPolicyOnboardingFromReviewedIntent, probeAvailableCredentials, projectMatchesFilter, projectScopeMappingSavesOnlyNarrow, projectShareLifecycle, projectWithdrawalStates, promptPackArtifactFingerprint, queryPeerRemoval, readAccountLinkDevice, readAccountOwnerAssociation, readAccountOwnerAssociationRetainedAtMs, readCodememConfigFile, readCodememConfigFileForMutation, readCompletedLocalIdentitySwitches, readCoordinatorAccountChangeCapabilities, readCoordinatorAccountLinkStatus, readCoordinatorDeviceRejoinEvents, readCoordinatorDeviceSetup, readCoordinatorRejoinDiscovery, readCoordinatorResolvedAccountOwnerReceiptStatus, readCoordinatorResolvedAccountOwnerStatus, readCoordinatorSyncConfig, readOpenLocalIdentitySwitch, readPeerSyncActivity, readRepositoryIdentitySnapshot, reassignProjectScopeInventoryProject, recipientInviteAuthoritativeIdentityId, recipientPolicyDigest, recipientReviewedIntentDigest, reconcileCoordinatorEnrollmentSnapshot, reconcileRecipientPolicyProject, reconcileShareOperationAcceptance, reconstructLegacyTeamSetupCompletionManifest, recordAutomaticRecall, recordHighestObservedDirectSignatureVersion, recordLocalIdentitySwitch, recordNonce, recordPromptPackArtifacts, recordPromptPackTerminal, recordSyncAttempt, recordSyncTransferObservation, refreshAuthorizedCoordinatorPeerTrust, refreshConfiguredScopeMembershipCache, refreshLegacyTeamCandidate, rejectInboundScopeFailures, removePairingState, removePeerFromThisDevice, removeRevokedPeers, renameRecipientPolicyTeam, replayLegacyTeamSetupActivation, repositoryIdentitiesByWorkspace, repositoryIdentityForWorkspace, requestJson, requireLegacyTeamSetupAccessDeltaWithinLimit, resolveCodememConfigPath, resolveDbPath, resolveObserverDefaultModel, resolveObserverRuntime, resolveProject, resolveProjectRoot, resolveRecipientPolicyReview, resolveRecipientPolicyReviewBulk, resolveRetireTarget, resolveVisibleScopeIds, resumeDeviceRebind, resumeProjectOnThisDevice, retireDeviceLocally, runDeviceRebind, runSyncPass, schema, scopeAuthorizationFailureReason, scopesWrittenByInboundOp, searchPiSessions, serializeRecipientPolicyActorMutations, serializeRecipientPolicyCoordinatorGroupMutation, serializeRecipientPolicyPublicationMutation, serializeRecipientPolicyTeamMutation, setLegacyTeamSetupDeviceAssignment, setLegacyTeamSetupDeviceDecision, setLegacyTeamSetupProjectMapping, setLocalSyncFeature, setPeerProjectFilterChecked, stopProjectOnThisDevice, summarizeInboundScopeRejections, summaryLikeSqlPredicate, supportsSyncFeature, syncScopeResetRequiredPayload, toJson, tryUpdateRetrievalDelivery, updatePeerAddresses, upsertCoordinatorGroupPreference, upsertProjectScopeSettingsMappings, validateLegacyTeamSetupCompletionManifest, validateLegacyTeamSetupCompletionManifestBinding, validateRawEvents, verifiedLocalKeyId, verifyDirectPeerSignature, verifyRecipientReviewedIntent, verifySignature, wakeRecipientPoliciesForIdentities, wakeRecipientPoliciesForProjectIdentities } from "@codemem/core";
4
4
  import { serveStatic } from "@hono/node-server/serve-static";
5
5
  import { Hono } from "hono";
6
6
  import { createCipheriv, createDecipheriv, createHash, createPrivateKey, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -1801,7 +1801,7 @@ var DEFAULTS = {
1801
1801
  observer_auth_timeout_ms: 1500,
1802
1802
  observer_auth_cache_ttl_s: 300,
1803
1803
  observer_headers: {},
1804
- observer_max_chars: 12e3,
1804
+ observer_max_chars: 24e3,
1805
1805
  pack_observation_limit: 50,
1806
1806
  pack_session_limit: 10,
1807
1807
  sync_enabled: false,
@@ -5814,7 +5814,7 @@ function validatePackRequest(value) {
5814
5814
  }
5815
5815
  function ledgerFailureStatus(reason) {
5816
5816
  if (reason === "idempotency_conflict") return 409;
5817
- if (reason === "attempt_not_found") return 422;
5817
+ if (reason === "attempt_not_found" || reason === "attempt_incomplete") return 422;
5818
5818
  if (reason === "storage_unavailable") return 503;
5819
5819
  return 400;
5820
5820
  }
@@ -6269,6 +6269,15 @@ async function advancePendingProjectSharesOperation(store, options) {
6269
6269
  var RECIPIENT_POLICY_MAINTENANCE_MAX_LIMIT = 10;
6270
6270
  var RECIPIENT_POLICY_MAINTENANCE_DEFAULT_LIMIT = 3;
6271
6271
  var RECIPIENT_POLICY_MAINTENANCE_BACKOFF_MS = 6e4;
6272
+ /**
6273
+ * A legacy Project in a shared multi-Project scope gets the same answer on every attempt until
6274
+ * its scope mapping or the scope's Projects change, so it is not retried on a timer. A wake
6275
+ * (which clears last_attempt_at) still runs it. The check reads only local mappings and scopes:
6276
+ * a coordinator refresh that changes the scope updates those rows, and the next check sees it.
6277
+ */
6278
+ function waitsForSharedScopeChange(authority, projectId, boundaryBlocker) {
6279
+ return authority.authority_state === "legacy" && authority.safe_error_code === RECIPIENT_POLICY_SHARED_SCOPE_CODE && boundaryBlocker(projectId) === RECIPIENT_POLICY_SHARED_SCOPE_CODE;
6280
+ }
6272
6281
  function recipientPolicyMaintenanceCandidates(store, retryBefore, limit) {
6273
6282
  const repositoryIdentities = repositoryIdentitiesByWorkspace(store.db);
6274
6283
  const canonicalize = (projectId) => canonicalRepositoryProjectIdentity(repositoryIdentities, projectId);
@@ -6291,9 +6300,12 @@ function recipientPolicyMaintenanceCandidates(store, retryBefore, limit) {
6291
6300
  }
6292
6301
  if (String(row.last_attempt_at ?? "") > String(current.last_attempt_at ?? "")) authorityByProject.set(projectId, row);
6293
6302
  }
6303
+ const boundaryBlocker = createRecipientPolicyBoundaryInspector(store.db);
6294
6304
  return [...new Set(projectIds.map((row) => canonicalize(row.canonical_project_identity)))].filter((projectId) => {
6295
6305
  const authority = authorityByProject.get(projectId);
6296
- return authority == null || authority.last_attempt_at == null || authority.safe_error_code == null && authority.authority_state !== "active" || authority.last_attempt_at <= retryBefore;
6306
+ if (authority == null || authority.last_attempt_at == null) return true;
6307
+ if (waitsForSharedScopeChange(authority, projectId, boundaryBlocker)) return false;
6308
+ return authority.safe_error_code == null && authority.authority_state !== "active" || authority.last_attempt_at <= retryBefore;
6297
6309
  }).toSorted((left, right) => {
6298
6310
  const leftAttempt = authorityByProject.get(left)?.last_attempt_at;
6299
6311
  const rightAttempt = authorityByProject.get(right)?.last_attempt_at;
@@ -9823,6 +9835,41 @@ function mappingGuardrailChallenge(warnings, missing) {
9823
9835
  guardrail_warnings: warnings
9824
9836
  };
9825
9837
  }
9838
+ /**
9839
+ * Whether the bulk mapping save accepts these mappings. It cannot carry confirmations, so any
9840
+ * warning that requires one refuses it, and the person saves those entries one at a time.
9841
+ */
9842
+ function bulkProjectMappingVerdict(store, mappingInputs, deviceId) {
9843
+ const analyses = analyzeProjectScopeMappingChangesGuardrails(store.db, mappingInputs.map((input) => ({
9844
+ ...input,
9845
+ deviceId
9846
+ })));
9847
+ const warnings = analyses.flatMap((analysis) => analysis.warnings);
9848
+ const unmapped = analyses.find((analysis) => analysis.requested_workspace_identity?.startsWith("unmapped:"));
9849
+ if (unmapped) return {
9850
+ warnings,
9851
+ refusal: {
9852
+ status: 400,
9853
+ body: {
9854
+ error: "unmapped_project_local_only",
9855
+ message: "Unmapped projects need a stable path, git remote, or workspace id before assigning a Sharing domain.",
9856
+ guardrail_warnings: unmapped.warnings
9857
+ }
9858
+ }
9859
+ };
9860
+ const missing = analyses.flatMap((analysis) => missingGuardrailConfirmations(analysis.warnings, []));
9861
+ if (missing.length === 0) return {
9862
+ refusal: null,
9863
+ warnings
9864
+ };
9865
+ return {
9866
+ warnings,
9867
+ refusal: {
9868
+ status: 409,
9869
+ body: mappingGuardrailChallenge(warnings, missing)
9870
+ }
9871
+ };
9872
+ }
9826
9873
  function parseViewerProjectMappingInput(body) {
9827
9874
  const id = optionalViewerInteger(body, "id");
9828
9875
  const priority = optionalViewerInteger(body, "priority");
@@ -10118,7 +10165,7 @@ function resolveProjectInviteSelection(store, requestedIds, initiatingDeviceId)
10118
10165
  return requestedIds.map((projectId) => {
10119
10166
  const project = byIdentity.get(projectId);
10120
10167
  if (!project) throw new Error("project_selection_unknown");
10121
- if (project.guardrail_warnings.some((warning) => warning.code === "basename_collision_review" && warning.requires_confirmation)) throw new Error("project_selection_ambiguous");
10168
+ if (project.ambiguous_name === true || project.guardrail_warnings.some((warning) => warning.code === "basename_collision_review" && warning.requires_confirmation)) throw new Error("project_selection_ambiguous");
10122
10169
  if (project.read_only || project.identity_source === "unmapped" || project.memory_count == null || project.guardrail_warnings.some((warning) => warning.requires_confirmation)) throw new Error("project_selection_unsupported");
10123
10170
  return {
10124
10171
  canonicalIdentity: project.workspace_identity,
@@ -10549,7 +10596,8 @@ function coordinatorEnrollmentFailureCode(error) {
10549
10596
  "coordinator_id_invalid",
10550
10597
  "coordinator_invite_group_mismatch",
10551
10598
  "coordinator_invite_list_malformed",
10552
- "reconciliation_time_invalid"
10599
+ "reconciliation_time_invalid",
10600
+ "team_member_removal_invalid"
10553
10601
  ])).has(message)) return message;
10554
10602
  if (/timeout|timed out|abort/iu.test(message)) return "request_timeout";
10555
10603
  if (/fetch failed|network|econn|enotfound/iu.test(message)) return "network_error";
@@ -10613,6 +10661,7 @@ async function reconcileConfiguredCoordinatorGroup(store, groupId, config, optio
10613
10661
  const adminSecret = config.syncCoordinatorAdminSecret.trim();
10614
10662
  const listDevices = options.listDevices ?? coordinatorListDevicesAction;
10615
10663
  const listInvites = options.listConsumedTeamInvites ?? coordinatorListConsumedTeamInvitesAction;
10664
+ const listRemovals = options.listTeamMemberRemovals ?? coordinatorListTeamMemberRemovalsAction;
10616
10665
  const reconcile = options.reconcileSnapshot ?? ((input) => reconcileCoordinatorEnrollmentSnapshot(store.db, input));
10617
10666
  let stage = "complete_device_setup";
10618
10667
  try {
@@ -10640,6 +10689,11 @@ async function reconcileConfiguredCoordinatorGroup(store, groupId, config, optio
10640
10689
  remoteUrl,
10641
10690
  adminSecret
10642
10691
  });
10692
+ const teamMemberRemovals = await listRemovals({
10693
+ groupId,
10694
+ remoteUrl,
10695
+ adminSecret
10696
+ }).catch(() => void 0);
10643
10697
  stage = "complete_device_setup";
10644
10698
  context.assertCurrent();
10645
10699
  stage = "reconcile_snapshot";
@@ -10648,6 +10702,7 @@ async function reconcileConfiguredCoordinatorGroup(store, groupId, config, optio
10648
10702
  groupId,
10649
10703
  enrollments,
10650
10704
  consumedTeamInvites: invites,
10705
+ teamMemberRemovals,
10651
10706
  localDeviceId: store.deviceId
10652
10707
  }) };
10653
10708
  } catch (error) {
@@ -10980,6 +11035,7 @@ async function reconcileRecipientPolicyProjects(store, options = {}) {
10980
11035
  function recipientPolicyReadState(authority) {
10981
11036
  if (!authority) return "pending";
10982
11037
  if (authority.safeErrorCode && RECIPIENT_POLICY_WAITING_ERRORS.has(authority.safeErrorCode)) return "waiting";
11038
+ if (authority.authorityState === "legacy" && authority.safeErrorCode === RECIPIENT_POLICY_SHARED_SCOPE_CODE) return "legacy_scope";
10983
11039
  if (authority.safeErrorCode || authority.authorityState === "rolled_back") return "needs_attention";
10984
11040
  if (authority.authorityState === "active") return "active";
10985
11041
  if (authority.authorityState === "eligible") return "verifying";
@@ -10998,6 +11054,10 @@ function recipientPolicyReadCopy(state) {
10998
11054
  label: "Waiting to reconcile",
10999
11055
  explanation: "Waiting for devices or a fresh coordinator snapshot. No partial grant is applied."
11000
11056
  };
11057
+ if (state === "legacy_scope") return {
11058
+ label: "Shared scope controls access",
11059
+ explanation: "Access for this Project is still controlled by the shared scope it belongs to. Nothing is required."
11060
+ };
11001
11061
  if (state === "needs_attention") return {
11002
11062
  label: "Reconciliation needs attention",
11003
11063
  explanation: "Legacy scope enforcement remains in control until this Project is safe to retry."
@@ -12604,30 +12664,17 @@ function validateManagedScopes(scopeIds, context) {
12604
12664
  }
12605
12665
  return null;
12606
12666
  }
12607
- function addExistingMutationScopes(db, ops, scopeIds) {
12608
- const existingScopes = db.prepare("SELECT DISTINCT scope_id FROM memory_items WHERE import_key = ?");
12609
- for (const op of ops) {
12610
- if (![
12611
- "upsert",
12612
- "delete",
12613
- "reassign_scope"
12614
- ].includes(op.op_type)) continue;
12615
- const rows = existingScopes.all(op.entity_id);
12616
- for (const { scope_id: scope } of rows) if (typeof scope === "string" && scope.trim()) scopeIds.add(scope.trim());
12617
- }
12618
- }
12619
12667
  function cleanOpScopeId(op) {
12620
12668
  return typeof op.scope_id === "string" ? op.scope_id.trim() : "";
12621
12669
  }
12622
- /** Every scope a batch touches, including both sides of a reassignment. Payloads are already parsed. */
12623
- function mutationScopeIds(ops) {
12670
+ /**
12671
+ * Every scope a pushed batch touches: each op's own scope, and each scope of a stored copy
12672
+ * the op would change, by the rule the pull path uses. A move's new side needs only its new
12673
+ * scope unless this device stores a copy elsewhere, and its old side needs its old scope.
12674
+ */
12675
+ function inboundWriteScopeIds(db, ops, senderId) {
12624
12676
  const scopeIds = new Set(ops.map(cleanOpScopeId));
12625
- for (const op of ops) {
12626
- if (op.op_type !== "reassign_scope") continue;
12627
- const reassignment = parseReassignScopePayload(op);
12628
- scopeIds.add(reassignment.old_scope_id);
12629
- scopeIds.add(reassignment.new_scope_id);
12630
- }
12677
+ for (const op of ops) for (const scopeId of scopesWrittenByInboundOp(db, op, senderId)) scopeIds.add(scopeId);
12631
12678
  return scopeIds;
12632
12679
  }
12633
12680
  function rejectUnauthorizedInboundBatch(c, ops, context, options) {
@@ -12637,20 +12684,38 @@ function rejectUnauthorizedInboundBatch(c, ops, context, options) {
12637
12684
  });
12638
12685
  if (rejected) {
12639
12686
  recordInboundScopeFailure(context);
12687
+ const rejections = peerFacingRejections(ops, rejected.rejections);
12640
12688
  return c.json({
12641
12689
  error: "scope_rejected",
12642
- reason: rejected.rejections[0]?.reason ?? "scope_mismatch",
12643
- rejections: rejected.rejections,
12690
+ reason: rejections[0]?.reason ?? "scope_mismatch",
12691
+ rejections,
12644
12692
  sync_capability: LOCAL_SYNC_CAPABILITY,
12645
12693
  scope_id: options.scopeId
12646
12694
  }, 403);
12647
12695
  }
12648
- const scopeIds = new Set(options.managedScopeIds);
12649
- addExistingMutationScopes(context.db, ops, scopeIds);
12650
- const failure = validateManagedScopes(scopeIds, context);
12696
+ const failure = validateManagedScopes(inboundWriteScopeIds(context.db, ops, context.peerDeviceId), context);
12651
12697
  if (!failure) return null;
12652
12698
  recordInboundScopeFailure(context);
12653
- return c.json(syncScopeResetRequiredPayload(getSyncResetState(context.db), failure.reason, LOCAL_SYNC_CAPABILITY, failure.scopeId), 409);
12699
+ const reason = peerFacingScopeResetReason(failure.reason);
12700
+ const scopeId = (/* @__PURE__ */ new Set([options.scopeId, ...ops.map(cleanOpScopeId)])).has(failure.scopeId) ? failure.scopeId : options.scopeId;
12701
+ if (reason !== failure.reason || scopeId !== failure.scopeId) logWithheldScopeDenial(failure.reason, failure.scopeId);
12702
+ return c.json(syncScopeResetRequiredPayload(getSyncResetState(context.db), reason, LOCAL_SYNC_CAPABILITY, scopeId), 409);
12703
+ }
12704
+ /** Records locally what a scope denial withheld from the peer's answer. */
12705
+ function logWithheldScopeDenial(reason, scopeId) {
12706
+ console.warn(`[sync] scope denied to peer: reason=${reason} scope=${scopeId ?? "none"}`);
12707
+ }
12708
+ /**
12709
+ * Rejections as a peer may see them: each names its op's own scope, never the scope of a
12710
+ * stored copy, and membership and scope state collapse into one reason.
12711
+ */
12712
+ function peerFacingRejections(ops, rejections) {
12713
+ const declared = new Map(ops.map((op) => [op.op_id, cleanOpScopeId(op) || null]));
12714
+ return rejections.map((rejection) => ({
12715
+ ...rejection,
12716
+ scope_id: declared.get(rejection.op_id) ?? null,
12717
+ reason: rejection.reason === "scope_mismatch" ? rejection.reason : "missing_scope"
12718
+ }));
12654
12719
  }
12655
12720
  function recordInboundScopeFailure(context) {
12656
12721
  recordSyncTransferObservation(context.db, context.peerDeviceId, "receive", {
@@ -12731,7 +12796,9 @@ function serveChannelRead(c, options) {
12731
12796
  function syncScopeProvided(provided, syncChannelPeerPin) {
12732
12797
  return syncChannelPeerPin !== void 0 || provided;
12733
12798
  }
12734
- function syncScopeResetResponse(c, store, reason, syncChannelPeerPin) {
12799
+ function syncScopeResetResponse(c, store, preciseReason, syncChannelPeerPin) {
12800
+ const reason = peerFacingScopeResetReason(preciseReason);
12801
+ if (reason !== preciseReason) logWithheldScopeDenial(preciseReason, c.req.query(SYNC_SCOPE_QUERY_PARAM) ?? null);
12735
12802
  if (syncChannelPeerPin !== void 0) return c.json({
12736
12803
  error: "reset_required",
12737
12804
  reset_required: true,
@@ -12993,11 +13060,9 @@ function syncProtocolRoutes(getStore, opts = {}) {
12993
13060
  applyScopeFilter: false,
12994
13061
  supportsReassignScope: peerFeatures.includes("reassign_scope")
12995
13062
  });
12996
- const validatedOps = normalizedOps.filter((op) => !isProjectScopeWithdrawn(scopeContext.db, cleanOpScopeId(op)));
12997
- const rejected = rejectUnauthorizedInboundBatch(c, validatedOps, scopeContext, {
13063
+ const rejected = rejectUnauthorizedInboundBatch(c, normalizedOps.filter((op) => !isProjectScopeWithdrawn(scopeContext.db, cleanOpScopeId(op))), scopeContext, {
12998
13064
  enabled: negotiated !== "unsupported",
12999
- scopeId: scopeRequest.scope_id,
13000
- managedScopeIds: mutationScopeIds(validatedOps)
13065
+ scopeId: scopeRequest.scope_id
13001
13066
  });
13002
13067
  if (rejected) return rejected;
13003
13068
  const result = applyInboundSyncOps(store, filtered.allowed, localDeviceId, peerDeviceId);
@@ -14645,22 +14710,12 @@ function syncRoutes(getStore, getSyncRuntimeStatus, options = {}) {
14645
14710
  const mappingInputs = parseViewerProjectMappingInputs(body);
14646
14711
  releasePublicationMutation = await claimRecipientPolicyPublicationMutation(store.db);
14647
14712
  const [deviceId] = ensureDeviceIdentity(store.db, { keysDir: syncKeysDir() });
14648
- const analyses = analyzeProjectScopeMappingChangesGuardrails(store.db, mappingInputs.map((input) => ({
14649
- ...input,
14650
- deviceId
14651
- })));
14652
- const unmapped = analyses.find((analysis) => analysis.requested_workspace_identity?.startsWith("unmapped:"));
14653
- if (unmapped) return c.json({
14654
- error: "unmapped_project_local_only",
14655
- message: "Unmapped projects need a stable path, git remote, or workspace id before assigning a Sharing domain.",
14656
- guardrail_warnings: unmapped.warnings
14657
- }, 400);
14658
- const missingConfirmations = analyses.flatMap((analysis) => missingGuardrailConfirmations(analysis.warnings, []));
14659
- if (missingConfirmations.length > 0) return c.json(mappingGuardrailChallenge(analyses.flatMap((analysis) => analysis.warnings), missingConfirmations), 409);
14713
+ const verdict = bulkProjectMappingVerdict(store, mappingInputs, deviceId);
14714
+ if (verdict.refusal) return c.json(verdict.refusal.body, verdict.refusal.status);
14660
14715
  return c.json({
14661
14716
  ok: true,
14662
14717
  mappings: saveProjectMappingsAndWakePolicies(store, deviceId, mappingInputs),
14663
- guardrail_warnings: analyses.flatMap((analysis) => analysis.warnings)
14718
+ guardrail_warnings: verdict.warnings
14664
14719
  });
14665
14720
  } catch (error) {
14666
14721
  return c.json({ error: error instanceof Error ? error.message : String(error) }, 400);
@@ -14668,6 +14723,24 @@ function syncRoutes(getStore, getSyncRuntimeStatus, options = {}) {
14668
14723
  releasePublicationMutation?.();
14669
14724
  }
14670
14725
  });
14726
+ app.post("/api/sync/sharing-domains/project-mappings/bulk/check", async (c) => {
14727
+ const store = getStore();
14728
+ const body = await parseViewerJsonBody(c);
14729
+ if (!body) return c.json({ error: "invalid json" }, 400);
14730
+ try {
14731
+ const mappingInputs = parseViewerProjectMappingInputs(body);
14732
+ const [deviceId] = ensureDeviceIdentity(store.db, { keysDir: syncKeysDir() });
14733
+ const verdict = bulkProjectMappingVerdict(store, mappingInputs, deviceId);
14734
+ return c.json({
14735
+ ok: true,
14736
+ accepted: verdict.refusal === null,
14737
+ refusal: verdict.refusal?.body ?? null,
14738
+ guardrail_warnings: verdict.warnings
14739
+ });
14740
+ } catch (error) {
14741
+ return c.json({ error: error instanceof Error ? error.message : String(error) }, 400);
14742
+ }
14743
+ });
14671
14744
  app.delete("/api/sync/sharing-domains/project-mappings/:id", (c) => deleteProjectScopeMappingRoute(c, getStore()));
14672
14745
  app.post("/api/sync/peers/identity", async (c) => {
14673
14746
  const store = getStore();
@@ -18180,7 +18253,11 @@ var retrievalExposures = sqliteTable("retrieval_exposures", {
18180
18253
  memory_deleted_at: text("memory_deleted_at"),
18181
18254
  score_summary_json: text("score_summary_json"),
18182
18255
  reason_codes_json: text("reason_codes_json")
18183
- }, (table) => [uniqueIndex("idx_retrieval_exposures_attempt_rank").on(table.attempt_id, table.rank), index("idx_retrieval_exposures_memory").on(table.memory_id)]);
18256
+ }, (table) => [
18257
+ uniqueIndex("idx_retrieval_exposures_attempt_rank").on(table.attempt_id, table.rank),
18258
+ index("idx_retrieval_exposures_memory").on(table.memory_id),
18259
+ index("idx_retrieval_exposures_not_selected").on(table.attempt_id).where(sql`${table.disposition} <> 'selected'`)
18260
+ ]);
18184
18261
  var outcomeEvidence = sqliteTable("outcome_evidence", {
18185
18262
  evidence_id: text("evidence_id").primaryKey(),
18186
18263
  contract_version: integer("contract_version").notNull(),
@@ -18461,6 +18538,7 @@ sqliteTable("sync_attempts", {
18461
18538
  transport: text("transport")
18462
18539
  }, (table) => [
18463
18540
  index("idx_sync_attempts_peer_started").on(table.peer_device_id, table.started_at),
18541
+ index("idx_sync_attempts_peer_kind_started").on(table.peer_device_id, table.ok, table.failure_category, table.started_at),
18464
18542
  index("idx_sync_attempts_occurred").on(sql`CASE WHEN ${table.finished_at} IS NULL THEN ${table.started_at} ELSE ${table.finished_at} END`, table.id),
18465
18543
  index("idx_sync_attempts_error_occurred").on(sql`CASE WHEN ${table.finished_at} IS NULL THEN ${table.started_at} ELSE ${table.finished_at} END`, table.id).where(sql`${table.ok} = 0`),
18466
18544
  index("idx_sync_attempts_success_occurred").on(sql`CASE WHEN ${table.finished_at} IS NULL THEN ${table.started_at} ELSE ${table.finished_at} END`, table.id).where(sql`${table.ok} <> 0`)
@@ -18632,6 +18710,21 @@ sqliteTable("policy_team_device_decisions", {
18632
18710
  created_at: text("created_at").notNull(),
18633
18711
  updated_at: text("updated_at").notNull()
18634
18712
  }, (table) => [primaryKey({ columns: [table.team_id, table.device_id] }), index("idx_policy_team_device_decisions_device").on(table.device_id)]);
18713
+ sqliteTable("policy_team_member_removals", {
18714
+ team_id: text("team_id").notNull(),
18715
+ identity_id: text("identity_id").notNull(),
18716
+ coordinator_id: text("coordinator_id").notNull(),
18717
+ group_id: text("group_id").notNull(),
18718
+ removal_seq: integer("removal_seq").notNull(),
18719
+ removed_at: text("removed_at").notNull(),
18720
+ removed_by_device_id: text("removed_by_device_id"),
18721
+ recorded_at: text("recorded_at").notNull()
18722
+ }, (table) => [primaryKey({ columns: [
18723
+ table.coordinator_id,
18724
+ table.group_id,
18725
+ table.team_id,
18726
+ table.identity_id
18727
+ ] })]);
18635
18728
  sqliteTable("identity_devices", {
18636
18729
  device_id: text("device_id").primaryKey(),
18637
18730
  identity_id: text("identity_id").notNull(),