@gitgov/core 2.5.0 → 2.7.0

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,7 +1,8 @@
1
1
  import { Octokit } from '@octokit/rest';
2
2
  export { Octokit, RestEndpointMethodTypes } from '@octokit/rest';
3
- import { g as FileLister, h as FileListOptions, i as FileStats, I as IGitModule, c as ChangedFile, d as GetCommitHistoryOptions, e as CommitInfo, f as CommitAuthor, E as ExecOptions, b as ExecResult, C as ConfigStore, G as GitGovConfig } from './index-Bhc341pf.js';
4
- import { I as IdEncoder, R as RecordStore } from './record_store-BXKWqon5.js';
3
+ import { h as FileLister, i as FileListOptions, j as FileStats, I as IGitModule, d as ChangedFile, e as GetCommitHistoryOptions, f as CommitInfo, g as CommitAuthor, E as ExecOptions, c as ExecResult, C as ConfigStore, G as GitGovConfig } from './index-LULVRsCZ.js';
4
+ import { I as IdEncoder, R as RecordStore, a as IRecordProjector } from './record_projection.types-Dz9YU3r9.js';
5
+ import { C as ConfigManager, q as IIdentityAdapter, I as ILintModule, e as ISyncStateModule, j as SyncStatePushOptions, k as SyncStatePushResult, l as SyncStatePullOptions, m as SyncStatePullResult, f as StateDeltaFile, g as ConflictDiff, n as SyncStateResolveOptions, o as SyncStateResolveResult, h as IntegrityViolation, A as AuditStateOptions, i as AuditStateReport } from './sync_state-Bn_LogJ2.js';
5
6
 
