@c4a/context 0.7.4 → 0.7.5

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.
package/index.js CHANGED
@@ -16661,6 +16661,53 @@ function indexerDependencyTargetMatches(input) {
16661
16661
  return input.target.level === "logical-unit" || input.target.artifact_kind === input.artifact_kind && (input.target.level === "artifact-kind" || input.target.section_key === input.section_key);
16662
16662
  }
16663
16663
 
16664
+ // src/indexerCompositionFactDependencies.ts
16665
+ function compositionFactDependencies(input) {
16666
+ const composition = validateIndexerLayerCompositionInput(input.composition_input);
16667
+ if (composition.workset_digest !== input.workset.workset_digest || composition.final_authority_layer_ref !== input.result.provider_layer_ref) {
16668
+ throw new TypeError("extension composition belongs to another author run");
16669
+ }
16670
+ const selected = new Map(input.dependency_view.positive_nodes.flatMap((node) => node.kind === "selected-fact" ? [[node.fact_ref, node]] : []));
16671
+ const spans = new Map(input.dependency_view.positive_nodes.flatMap((node) => node.kind === "source-span" ? [[node.node_ref, node]] : []));
16672
+ return composition.accepted_fragments.flatMap((fragment) => {
16673
+ if (fragment.payload.protocol !== "context.indexer.fragment.fact-enrichment/v1")
16674
+ return [];
16675
+ return fragment.payload.facts.map((fact) => {
16676
+ if (fact.target_ref !== input.workset.logical_unit_ref) {
16677
+ throw new TypeError("extension fact belongs to another logical unit");
16678
+ }
16679
+ const sourceSpanRefs = [...new Set(fact.evidence_refs.flatMap((ref) => {
16680
+ const source = selected.get(ref.ref);
16681
+ if (source === undefined) {
16682
+ throw new TypeError(`extension fact references unavailable source fact ${ref.ref}`);
16683
+ }
16684
+ return source.source_span_node_refs;
16685
+ }))].sort(compareIndexerCanonicalText);
16686
+ const evidenceRefs = [...new Set(sourceSpanRefs.map((ref) => {
16687
+ const span = spans.get(ref);
16688
+ if (span === undefined)
16689
+ throw new TypeError("extension fact has no authorized source span");
16690
+ return span.evidence_ref;
16691
+ }))].sort(compareIndexerCanonicalText);
16692
+ const factRef = `layer-fact:${fragment.fragment_digest}/${fact.fact_id}`;
16693
+ const node = {
16694
+ kind: "selected-fact",
16695
+ fact_ref: factRef,
16696
+ fact_digest: indexerProtocolDigest({
16697
+ fact_ref: factRef,
16698
+ fact_kind: fact.fact_id,
16699
+ subject_key: input.result.logical_unit.subject_key,
16700
+ value: fact.value,
16701
+ evidence_refs: evidenceRefs
16702
+ }),
16703
+ source_span_node_refs: sourceSpanRefs,
16704
+ targets: []
16705
+ };
16706
+ return { ...node, node_ref: indexerDependencyNodeRef({ polarity: "positive", node }) };
16707
+ });
16708
+ });
16709
+ }
16710
+
16664
16711
  // src/indexerRunProtocolCommon.ts
16665
16712
  var indexerRunFinalAuthoritySchema = exports_external.object({
16666
16713
  layer_ref: indexerProviderLayerRefSchema,
@@ -17221,7 +17268,15 @@ function buildIndexerArtifactDependencySet(input) {
17221
17268
  }
17222
17269
  return [evidence.evidence_ref, versionedPositive(node)];
17223
17270
  }));
17224
- const factNodes = dependencyView.positive_nodes.filter((node) => node.kind === "selected-fact");
17271
+ const factNodes = [
17272
+ ...dependencyView.positive_nodes.filter((node) => node.kind === "selected-fact"),
17273
+ ...input.composition_input === undefined ? [] : compositionFactDependencies({
17274
+ composition_input: input.composition_input,
17275
+ workset: input.workset,
17276
+ dependency_view: dependencyView,
17277
+ result: input.result
17278
+ })
17279
+ ];
17225
17280
  const factNodeByRef = new Map(factNodes.map((node) => [node.fact_ref, node]));
