@rig-c/review 2.6.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.
@@ -11,10 +11,21 @@
11
11
  * Only explicit close ends an active job. Direction carriage is metadata-only.
12
12
  */
13
13
 
14
+ import type { JobPublicationReader } from './job-source.ts';
15
+
14
16
  export const JOB_API_SCHEMA = 'rig-review/job-api@2' as const;
17
+ export const JOB_API_V3_SCHEMA = 'rig-review/job-api@3' as const;
15
18
  export const JOB_ACT_SCHEMA = 'rig-review/act@2' as const;
16
19
  /** New rig verdicts only. Store/reuse markers and all other acts retain @2. */
17
20
  export const JOB_RIG_REVIEW_ACT_SCHEMA = 'rig-review/act@3' as const;
21
+ /** Record-source acts only under opt-in API@3. Package/image acts retain @2/@3. */
22
+ export const JOB_RECORD_ACT_SCHEMA = 'rig-review/act@4' as const;
23
+ export const JOB_RECORD_READER_ID = 'rig-create/publication-reader/2' as const;
24
+ export const JOB_RECORD_SOURCE_SCHEMA = 'rig-review-job-record-source/1' as const;
25
+ export const JOB_RECORD_INSTANCE_SCHEMA = 'rig-review-job-record-instance/1' as const;
26
+ export const JOB_PUBLICATION_MODES = ['package-only', 'record-and-package'] as const;
27
+ export type JobPublicationMode = typeof JOB_PUBLICATION_MODES[number];
28
+ export type JobApiSchema = typeof JOB_API_SCHEMA | typeof JOB_API_V3_SCHEMA;
18
29
  export const jobStillByteLimit = 8 * 1024 * 1024;
19
30
  export const jobCaptureBodyLimit = 12 * 1024 * 1024;
20
31
  export const jobRawActMediaType = 'application/vnd.rig-review.act+json';
@@ -639,3 +650,291 @@ export interface JobConsumerGrant {
639
650
  readonly actKinds: readonly JobEnabledActKind[];
640
651
  readonly lifetime: 'until-explicit-close';
641
652
  }