6
7
  /**
7
8
  * Types for GitHubFileLister module.
@@ -422,6 +423,119 @@ declare class GitHubConfigStore implements ConfigStore<GitHubSaveResult> {
422
423
  saveConfig(config: GitGovConfig): Promise<GitHubSaveResult>;
423
424
  }
424
425
 
426
+ /**
427
+ * Types for GithubSyncStateModule.
428
+ *
429
+ * Blueprint: github_sync_state_module.md §3.1
430
+ * @module sync_state/github_sync_state
431
+ */
432
+
433
+ /**
434
+ * Dependencies for GithubSyncStateModule.
435
+ *
436
+ * Uses Octokit directly (not IGitModule) because:
437
+ * - GitHubGitModule has a stateful staging buffer that complicates the flow
438
+ * - Tree API recursive operations (getTree, compare) are not exposed in IGitModule
439
+ * - Direct Octokit control is simpler for atomic tree+commit+ref operations
440
+ */
441
+ type GithubSyncStateDependencies = {
442
+ /** Octokit instance (authenticated) */
443
+ octokit: Octokit;
444
+ /** GitHub repo owner */
445
+ owner: string;
446
+ /** GitHub repo name */
447
+ repo: string;
448
+ /** Configuration manager (DI consistency — not actively used in initial implementation) */
449
+ config: ConfigManager;
450
+ /** Identity adapter (DI consistency — not actively used; lint handles validation internally) */
451
+ identity: IIdentityAdapter;
452
+ /** Lint module for record validation */
453
+ lint: ILintModule;
454
+ /** Record projector for re-indexing after pull */
455
+ indexer: IRecordProjector;
456
+ };
457
+
458
+ /**
459
+ * GithubSyncStateModule — ISyncStateModule via GitHub API (Octokit)
460
+ *
461
+ * Implements state synchronization between .gitgov/ records and a shared
462
+ * gitgov-state branch using the GitHub Trees/Commits/Refs API.
463
+ * No local filesystem or git CLI required.
464
+ *
465
+ * Blueprint: github_sync_state_module.md
466
+ * @module sync_state/github_sync_state
467
+ */
468
+
469
+ /**
470
+ * [EARS-GS-A1..F2] GithubSyncStateModule
471
+ *
472
+ * Synchronizes .gitgov/ state with a GitHub remote via API.
473
+ * Uses optimistic concurrency (SHA-based) instead of rebase.
474
+ */
475
+ declare class GithubSyncStateModule implements ISyncStateModule {
476
+ private readonly deps;
477
+ private lastKnownSha;
478
+ constructor(deps: GithubSyncStateDependencies);
479
+ /**
480
+ * [EARS-GS-A3] Returns the configured state branch name.
481
+ */
482
+ getStateBranchName(): Promise<string>;
483
+ /**
484
+ * [EARS-GS-A1] Creates gitgov-state branch if it does not exist.
485
+ * [EARS-GS-A2] Idempotent — no-op if branch already exists.
486
+ */
487
+ ensureStateBranch(): Promise<void>;
488
+ /**
489
+ * [EARS-GS-B1..B5] Push local .gitgov/ state to gitgov-state branch via API.
490
+ *
491
+ * Uses the 6-step atomic commit pattern:
492
+ * getRef → getCommit → createBlob → createTree → createCommit → updateRef
493
+ *
494
+ * Optimistic concurrency: if remote ref advanced since our read, updateRef
495
+ * fails with 422 → return conflictDetected: true.
496
+ */
497
+ pushState(options: SyncStatePushOptions): Promise<SyncStatePushResult>;
498
+ /**
499
+ * [EARS-GS-C1..C4] Pull remote state from gitgov-state branch.
500
+ *
501
+ * Fetches tree + blobs, updates lastKnownSha, triggers re-indexing.
502
+ */
503
+ pullState(options?: SyncStatePullOptions): Promise<SyncStatePullResult>;
504
+ /**
505
+ * [EARS-GS-D1..D3] Calculate file delta between known state and current remote.
506
+ */
507
+ calculateStateDelta(_sourceBranch: string): Promise<StateDeltaFile[]>;
508
+ /**
509
+ * Always empty — no local pending changes in API mode.
510
+ * In API mode there is no local filesystem; all state is remote.
511
+ */
512
+ getPendingChanges(): Promise<StateDeltaFile[]>;
513
+ /**
514
+ * Always false — no rebase in API mode.
515
+ */
516
+ isRebaseInProgress(): Promise<boolean>;
517
+ /**
518
+ * Always empty — no conflict markers in API mode.
519
+ */
520
+ checkConflictMarkers(_filePaths: string[]): Promise<string[]>;
521
+ /**
522
+ * Empty diff — no git-level conflict markers in API mode.
523
+ */
524
+ getConflictDiff(_filePaths?: string[]): Promise<ConflictDiff>;
525
+ /**
526
+ * [EARS-GS-E1..E2] Resolve conflict by pulling latest and retrying push.
527
+ */
528
+ resolveConflict(options: SyncStateResolveOptions): Promise<SyncStateResolveResult>;
529
+ /**
530
+ * No integrity violations in API mode (no rebase commits).
531
+ */
532
+ verifyResolutionIntegrity(): Promise<IntegrityViolation[]>;
533
+ /**
534
+ * [EARS-GS-F1..F2] Audit the remote gitgov-state branch.
535
+ */
536
+ auditState(options?: AuditStateOptions): Promise<AuditStateReport>;
537
+ }
538
+
425
539
  /**
426
540
  * GitHub API implementations for @gitgov/core/github
427
541
  *
@@ -470,4 +584,4 @@ declare function isOctokitRequestError(error: unknown): error is {
470
584
  */
471
585
  declare function mapOctokitError(error: unknown, context: string): GitHubApiError;
472
586
 
473
- export { GitHubApiError, type GitHubApiErrorCode, GitHubConfigStore, type GitHubConfigStoreOptions, GitHubFileLister, type GitHubFileListerOptions, GitHubGitModule, type GitHubGitModuleOptions, GitHubRecordStore, type GitHubRecordStoreOptions, type GitHubSaveResult, type GitHubWriteOpts, type GitHubWriteResult, isOctokitRequestError, mapOctokitError };
587
+ export { GitHubApiError, type GitHubApiErrorCode, GitHubConfigStore, type GitHubConfigStoreOptions, GitHubFileLister, type GitHubFileListerOptions, GitHubGitModule, type GitHubGitModuleOptions, GitHubRecordStore, type GitHubRecordStoreOptions, type GitHubSaveResult, type GitHubWriteOpts, type GitHubWriteResult, type GithubSyncStateDependencies, GithubSyncStateModule, isOctokitRequestError, mapOctokitError };