17226
17281
  const factByRef = new Map(input.result.facts.map((fact) => {
17227
17282
  const node = factNodeByRef.get(fact.fact_ref);
@@ -17327,6 +17382,7 @@ function validateIndexerArtifactDependencySet(input) {
17327
17382
  workset: input.workset,
17328
17383
  run_envelope: input.run_envelope,
17329
17384
  dependency_view: input.dependency_view,
17385
+ ...input.composition_input === undefined ? {} : { composition_input: input.composition_input },
17330
17386
  ...input.authorized_evidence_targets === undefined ? {} : { authorized_evidence_targets: input.authorized_evidence_targets }
17331
17387
  });
17332
17388
  if (canonicalIndexerJson(expected) !== canonicalIndexerJson(value)) {
@@ -18694,6 +18750,7 @@ function validateIndexerMainRunResult(input) {
18694
18750
  workset: request.workset,
18695
18751
  run_envelope: runEnvelope,
18696
18752
  dependency_view: input.validation.dependency_view,
18753
+ composition_input: request.composition_input,
18697
18754
  ...input.validation.authorized_evidence_targets === undefined ? {} : {
18698
18755
  authorized_evidence_targets: input.validation.authorized_evidence_targets
18699
18756
  }
@@ -27471,33 +27528,124 @@ function observeIndexerMainWorksetState(input) {
27471
27528
  });
27472
27529
  }
27473
27530
  // src/indexerAgentStepProtocol.ts
27474
- var indexerAgentStepInputSchema = exports_external.object({
27475
- protocol: exports_external.literal("context.indexer.agent-step-input/v1"),
27476
- run_request: indexerProgramRunRequestSchema,
27531
+ var indexerAgentStepTaskSchema = exports_external.object({
27532
+ task_key: exports_external.string().regex(/^task-[0-9]{3}$/u),
27533
+ workset_digest: indexerDigestSchema,
27534
+ execution_request_digest: indexerDigestSchema,
27535
+ consumed_input_view_digest: indexerDigestSchema,
27536
+ workset_view_resource_id: exports_external.string().regex(/^authorized-indexer-workset-view\/task-[0-9]{3}$/u),
27537
+ workset_view_request_digest: indexerDigestSchema
27538
+ }).strict();
27539
+ var indexerMainAgentStepInputSchema = exports_external.object({
27540
+ protocol: exports_external.literal("context.indexer.agent-step-input/v2"),
27541
+ stage: exports_external.enum(["partition", "author"]),
27542
+ transport: indexerMainTransportBatchSchema,
27543
+ instruction_request_digest: indexerDigestSchema,
27544
+ tasks: exports_external.array(indexerAgentStepTaskSchema).min(1),
27545
+ input_digest: indexerDigestSchema
27546
+ }).strict();
27547
+ var indexerPostAuthorAgentStepTaskSchema = exports_external.object({
27548
+ task_key: exports_external.string().regex(/^task-[0-9]{3}$/u),
27549
+ workset_digest: indexerDigestSchema,
27550
+ request_digest: indexerDigestSchema,
27551
+ primary_result_view_digest: indexerDigestSchema,
27552
+ workset_view_resource_id: exports_external.string().regex(/^authorized-indexer-workset-view\/task-[0-9]{3}$/u)
27553
+ }).strict();
27554
+ var indexerPostAuthorAgentStepInputSchema = exports_external.object({
27555
+ protocol: exports_external.literal("context.indexer.agent-step-input/v2"),
27556
+ stage: exports_external.literal("post-author"),
27477
27557
  instruction_request_digest: indexerDigestSchema,
27558
+ tasks: exports_external.array(indexerPostAuthorAgentStepTaskSchema).min(1),
27478
27559
  input_digest: indexerDigestSchema
27479
27560
  }).strict();
27561
+ var indexerAgentStepInputSchema = exports_external.discriminatedUnion("stage", [
27562
+ indexerMainAgentStepInputSchema,
27563
+ indexerPostAuthorAgentStepInputSchema
27564
+ ]);
27480
27565
  function indexerAgentStepInputDigest(value) {
27481
- return indexerProtocolDigest(value);
27566
+ const { input_digest: _digest, ...payload2 } = value;
27567
+ return indexerProtocolDigest(payload2);
27482
27568
  }
27483
27569
  function buildIndexerAgentStepInput(input) {
27484
- const runRequest = validateIndexerProgramRunRequest(input.run_request);
27570
+ if (input.run_requests.length === 0) {
27571
+ throw new TypeError("Indexer Agent step requires at least one run request");
27572
+ }
27573
+ const runRequests = input.run_requests.map(validateIndexerProgramRunRequest);
27574
+ if (input.workset_view_requests.length !== runRequests.length) {
27575
+ throw new TypeError("Indexer Agent step must have one View per run request");
27576
+ }
27577
+ const stage = runRequests[0].workset.stage;
27578
+ if (runRequests.some((request) => request.workset.stage !== stage)) {
27579
+ throw new TypeError("Indexer Agent step batch must contain one stage");
27580
+ }
27581
+ const transport = buildIndexerMainTransportBatch(runRequests.map((request) => request.workset));
27582
+ const tasks = runRequests.map((request, index) => {
27583
+ const taskKey = `task-${String(index + 1).padStart(3, "0")}`;
27584
+ const view = input.workset_view_requests[index];
27585
+ if (view.workset_digest !== request.workset.workset_digest || view.resource_id !== `authorized-indexer-workset-view/${taskKey}`) {
27586
+ throw new TypeError("Indexer Agent step View mapping does not match its workset");
27587
+ }
27588
+ return {
27589
+ task_key: taskKey,
27590
+ workset_digest: request.workset.workset_digest,
27591
+ execution_request_digest: request.execution_request_digest,
27592
+ consumed_input_view_digest: request.composition_input.view_digest,
27593
+ workset_view_resource_id: view.resource_id,
27594
+ workset_view_request_digest: view.request_digest
27595
+ };
27596
+ });
27485
27597
  const payload2 = {
27486
- protocol: "context.indexer.agent-step-input/v1",
27487
- run_request: runRequest,
27488
- instruction_request_digest: indexerDigestSchema.parse(input.instruction_request_digest)
27598
+ protocol: "context.indexer.agent-step-input/v2",
27599
+ stage,
27600
+ transport,
27601
+ instruction_request_digest: indexerDigestSchema.parse(input.instruction_request_digest),
27602
+ tasks
27489
27603
  };
27490
- return indexerAgentStepInputSchema.parse({
27604
+ return indexerMainAgentStepInputSchema.parse({
27605
+ ...payload2,
27606
+ input_digest: indexerAgentStepInputDigest(payload2)
27607
+ });
27608
+ }
27609
+ function buildIndexerPostAuthorAgentStepInput(input) {
27610
+ if (input.fragment_requests.length === 0) {
27611
+ throw new TypeError("post-author Agent step requires at least one fragment request");
27612
+ }
27613
+ const requests = input.fragment_requests.map(validateIndexerPostAuthorFragmentRequest);
27614
+ const tasks = requests.map((request, index) => {
27615
+ const taskKey = `task-${String(index + 1).padStart(3, "0")}`;
27616
+ return {
27617
+ task_key: taskKey,
27618
+ workset_digest: request.workset.workset_digest,
27619
+ request_digest: request.request_digest,
27620
+ primary_result_view_digest: request.primary_result_view.view_digest,
27621
+ workset_view_resource_id: `authorized-indexer-workset-view/${taskKey}`
27622
+ };
27623
+ });
27624
+ const payload2 = {
27625
+ protocol: "context.indexer.agent-step-input/v2",
27626
+ stage: "post-author",
27627
+ instruction_request_digest: indexerDigestSchema.parse(input.instruction_request_digest),
27628
+ tasks
27629
+ };
27630
+ return indexerPostAuthorAgentStepInputSchema.parse({
27491
27631
  ...payload2,
27492
27632
  input_digest: indexerAgentStepInputDigest(payload2)
27493
27633
  });
27494
27634
  }
27495
27635
  function validateIndexerAgentStepInput(value) {
27496
27636
  const input = indexerAgentStepInputSchema.parse(value);
27497
- const rebuilt = buildIndexerAgentStepInput(input);
27498
- if (rebuilt.input_digest !== input.input_digest) {
27637
+ if (input.input_digest !== indexerAgentStepInputDigest(input)) {
27499
27638
  throw new TypeError("Indexer Agent step input digest is invalid");
27500
27639
  }
27640
+ if (input.stage === "post-author") {
27641
+ if (new Set(input.tasks.map((task) => task.task_key)).size !== input.tasks.length) {
27642
+ throw new TypeError("post-author Agent step task keys must be unique");
27643
+ }
27644
+ return input;
27645
+ }
27646
+ if (input.transport.worksets.length !== input.tasks.length || input.transport.worksets.some((workset, index) => workset.stage !== input.stage || workset.workset_digest !== input.tasks[index].workset_digest)) {
27647
+ throw new TypeError("Indexer Agent step transport does not match its task manifest");
27648
+ }
27501
27649
  return input;
27502
27650
  }
27503
27651
  // src/indexerSemanticInput.ts
@@ -27525,9 +27673,6 @@ var indexerProviderResolutionSemanticInputSchema = exports_external.object({
27525
27673
  value: exports_external.unknown()
27526
27674
  }).strict().optional()
27527
27675
  }).strict();
27528
- var indexerProviderFinalizationSemanticInputSchema = exports_external.object({
27529
- stage: exports_external.literal("provider-finalization")
27530
- }).strict();
27531
27676
  var indexerProviderProgramAuthorizationSemanticInputSchema = exports_external.object({
27532
27677
  stage: exports_external.literal("provider-program-authorization"),
27533
27678
  decision: exports_external.enum(["approved", "rejected"])
@@ -27565,8 +27710,6 @@ var partitionUnsupportedSchema = exports_external.object({
27565
27710
  var completePartitionInputSchema = exports_external.object({
27566
27711
  stage: exports_external.literal("partition"),
27567
27712
  outcome: exports_external.literal("complete"),
27568
- unit_type: exports_external.string().min(1),
27569
- partition_axis: exports_external.string().min(1),
27570
27713
  groups: exports_external.array(partitionGroupSchema2),
27571
27714
  excluded: exports_external.array(partitionDispositionSchema).default([]),
27572
27715
  unsupported: exports_external.array(partitionUnsupportedSchema).default([])
@@ -27574,8 +27717,6 @@ var completePartitionInputSchema = exports_external.object({
27574
27717
  var failedPartitionInputSchema = exports_external.object({
27575
27718
  stage: exports_external.literal("partition"),
27576
27719
  outcome: exports_external.literal("failed"),
27577
- unit_type: exports_external.string().min(1),
27578
- partition_axis: exports_external.string().min(1),
27579
27720
  groups: exports_external.array(partitionGroupSchema2).default([]),
27580
27721
  excluded: exports_external.array(partitionDispositionSchema).default([]),
27581
27722
  unsupported: exports_external.array(partitionUnsupportedSchema).default([]),
@@ -27663,6 +27804,45 @@ var indexerAuthorSemanticInputSchema = exports_external.object({
27663
27804
  });
27664
27805
  }
27665
27806
  });
27807
+ var indexerPartitionBatchSemanticInputSchema = exports_external.object({
27808
+ stage: exports_external.literal("partition"),
27809
+ results: exports_external.array(exports_external.object({
27810
+ task_key: exports_external.string().regex(/^task-[0-9]{3}$/u),
27811
+ result: indexerPartitionSemanticInputSchema
27812
+ }).strict()).min(1)
27813
+ }).strict().superRefine((value, context) => {
27814
+ const keys = value.results.map((result) => result.task_key);
27815
+ if (new Set(keys).size !== keys.length) {
27816
+ context.addIssue({
27817
+ code: exports_external.ZodIssueCode.custom,
27818
+ path: ["results"],
27819
+ message: "partition batch task keys must be unique"
27820
+ });
27821
+ }
27822
+ });
27823
+ var indexerAuthorBatchSemanticInputSchema = exports_external.object({
27824
+ stage: exports_external.literal("author"),
27825
+ results: exports_external.array(exports_external.object({
27826
+ task_key: exports_external.string().regex(/^task-[0-9]{3}$/u),
27827
+ result: indexerAuthorSemanticInputSchema
27828
+ }).strict()).min(1)
27829
+ }).strict().superRefine((value, context) => {
27830
+ const keys = value.results.map((result) => result.task_key);
27831
+ if (new Set(keys).size !== keys.length) {
27832
+ context.addIssue({
27833
+ code: exports_external.ZodIssueCode.custom,
27834
+ path: ["results"],
27835
+ message: "author batch task keys must be unique"
27836
+ });
27837
+ }
27838
+ });
27839
+ var indexerMainBatchSubmissionEnvelopeSchema = exports_external.object({
27840
+ stage: exports_external.enum(["partition", "author", "post-author"]),
27841
+ results: exports_external.array(exports_external.object({
27842
+ task_key: exports_external.string(),
27843
+ result: exports_external.unknown()
27844
+ }).strict()).min(1)
27845
+ }).strict();
27666
27846
  var postAuthorSectionSchema = exports_external.object({
27667
27847
  key: exports_external.string().min(1),
27668
27848
  heading: exports_external.string().min(1),
@@ -27689,6 +27869,22 @@ var indexerPostAuthorSemanticInputSchema = exports_external.object({
27689
27869
  });
27690
27870
  }
27691
27871
  });
27872
+ var indexerPostAuthorBatchSemanticInputSchema = exports_external.object({
27873
+ stage: exports_external.literal("post-author"),
27874
+ results: exports_external.array(exports_external.object({
27875
+ task_key: exports_external.string().regex(/^task-[0-9]{3}$/u),
27876
+ result: indexerPostAuthorSemanticInputSchema
27877
+ }).strict()).min(1)
27878
+ }).strict().superRefine((value, context) => {
27879
+ const keys = value.results.map((result) => result.task_key);
27880
+ if (new Set(keys).size !== keys.length) {
27881
+ context.addIssue({
27882
+ code: exports_external.ZodIssueCode.custom,
27883
+ path: ["results"],
27884
+ message: "post-author batch task keys must be unique"
27885
+ });
27886
+ }
27887
+ });
27692
27888
  var indexerStructureReviewInputSchema = exports_external.object({
27693
27889
  stage: exports_external.literal("structure-review"),
27694
27890
  decision: exports_external.enum(["approved", "request-adjustment"]),
@@ -27705,7 +27901,11 @@ var indexerStructureReviewInputSchema = exports_external.object({
27705
27901
  var indexerLayoutConfirmationInputSchema = exports_external.object({
27706
27902
  stage: exports_external.literal("layout-confirmation"),
27707
27903
  decision: exports_external.enum(["approved", "rejected"]),
27708
- feedback: exports_external.string().min(1).optional()
27904
+ feedback: exports_external.string().min(1).optional(),
27905
+ paths: exports_external.array(exports_external.object({
27906
+ artifact_ref: exports_external.string().min(1),
27907
+ output_path: exports_external.string().min(1)
27908
+ }).strict()).min(1).optional()
27709
27909
  }).strict().superRefine((value, context) => {
27710
27910
  if (value.decision === "rejected" && value.feedback === undefined) {
27711
27911
  context.addIssue({
@@ -27714,21 +27914,33 @@ var indexerLayoutConfirmationInputSchema = exports_external.object({
27714
27914
  message: "rejected layout confirmation requires feedback"
27715
27915
  });
27716
27916
  }
27917
+ if (value.decision === "rejected" && value.paths !== undefined) {
27918
+ context.addIssue({
27919
+ code: exports_external.ZodIssueCode.custom,
27920
+ path: ["paths"],
27921
+ message: "only an approved layout can select output paths"
27922
+ });
27923
+ }
27717
27924
  });
27718
27925
  var indexerCurrentActionInputSchema = exports_external.union([
27719
27926
  indexerProviderSelectionSemanticInputSchema,
27720
27927
  indexerProviderResolutionSemanticInputSchema,
27721
27928
  indexerProviderProgramAuthorizationSemanticInputSchema,
27722
- indexerProviderFinalizationSemanticInputSchema,
27723
- indexerPartitionSemanticInputSchema,
27724
- indexerAuthorSemanticInputSchema,
27725
- indexerPostAuthorSemanticInputSchema,
27929
+ indexerPartitionBatchSemanticInputSchema,
27930
+ indexerAuthorBatchSemanticInputSchema,
27931
+ indexerPostAuthorBatchSemanticInputSchema,
27726
27932
  indexerStructureReviewInputSchema,
27727
27933
  indexerLayoutConfirmationInputSchema
27728
27934
  ]);
27729
27935
  function validateIndexerCurrentActionInput(value) {
27730
27936
  return indexerCurrentActionInputSchema.parse(value);
27731
27937
  }
27938
+ function parseIndexerCurrentActionSubmission(value) {
27939
+ if (value !== null && typeof value === "object" && !Array.isArray(value) && (Reflect.get(value, "stage") === "partition" || Reflect.get(value, "stage") === "author" || Reflect.get(value, "stage") === "post-author")) {
27940
+ return indexerMainBatchSubmissionEnvelopeSchema.parse(value);
27941
+ }
27942
+ return validateIndexerCurrentActionInput(value);
27943
+ }
27732
27944
  // src/indexerExampleIdentity.ts
27733
27945
  var exampleObservationSchema = exports_external.object({
27734
27946
  observation_ref: indexerCanonicalRefSchema,
@@ -29542,6 +29754,10 @@ function viewRef(currentArtifactRef, collection) {
29542
29754
  })}`;
29543
29755
  }
29544
29756
  function readerPathSlug(value) {
29757
+ const identity2 = value.trim();
29758
+ if (/^(?:artifact|evidence|node|section|view):/iu.test(identity2) || /(?:^|[:/_-])sha256(?::|$)/iu.test(identity2) || /^[a-f\d]{32,}$/iu.test(identity2) || /^\d{8,14}$/u.test(identity2) || /^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/iu.test(identity2)) {
29759
+ throw new TypeError("layout resolver rejects machine identity in a reader-facing path");
29760
+ }
29545
29761
  const slug = value.normalize("NFC").replace(/([\p{Ll}\p{N}])(\p{Lu})/gu, "$1-$2").replace(/(\p{Lu})(\p{Lu}\p{Ll})/gu, "$1-$2").toLowerCase().replace(/[^\p{Letter}\p{Number}]+/gu, "-").replace(/^-+|-+$/gu, "");
29546
29762
  if (slug.length === 0) {
29547
29763
  throw new TypeError("layout resolver requires a reader-readable semantic path identity");
@@ -29549,8 +29765,10 @@ function readerPathSlug(value) {
29549
29765
  return slug;
29550
29766
  }
29551
29767
  function outputPath(input) {
29552
- const moduleIdentity = input.module_ref?.replace(/^module:/u, "") ?? input.subject_key.namespace;
29553
- return `knowledge/${input.collection}/${readerPathSlug(moduleIdentity)}/${readerPathSlug(input.artifact_id)}.md`;
29768
+ const namespace = readerPathSlug(input.subject_key.namespace);
29769
+ const subject = readerPathSlug(input.subject_key.local_key);
29770
+ const suffix = input.primary ? "" : input.duplicate_kind ? `-${readerPathSlug(input.artifact.artifact_kind)}-${readerPathSlug(input.artifact.artifact_id)}` : `-${readerPathSlug(input.artifact.artifact_kind)}`;
29771
+ return `knowledge/${input.collection}/${namespace}/${subject}${suffix}.md`;
29554
29772
  }
29555
29773
  function structuredSections(artifact, facts) {
29556
29774
  return artifact.sections.map((section) => {
@@ -29657,6 +29875,11 @@ function resolveIndexerLayout(input) {
29657
29875
  if (bundleById.size !== (artifactBundle?.artifacts.length ?? 0) || bundleById.size !== effective.artifacts.length) {
29658
29876
  throw new TypeError("layout resolver requires one Artifact Bundle entry per Artifact");
29659
29877
  }
29878
+ const requiredArtifactIds = new Set((artifactBundle?.artifacts ?? []).filter((artifact) => artifact.purpose === "required").map((artifact) => artifact.artifact_id));
29879
+ const artifactKindCounts = new Map;
29880
+ for (const artifact of effective.artifacts) {
29881
+ artifactKindCounts.set(artifact.artifact_kind, (artifactKindCounts.get(artifact.artifact_kind) ?? 0) + 1);
29882
+ }
29660
29883
  const artifacts = effective.artifacts.map((artifact) => {
29661
29884
  const bundleEntry = bundleById.get(artifact.artifact_id);
29662
29885
  if (bundleEntry === undefined || bundleEntry.artifact_kind !== artifact.artifact_kind) {
@@ -29702,9 +29925,10 @@ function resolveIndexerLayout(input) {
29702
29925
  collection,
29703
29926
  output_path: outputPath({
29704
29927
  collection,
29705
- module_ref: result.module_ref,
29706
29928
  subject_key: result.logical_unit.subject_key,
29707
- artifact_id: artifact.artifact_id
29929
+ artifact,
29930
+ primary: effective.artifacts.length === 1 || requiredArtifactIds.size === 1 && requiredArtifactIds.has(artifact.artifact_id),
29931
+ duplicate_kind: (artifactKindCounts.get(artifact.artifact_kind) ?? 0) > 1
29708
29932
  }),
29709
29933
  shared_artifact_fingerprint_digest: sharedFingerprint.fingerprint_digest,
29710
29934
  purpose: bundleEntry.purpose,
@@ -31799,17 +32023,38 @@ function replaceEntry(input) {
31799
32023
  return buildLedger({ workset_set: input.ledger.workset_set, entries });
31800
32024
  }
31801
32025
  function startIndexerMainRun(input) {
32026
+ return startIndexerMainRuns({
32027
+ ledger: input.ledger,
32028
+ workset_digests: [input.workset_digest]
32029
+ });
32030
+ }
32031
+ function startIndexerMainRuns(input) {
31802
32032
  const ledger = validateIndexerMainRunLedger(input.ledger);
31803
- return replaceEntry({
31804
- ledger,
31805
- workset_digest: input.workset_digest,
31806
- replace: (entry) => {
31807
- if (entry.state !== "pending" && entry.state !== "stale") {
31808
- throw new TypeError("only pending or stale main work may start");
31809
- }
32033
+ if (input.workset_digests.length === 0) {
32034
+ throw new TypeError("main run batch must contain at least one workset");
32035
+ }
32036
+ const requested = new Set(input.workset_digests);
32037
+ if (requested.size !== input.workset_digests.length) {
32038
+ throw new TypeError("main run batch contains duplicate worksets");
32039
+ }
32040
+ const selected = ledger.entries.filter((entry) => requested.has(entry.workset_digest));
32041
+ if (selected.length !== requested.size) {
32042
+ throw new TypeError("main run ledger has no requested workset");
32043
+ }
32044
+ if (new Set(selected.map((entry) => entry.stage)).size !== 1) {
32045
+ throw new TypeError("main run batch must contain one stage");
32046
+ }
32047
+ if (selected.some((entry) => entry.state !== "pending" && entry.state !== "stale")) {
32048
+ throw new TypeError("only pending or stale main work may start");
32049
+ }
32050
+ return buildLedger({
32051
+ workset_set: ledger.workset_set,
32052
+ entries: ledger.entries.map((entry) => {
32053
+ if (!requested.has(entry.workset_digest))
32054
+ return entry;
31810
32055
  const clean = Object.fromEntries(Object.entries(entry).filter(([key]) => key !== "state" && key !== "previous_workset_digest" && key !== "previous_execution_request_digest"));
31811
32056
  return { ...clean, state: "running" };
31812
- }
32057
+ })
31813
32058
  });
31814
32059
  }
31815
32060
  function acceptIndexerMainRun(input) {
@@ -33375,6 +33620,7 @@ export {
33375
33620
  validateAndRecordIndexerMainRun,
33376
33621
  validateAndMaterializeIndexerLayerFragment,
33377
33622
  startIndexerPostAuthorRun,
33623
+ startIndexerMainRuns,
33378
33624
  startIndexerMainRun,
33379
33625
  source,
33380
33626
  sameIndexerParserExecutionPlan,
@@ -33410,6 +33656,7 @@ export {
33410
33656
  planIndexerPostAuthorComposition,
33411
33657
  parseIndexerRegistry,
33412
33658
  parseIndexerProviderManifest,
33659
+ parseIndexerCurrentActionSubmission,
33413
33660
  ownerCells,
33414
33661
  observeIndexerPostAuthorState,
33415
33662
  observeIndexerMainWorksetState,
@@ -33538,7 +33785,6 @@ export {
33538
33785
  indexerProviderManifestSchema,
33539
33786
  indexerProviderLayerRefSchema,
33540
33787
  indexerProviderLayerFragmentSchema,
33541
- indexerProviderFinalizationSemanticInputSchema,
33542
33788
  indexerProviderCompositionPlanSchema,
33543
33789
  indexerProviderBundleIntegrity,
33544
33790
  indexerProtocolDigest,
@@ -33830,6 +34076,7 @@ export {
33830
34076
  buildIndexerPrimaryRegistryProjection,
33831
34077
  buildIndexerPrimaryExecutionProjection,
33832
34078
  buildIndexerPostAuthorFragmentRequest,
34079
+ buildIndexerPostAuthorAgentStepInput,
33833
34080
  buildIndexerPartitionInventoryFromParserFactView,
33834
34081
  buildIndexerParserWorksetViewSource,
33835
34082
  buildIndexerParserResolutionLocks,