653
+
654
+ export interface RecordOptionResult {
655
+ readonly kind: 'option-set';
656
+ readonly questionId: string;
657
+ readonly setId: string;
658
+ }
659
+
660
+ export interface RecordPlanResult {
661
+ readonly kind: 'plan';
662
+ }
663
+
664
+ export type RecordResult = RecordOptionResult | RecordPlanResult;
665
+
666
+ export interface PackageResultV3 {
667
+ readonly kind: 'package';
668
+ readonly path: string;
669
+ readonly selector: JobSelector | null;
670
+ }
671
+
672
+ export type PublishResultV3 = PackageResultV3 | RecordResult;
673
+
674
+ export type ProjectRecord = JobFileIdentity & { readonly path: 'project.json' };
675
+
676
+ export type RecordFreeze = Omit<JobPublishRequest['freeze'], 'record'> & {
677
+ readonly record: ProjectRecord;
678
+ };
679
+
680
+ export type PublishRequestV3 = Omit<JobPublishRequest, 'schema' | 'result' | 'freeze'> & {
681
+ readonly schema: typeof JOB_API_V3_SCHEMA;
682
+ } & (
683
+ | {
684
+ readonly result: Extract<PublishResultV3, { readonly kind: 'package' }>;
685
+ readonly freeze: JobPublishRequest['freeze'];
686
+ }
687
+ | {
688
+ readonly result: RecordResult;
689
+ readonly freeze: RecordFreeze;
690
+ }
691
+ );
692
+
693
+ export type AskRequestV3 = Omit<JobAskRequest, 'schema'> & {
694
+ readonly schema: typeof JOB_API_V3_SCHEMA;
695
+ };
696
+
697
+ export type NextRequestV3 = Omit<JobNextRequest, 'schema'> & {
698
+ readonly schema: typeof JOB_API_V3_SCHEMA;
699
+ };
700
+
701
+ export type CloseRequestV3 = Omit<JobCloseRequest, 'schema'> & {
702
+ readonly schema: typeof JOB_API_V3_SCHEMA;
703
+ };
704
+
705
+ export type AgentRequestV3 =
706
+ | PublishRequestV3
707
+ | AskRequestV3
708
+ | NextRequestV3
709
+ | CloseRequestV3;
710
+
711
+ export type FetchActRequestV3 = Omit<JobFetchActRequest, 'schema'> & {
712
+ readonly schema: typeof JOB_API_V3_SCHEMA;
713
+ };
714
+
715
+ export interface RecordPicksSubject {
716
+ readonly kind: 'interview-picks';
717
+ readonly questionId: string;
718
+ readonly setId: string;
719
+ }
720
+
721
+ export interface RecordCheckpointSubject {
722
+ readonly kind: 'checkpoint';
723
+ readonly checkpointId: string;
724
+ }
725
+
726
+ export type RecordSignoffStage = typeof JOB_PLAN_BOUND_SIGNOFF_STAGES[number];
727
+
728
+ export interface RecordSignoffSubject {
729
+ readonly kind: 'signoff';
730
+ readonly stage: RecordSignoffStage;
731
+ }
732
+
733
+ export type RecordPlanSubject = RecordCheckpointSubject | RecordSignoffSubject;
734
+ export type RecordSubject = RecordPicksSubject | RecordPlanSubject;
735
+
736
+ export interface RecordPartsIdentity {
737
+ readonly name: string;
738
+ readonly version: string;
739
+ readonly integrity: string;
740
+ }
741
+
742
+ export interface RecordContextBase {
743
+ readonly label: string;
744
+ readonly parts: RecordPartsIdentity;
745
+ readonly inputs: readonly JobFileIdentity[];
746
+ readonly files: readonly JobFileIdentity[];
747
+ }
748
+
749
+ export type OptionContext = RecordContextBase & {
750
+ readonly plan: null;
751
+ readonly subjects: readonly [RecordPicksSubject];
752
+ };
753
+
754
+ export type PlanContext = RecordContextBase & {
755
+ readonly plan: JobPlanIdentity;
756
+ readonly subjects: readonly RecordPlanSubject[];
757
+ };
758
+
759
+ export type RecordPublishedContext = OptionContext | PlanContext;
760
+
761
+ export interface RecordReaderInput<Result extends RecordResult = RecordResult> {
762
+ readonly root: string;
763
+ readonly record: ProjectRecord;
764
+ readonly result: Result;
765
+ readonly phase: 'inventory' | 'retained';
766
+ readonly parts?: RecordPartsIdentity;
767
+ }
768
+
769
+ export type ReaderValue<Value> = Value | Promise<Value>;
770
+
771
+ export interface RecordPublicationReader {
772
+ (input: RecordReaderInput<RecordOptionResult>): ReaderValue<OptionContext>;
773
+ (input: RecordReaderInput<RecordPlanResult>): ReaderValue<PlanContext>;
774
+ }
775
+
776
+ export interface RecordHostHooks {
777
+ readonly publicationMode: 'record-and-package';
778
+ readonly readerId: typeof JOB_RECORD_READER_ID;
779
+ readonly readPublished: JobPublicationReader;
780
+ readonly readRecordPublished: RecordPublicationReader;
781
+ }
782
+
783
+ export interface RecordSourceBase {
784
+ readonly sourceHash: JobSha256;
785
+ readonly projectHash: JobSha256;
786
+ readonly record: ProjectRecord;
787
+ readonly inputs: readonly JobFileIdentity[];
788
+ readonly files: readonly JobFileIdentity[];
789
+ }
790
+
791
+ export type OptionSource = RecordSourceBase & {
792
+ readonly subject: 'option-set';
793
+ readonly selection: RecordOptionResult;
794
+ readonly optionSet: { readonly id: string; readonly sha256: JobSha256 };
795
+ readonly optionSetFile: JobFileIdentity;
796
+ readonly plan: null;
797
+ readonly subjects: readonly [RecordPicksSubject];
798
+ };
799
+
800
+ export type PlanSource = RecordSourceBase & {
801
+ readonly subject: 'plan';
802
+ readonly selection: RecordPlanResult;
803
+ readonly optionSet: null;
804
+ readonly optionSetFile: null;
805
+ readonly plan: JobPlanIdentity;
806
+ readonly subjects: readonly RecordPlanSubject[];
807
+ };
808
+
809
+ export type RecordSource = OptionSource | PlanSource;
810
+
811
+ export type RecordSignoffValue = Omit<JobActValues['signoff'], 'stage'> & {
812
+ readonly stage: RecordSignoffStage;
813
+ };
814
+
815
+ export type RecordAct = Pick<JobLegacyAct,
816
+ 'actId' | 'jobId' | 'askId' | 'publicationId' | 'authority' | 'at'> & {
817
+ readonly schema: typeof JOB_RECORD_ACT_SCHEMA;
818
+ } & (
819
+ | {
820
+ readonly kind: 'interview-picks';
821
+ readonly source: OptionSource;
822
+ readonly value: JobActValues['interview-picks'];
823
+ }
824
+ | {
825
+ readonly kind: 'checkpoint';
826
+ readonly source: PlanSource;
827
+ readonly value: JobActValues['checkpoint'];
828
+ }
829
+ | {
830
+ readonly kind: 'signoff';
831
+ readonly source: PlanSource;
832
+ readonly value: RecordSignoffValue;
833
+ }
834
+ );
835
+
836
+ export type SourceV3 = JobSourceBinding | RecordSource;
837
+ export type ActV3 = JobAct | RecordAct;
838
+
839
+ export interface JobCapabilitiesV3 extends JobCapabilities {
840
+ readonly recordPublication: true;
841
+ readonly recordActSchema: typeof JOB_RECORD_ACT_SCHEMA;
842
+ }
843
+
844
+ export const JOB_CAPABILITIES_V3: JobCapabilitiesV3 = Object.freeze({
845
+ imageSetVerdict: true,
846
+ recordPublication: true,
847
+ recordActSchema: JOB_RECORD_ACT_SCHEMA,
848
+ });
849
+
850
+ export interface PendingAskV3 extends Omit<JobPendingAsk, 'source'> {
851
+ readonly source: SourceV3;
852
+ }
853
+
854
+ export interface PublicationV3 extends Omit<JobPublication, 'source'> {
855
+ readonly source: SourceV3;
856
+ }
857
+
858
+ export interface StatusV3 extends Omit<JobStatus, 'publication' | 'pending'> {
859
+ readonly publication: PublicationV3 | null;
860
+ readonly pending: readonly PendingAskV3[];
861
+ }
862
+
863
+ export type EventV3 = {
864
+ readonly cursor: JobCursor;
865
+ readonly jobId: JobId;
866
+ readonly generation: number;
867
+ } & (
868
+ | { readonly type: 'published'; readonly publication: PublicationV3 }
869
+ | { readonly type: 'pending'; readonly ask: PendingAskV3 }
870
+ | { readonly type: 'act'; readonly act: ActV3 }
871
+ | { readonly type: 'closed'; readonly reason: string }
872
+ );
873
+
874
+ export interface NextValueV3 {
875
+ readonly capabilities?: JobCapabilitiesV3;
876
+ readonly events: readonly EventV3[];
877
+ readonly cursor: JobCursor | null;
878
+ readonly status: 'events' | 'timeout' | 'closed';
879
+ }
880
+
881
+ export interface ResponseValuesV3 {
882
+ readonly publish: PublicationV3;
883
+ readonly ask: PendingAskV3;
884
+ readonly next: NextValueV3;
885
+ readonly close: { readonly status: 'closed'; readonly cursor: JobCursor | null };
886
+ readonly 'fetch-act': ActV3;
887
+ }
888
+
889
+ export type ApiResponseV3 = {
890
+ [Verb in keyof ResponseValuesV3]: {
891
+ readonly schema: typeof JOB_API_V3_SCHEMA;
892
+ readonly verb: Verb;
893
+ readonly jobId: JobId;
894
+ readonly requestId: string;
895
+ readonly generation: number;
896
+ } & JobResult<ResponseValuesV3[Verb]>;
897
+ }[keyof ResponseValuesV3];
898
+
899
+ export type JobRecordOptionResult = RecordOptionResult;
900
+ export type JobRecordPlanResult = RecordPlanResult;
901
+ export type JobRecordResult = RecordResult;
902
+ export type JobPublishResultV3 = PublishResultV3;
903
+ export type JobProjectRecord = ProjectRecord;
904
+ export type JobRecordFreeze = RecordFreeze;
905
+ export type JobPublishRequestV3 = PublishRequestV3;
906
+ export type JobAskRequestV3 = AskRequestV3;
907
+ export type JobNextRequestV3 = NextRequestV3;
908
+ export type JobCloseRequestV3 = CloseRequestV3;
909
+ export type JobAgentRequestV3 = AgentRequestV3;
910
+ export type JobFetchActRequestV3 = FetchActRequestV3;
911
+ export type JobRecordPicksSubject = RecordPicksSubject;
912
+ export type JobRecordCheckpointSubject = RecordCheckpointSubject;
913
+ export type JobRecordSignoffStage = RecordSignoffStage;
914
+ export type JobRecordSignoffSubject = RecordSignoffSubject;
915
+ export type JobRecordPlanSubject = RecordPlanSubject;
916
+ export type JobRecordSubject = RecordSubject;
917
+ export type JobRecordPartsIdentity = RecordPartsIdentity;
918
+ export type JobRecordContextBase = RecordContextBase;
919
+ export type JobOptionContext = OptionContext;
920
+ export type JobPlanContext = PlanContext;
921
+ export type JobRecordPublishedContext = RecordPublishedContext;
922
+ export type JobRecordReaderInput<Result extends RecordResult = RecordResult> = RecordReaderInput<Result>;
923
+ export type JobRecordPublicationReader = RecordPublicationReader;
924
+ export type JobRecordHostHooks = RecordHostHooks;
925
+ export type JobRecordSourceBase = RecordSourceBase;
926
+ export type JobOptionSource = OptionSource;
927
+ export type JobPlanSource = PlanSource;
928
+ export type JobRecordSource = RecordSource;
929
+ export type JobRecordSignoffValue = RecordSignoffValue;
930
+ export type JobRecordAct = RecordAct;
931
+ export type JobSourceV3 = SourceV3;
932
+ export type JobActV3 = ActV3;
933
+ export type JobPendingAskV3 = PendingAskV3;
934
+ export type JobPublicationV3 = PublicationV3;
935
+ export type JobStatusV3 = StatusV3;
936
+ export type JobEventV3 = EventV3;
937
+ export type JobNextValueV3 = NextValueV3;
938
+ export type JobResponseValuesV3 = ResponseValuesV3;
939
+ export type JobApiResponseV3 = ApiResponseV3;
940
+