@kognai/orchestrator-core 0.2.1 → 0.2.2

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,4 +1,4 @@
1
- import { type CitizenOwner } from './citizenship';
1
+ import { type CitizenOwner, type CitizenRecord } from './citizenship';
2
2
  import type { AgentTask, ReviewResult, CTOProposal, CTOReport } from './orchestrate-engine';
3
3
  export declare class SupervisorAgent {
4
4
  private systemPrompt;
@@ -69,6 +69,13 @@ export interface SpawnGateResult {
69
69
  * Voxight swarm's a Voxight citizen, etc. The running company is carried by
70
70
  * the template-injected gate's requester_did, not hardcoded in the engine. */
71
71
  owner?: CitizenOwner;
72
+ /** TICKET-334b: the citizen the gate already minted through the template's
73
+ * canonical issuer (Kognai → SAF.spawnCitizen — governance + owner-lineage +
74
+ * ACP-at-birth). When present the engine adopts it verbatim and SKIPS its own
75
+ * bare mintCitizen, so the engine path no longer loses the ACP seeding. When
76
+ * absent (gate-less templates, or a gate that only governs) the engine falls
77
+ * back to minting itself with the resolved owner. */
78
+ citizen?: CitizenRecord;
72
79
  }
73
80
  export type SpawnGate = (spec: AgentSpawnSpec) => SpawnGateResult;
74
81
  export declare class AgentCreator {
@@ -736,6 +736,7 @@ class AgentCreator {
736
736
  // anything on disk. Approval/rejection only; the citizenship logic below is
737
737
  // unchanged (its extraction is tracked separately as TICKET-226).
738
738
  let spawnOwner;
739
+ let gateCitizen;
739
740
  if (this.spawnGate) {
740
741
  const decision = this.spawnGate(spec);
741
742
  if (!decision.approved) {
@@ -753,6 +754,10 @@ class AgentCreator {
753
754
  // The gate (SAF) resolves the lineage from its requester_did — this is the
754
755
  // running company's context, plumbed in rather than hardcoded here.
755
756
  spawnOwner = decision.owner;
757
+ // TICKET-334b: when the gate minted through the canonical issuer
758
+ // (SAF.spawnCitizen — owner-lineage + ACP-at-birth), adopt that citizen
759
+ // and skip the bare mint below (which would skip ACP seeding).
760
+ gateCitizen = decision.citizen;
756
761
  }
757
762
  const agentDir = `./agents/${spec.name}`;
758
763
  (0, fs_1.mkdirSync)(agentDir, { recursive: true });
@@ -760,9 +765,11 @@ class AgentCreator {
760
765
  // citizen — not a bare agent. Mint citizenship (citizen_id + roll
761
766
  // number + Kōpus avatar + ACP baseline) BEFORE writing the agent
762
767
  // files so the citizen record can be referenced in the prompt.
763
- // Owner-scoped when the gate supplied a lineage (e.g. invoica/voxight);
764
- // legacy kognai-internal path otherwise (back-compat for gate-less templates).
765
- const citizen = (0, citizenship_1.mintCitizen)(spec.name, {
768
+ // Prefer the citizen the gate already minted through the canonical issuer
769
+ // (carries ACP-at-birth); else mint here owner-scoped when the gate supplied
770
+ // a lineage (e.g. invoica/voxight), or via the legacy kognai-internal path
771
+ // for gate-less templates.
772
+ const citizen = gateCitizen ?? (0, citizenship_1.mintCitizen)(spec.name, {
766
773
  founding_agent: 'ceo',
767
774
  proposing_agent: 'cto',
768
775
  citizen_type: 'spawned',
@@ -119,12 +119,19 @@ export declare function deriveOwner(requester_did: string): CitizenOwner;
119
119
  *
120
120
  * Returns the governance decision plus the minted citizen (when approved). The
121
121
  * caller still writes citizen.yaml via renderCitizenYaml(citizen). The initial
122
- * ACP (`decision.initial_acp_score`) should be persisted to the score registry
123
- * by the caller/wiring step (see TICKET-335).
122
+ * ACP is seeded here at birth (writeInitialAcp) so the citizen has a routing
123
+ * profile from the moment it exists — this is the property the engine seam lost
124
+ * when it minted via bare mintCitizen (TICKET-334b).
125
+ *
126
+ * `founding_agent` / `proposing_agent` let a caller preserve its own attribution
127
+ * (e.g. the engine's CEO-founds / CTO-proposes lineage). When omitted, the
128
+ * proposing agent defaults to the requester DID.
124
129
  */
125
130
  export declare function spawnCitizen(req: SpawnRequest, opts?: {
126
131
  agent_name?: string;
127
132
  now?: Date;
133
+ founding_agent?: string;
134
+ proposing_agent?: string;
128
135
  }): {
129
136
  decision: SpawnDecision;
130
137
  citizen?: CitizenRecord;
@@ -328,8 +328,13 @@ function deriveOwner(requester_did) {
328
328
  *
329
329
  * Returns the governance decision plus the minted citizen (when approved). The
330
330
  * caller still writes citizen.yaml via renderCitizenYaml(citizen). The initial
331
- * ACP (`decision.initial_acp_score`) should be persisted to the score registry
332
- * by the caller/wiring step (see TICKET-335).
331
+ * ACP is seeded here at birth (writeInitialAcp) so the citizen has a routing
332
+ * profile from the moment it exists — this is the property the engine seam lost
333
+ * when it minted via bare mintCitizen (TICKET-334b).
334
+ *
335
+ * `founding_agent` / `proposing_agent` let a caller preserve its own attribution
336
+ * (e.g. the engine's CEO-founds / CTO-proposes lineage). When omitted, the
337
+ * proposing agent defaults to the requester DID.
333
338
  */
334
339
  function spawnCitizen(req, opts = {}) {
335
340
  const decision = sovereignSpawn(req);
@@ -339,7 +344,8 @@ function spawnCitizen(req, opts = {}) {
339
344
  const citizen = (0, citizenship_1.mintCitizen)(opts.agent_name ?? req.requested_role, {
340
345
  owner,
341
346
  citizen_type: 'spawned',
342
- proposing_agent: req.requester_did,
347
+ founding_agent: opts.founding_agent,
348
+ proposing_agent: opts.proposing_agent ?? req.requester_did,
343
349
  now: opts.now,
344
350
  });
345
351
  decision.citizen_did = citizen.agent_did;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kognai/orchestrator-core",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Kognai sovereign orchestrator — core engine (template-agnostic). Shared by all products (Kognai/coding, Voxight/market-intel, Invoica/fin-compliance); each supplies only its template. Replaces per-repo forks of orchestrate-agents-v2 / sprint-runner / lib.",
5
5
  "license": "MIT",
6
6
  "author": "SkinGem",