authoring-cli 0.1.11 → 0.1.12

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/dist/index.js CHANGED
@@ -1542,13 +1542,10 @@ async function updateAxiom(cfg, input, currentTask) {
1542
1542
  if (!axiom) {
1543
1543
  return { statusCode: 404, body: { error: `Concept ${input.conceptId} has no class axiom ${input.axiomId}.` } };
1544
1544
  }
1545
- if (axiom.effectiveTime != null) {
1546
- return {
1547
- statusCode: 409,
1548
- body: { error: `Axiom ${input.axiomId} has effectiveTime ${String(axiom.effectiveTime)} set (already versioned) \u2014 cannot update.` }
1549
- };
1550
- }
1551
1545
  axiom.relationships = input.relationships;
1546
+ if (input.active != null) {
1547
+ axiom.active = input.active;
1548
+ }
1552
1549
  return null;
1553
1550
  });
1554
1551
  }
@@ -1566,13 +1563,10 @@ async function updateGciAxiom(cfg, input, currentTask) {
1566
1563
  if (!axiom) {
1567
1564
  return { statusCode: 404, body: { error: `Concept ${input.conceptId} has no GCI axiom ${input.axiomId}.` } };
1568
1565
  }
1569
- if (axiom.effectiveTime != null) {
1570
- return {
1571
- statusCode: 409,
1572
- body: { error: `GCI axiom ${input.axiomId} has effectiveTime ${String(axiom.effectiveTime)} set (already versioned) \u2014 cannot update.` }
1573
- };
1574
- }
1575
1566
  axiom.relationships = input.relationships;
1567
+ if (input.active != null) {
1568
+ axiom.active = input.active;
1569
+ }
1576
1570
  return null;
1577
1571
  });
1578
1572
  }
@@ -1684,13 +1678,21 @@ async function inactivateAxiom(cfg, input, currentTask) {
1684
1678
  body: { error: `Unpublished axiom ${input.axiomId} cannot be inactivated \u2014 it should be deleted instead (use delete-axiom).` }
1685
1679
  };
1686
1680
  }
1687
- const otherActiveCount = axioms.filter((a) => a !== axiom && a.active !== false).length;
1688
- if (otherActiveCount === 0) {
1681
+ const otherActiveAxioms = axioms.filter((a) => a !== axiom && a.active !== false);
1682
+ if (otherActiveAxioms.length === 0) {
1689
1683
  return {
1690
1684
  statusCode: 409,
1691
1685
  body: { error: `Concept ${input.conceptId} has only one active class axiom \u2014 a concept must retain at least one.` }
1692
1686
  };
1693
1687
  }
1688
+ if (otherActiveAxioms.every((a) => a.effectiveTime == null)) {
1689
+ return {
1690
+ statusCode: 409,
1691
+ body: {
1692
+ error: `Inactivating axiom ${input.axiomId} would leave concept ${input.conceptId} with only unpublished class axiom(s) active \u2014 this is the add-a-replacement-then-inactivate-the-original pattern, which produces two OwlAxiom rows where the real Authoring Workbench produces one. Use update-axiom to edit ${input.axiomId}'s content in place instead.`
1693
+ }
1694
+ };
1695
+ }
1694
1696
  axiom.active = false;
1695
1697
  return null;
1696
1698
  });
@@ -1869,7 +1871,7 @@ function relationshipsMatchAuthoringForm(current, target) {
1869
1871
  const groupsB = b.groups.map((g) => g.join("|")).sort();
1870
1872
  return groupsA.join("||") === groupsB.join("||");
1871
1873
  }
1872
- async function transformAxiom(cfg, input, currentTask, metadataCache = /* @__PURE__ */ new Map()) {
1874
+ async function transformAxiom(cfg, input, currentTask) {
1873
1875
  if (!input.conceptId) {
1874
1876
  return { statusCode: 400, body: { error: "conceptId is required." } };
1875
1877
  }
@@ -1889,48 +1891,11 @@ async function transformAxiom(cfg, input, currentTask, metadataCache = /* @__PUR
1889
1891
  );
1890
1892
  return { statusCode: 200, body: { conceptId: input.conceptId, axiomId, alreadyConformed: true } };
1891
1893
  }
1892
- const published = axiom.effectiveTime != null;
1893
- if (!published) {
1894
- return updateAxiom(
1895
- cfg,
1896
- { conceptId: input.conceptId, axiomId, relationships: targetRelationships, projectKey: taskContext.projectKey, taskKey: taskContext.taskKey },
1897
- currentTask
1898
- );
1899
- }
1900
- const addResult = await addAxiom(
1894
+ return updateAxiom(
1901
1895
  cfg,
1902
- {
1903
- conceptId: input.conceptId,
1904
- relationships: targetRelationships,
1905
- moduleId: typeof axiom.moduleId === "string" ? axiom.moduleId : void 0,
1906
- definitionStatus: axiom.definitionStatus,
1907
- projectKey: taskContext.projectKey,
1908
- taskKey: taskContext.taskKey
1909
- },
1910
- currentTask,
1911
- metadataCache
1912
- );
1913
- if (addResult.statusCode < 200 || addResult.statusCode >= 300) {
1914
- return addResult;
1915
- }
1916
- const inactivateResult = await inactivateAxiom(
1917
- cfg,
1918
- { conceptId: input.conceptId, axiomId, projectKey: taskContext.projectKey, taskKey: taskContext.taskKey },
1896
+ { conceptId: input.conceptId, axiomId, relationships: targetRelationships, projectKey: taskContext.projectKey, taskKey: taskContext.taskKey },
1919
1897
  currentTask
1920
1898
  );
1921
- if (inactivateResult.statusCode < 200 || inactivateResult.statusCode >= 300) {
1922
- return {
1923
- statusCode: inactivateResult.statusCode,
1924
- body: {
1925
- error: `Added the transformed axiom but failed to inactivate published axiom ${axiomId}: ${JSON.stringify(inactivateResult.body)}`,
1926
- addResult: addResult.body
1927
- }
1928
- };
1929
- }
1930
- return {
1931
- statusCode: inactivateResult.statusCode,
1932
- body: { replacedAxiomId: axiomId, addResult: addResult.body, inactivateResult: inactivateResult.body }
1933
- };
1934
1899
  }
1935
1900
  async function checkStatedParentsDefinitionStatus(cfg, input, currentTask) {
1936
1901
  if (!input.conceptId) {
@@ -2089,6 +2054,15 @@ async function inactivateGciAxiom(cfg, input, currentTask) {
2089
2054
  if (axiom.active === false) {
2090
2055
  return { statusCode: 409, body: { error: `GCI axiom ${input.axiomId} is already inactive.` } };
2091
2056
  }
2057
+ const otherActiveAxioms = axioms.filter((a) => a !== axiom && a.active !== false);
2058
+ if (otherActiveAxioms.length > 0 && otherActiveAxioms.every((a) => a.effectiveTime == null)) {
2059
+ return {
2060
+ statusCode: 409,
2061
+ body: {
2062
+ error: `Inactivating GCI axiom ${input.axiomId} would leave concept ${input.conceptId} with only unpublished GCI axiom(s) active \u2014 this is the add-a-replacement-then-inactivate-the-original pattern, which produces two OwlAxiom rows where the real Authoring Workbench produces one. Use update-gci-axiom to edit ${input.axiomId}'s content in place instead.`
2063
+ }
2064
+ };
2065
+ }
2092
2066
  axiom.active = false;
2093
2067
  return null;
2094
2068
  });
@@ -4560,7 +4534,14 @@ async function runUpdateAxiom(args) {
4560
4534
  const cfg = toBackendConfig(session);
4561
4535
  const result = await updateAxiom(
4562
4536
  cfg,
4563
- { conceptId: args.id, axiomId: args.axiomId, relationships, projectKey: args.project, taskKey: args.task },
4537
+ {
4538
+ conceptId: args.id,
4539
+ axiomId: args.axiomId,
4540
+ relationships,
4541
+ active: args.reactivate ? true : void 0,
4542
+ projectKey: args.project,
4543
+ taskKey: args.task
4544
+ },
4564
4545
  session.currentTask
4565
4546
  );
4566
4547
  const body = result.body;
@@ -4588,7 +4569,14 @@ async function runUpdateGciAxiom(args) {
4588
4569
  const cfg = toBackendConfig(session);
4589
4570
  const result = await updateGciAxiom(
4590
4571
  cfg,
4591
- { conceptId: args.id, axiomId: args.axiomId, relationships, projectKey: args.project, taskKey: args.task },
4572
+ {
4573
+ conceptId: args.id,
4574
+ axiomId: args.axiomId,
4575
+ relationships,
4576
+ active: args.reactivate ? true : void 0,
4577
+ projectKey: args.project,
4578
+ taskKey: args.task
4579
+ },
4592
4580
  session.currentTask
4593
4581
  );
4594
4582
  const body = result.body;
@@ -5779,19 +5767,20 @@ var COMMANDS = [
5779
5767
  },
5780
5768
  {
5781
5769
  name: "update-axiom",
5782
- usage: `update-axiom --id <SCTID> --axiom-id <axiomId> --relationships '[{"active":true,"groupId":0,"type":{"conceptId":"..."},"target":{"conceptId":"..."}}]' [--project <projectKey> --task <taskKey>] (only if never versioned; replaces the axiom's relationships wholesale)`,
5770
+ usage: `update-axiom --id <SCTID> --axiom-id <axiomId> --relationships '[{"active":true,"groupId":0,"type":{"conceptId":"..."},"target":{"conceptId":"..."}}]' [--reactivate] [--project <projectKey> --task <taskKey>] (replaces the axiom's relationships wholesale in place, same axiomId, published or not \u2014 Snowstorm clears the axiom's effectiveTime on save if it was versioned; --reactivate also sets the axiom active, for repairing one previously retired via inactivate-axiom)`,
5783
5771
  required: ["id", "axiom-id", "relationships"],
5784
5772
  run: (flags) => runUpdateAxiom({
5785
5773
  id: flags.id,
5786
5774
  axiomId: flags["axiom-id"],
5787
5775
  relationships: flags.relationships,
5776
+ reactivate: "reactivate" in flags,
5788
5777
  project: flags.project,
5789
5778
  task: flags.task
5790
5779
  })
5791
5780
  },
5792
5781
  {
5793
5782
  name: "add-axiom",
5794
- usage: `add-axiom --id <SCTID> --relationships '[{"active":true,"groupId":0,"type":{"conceptId":"116680003"},"target":{"conceptId":"..."}}]' [--definition-status PRIMITIVE|FULLY_DEFINED] [--module-id <moduleId>] [--project <projectKey> --task <taskKey>] (adds a new class axiom; use to replace a published axiom \u2014 add the replacement here, then inactivate-axiom the old one)`,
5783
+ usage: `add-axiom --id <SCTID> --relationships '[{"active":true,"groupId":0,"type":{"conceptId":"116680003"},"target":{"conceptId":"..."}}]' [--definition-status PRIMITIVE|FULLY_DEFINED] [--module-id <moduleId>] [--project <projectKey> --task <taskKey>] (appends a genuinely additional class axiom alongside the concept's existing one(s) \u2014 to change an existing axiom's content instead, use update-axiom in place, published or not)`,
5795
5784
  required: ["id", "relationships"],
5796
5785
  run: (flags) => runAddAxiom({
5797
5786
  id: flags.id,
@@ -5816,12 +5805,13 @@ var COMMANDS = [
5816
5805
  },
5817
5806
  {
5818
5807
  name: "update-gci-axiom",
5819
- usage: `update-gci-axiom --id <SCTID> --axiom-id <axiomId> --relationships '[{"active":true,"groupId":0,"type":{"conceptId":"..."},"target":{"conceptId":"..."}}]' [--project <projectKey> --task <taskKey>] (only if never versioned; replaces the axiom's relationships wholesale)`,
5808
+ usage: `update-gci-axiom --id <SCTID> --axiom-id <axiomId> --relationships '[{"active":true,"groupId":0,"type":{"conceptId":"..."},"target":{"conceptId":"..."}}]' [--reactivate] [--project <projectKey> --task <taskKey>] (replaces the axiom's relationships wholesale in place, same axiomId, published or not \u2014 Snowstorm clears the axiom's effectiveTime on save if it was versioned; --reactivate also sets the axiom active, for repairing one previously retired via inactivate-gci-axiom)`,
5820
5809
  required: ["id", "axiom-id", "relationships"],
5821
5810
  run: (flags) => runUpdateGciAxiom({
5822
5811
  id: flags.id,
5823
5812
  axiomId: flags["axiom-id"],
5824
5813
  relationships: flags.relationships,
5814
+ reactivate: "reactivate" in flags,
5825
5815
  project: flags.project,
5826
5816
  task: flags.task
5827
5817
  })
@@ -5914,7 +5904,7 @@ var COMMANDS = [
5914
5904
  },
5915
5905
  {
5916
5906
  name: "inactivate-axiom",
5917
- usage: "inactivate-axiom --id <SCTID> --axiom-id <axiomId> [--project <projectKey> --task <taskKey>] (only if published; for an unpublished axiom use delete-axiom instead; a concept must retain at least one active class axiom)",
5907
+ usage: "inactivate-axiom --id <SCTID> --axiom-id <axiomId> [--project <projectKey> --task <taskKey>] (only if published; for an unpublished axiom use delete-axiom instead; a concept must retain at least one active class axiom; 409s if every other active class axiom is itself unpublished \u2014 that combination is the add-a-replacement-then-inactivate anti-pattern, not a legitimate retirement; use update-axiom to edit this axiom in place instead)",
5918
5908
  required: ["id", "axiom-id"],
5919
5909
  run: (flags) => runInactivateAxiom({
5920
5910
  id: flags.id,
@@ -5925,7 +5915,7 @@ var COMMANDS = [
5925
5915
  },
5926
5916
  {
5927
5917
  name: "transform-axiom",
5928
- usage: "transform-axiom --id <SCTID> [--axiom-id <axiomId>] [--project <projectKey> --task <taskKey>] (rewrites a class axiom into the standard authoring form \u2014 Is-a to the proximal primitive parent(s) plus every currently-inferred attribute, per Snowstorm's own authoring-form computation; a never-versioned axiom is updated in place, a published one is replaced by adding the transformed axiom and inactivating the original \u2014 omit --axiom-id to target the concept's sole active class axiom)",
5918
+ usage: "transform-axiom --id <SCTID> [--axiom-id <axiomId>] [--project <projectKey> --task <taskKey>] (rewrites a class axiom into the standard authoring form \u2014 Is-a to the proximal primitive parent(s) plus every currently-inferred attribute, per Snowstorm's own authoring-form computation; updates the axiom in place, published or not \u2014 omit --axiom-id to target the concept's sole active class axiom)",
5929
5919
  required: ["id"],
5930
5920
  run: (flags) => runTransformAxiom({
5931
5921
  id: flags.id,
@@ -5958,7 +5948,7 @@ var COMMANDS = [
5958
5948
  },
5959
5949
  {
5960
5950
  name: "inactivate-gci-axiom",
5961
- usage: "inactivate-gci-axiom --id <SCTID> --axiom-id <axiomId> [--project <projectKey> --task <taskKey>] (only if published; for an unpublished GCI axiom use delete-gci-axiom instead; unlike inactivate-axiom there is no minimum-active-count guard, since GCI axioms are optional)",
5951
+ usage: "inactivate-gci-axiom --id <SCTID> --axiom-id <axiomId> [--project <projectKey> --task <taskKey>] (only if published; for an unpublished GCI axiom use delete-gci-axiom instead; unlike inactivate-axiom there is no minimum-active-count guard, since GCI axioms are optional; 409s if every other active GCI axiom is itself unpublished \u2014 use update-gci-axiom to edit this axiom in place instead)",
5962
5952
  required: ["id", "axiom-id"],
5963
5953
  run: (flags) => runInactivateGciAxiom({
5964
5954
  id: flags.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authoring-cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "CLI for SNOMED CT authoring against authoring-services",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
@@ -424,31 +424,31 @@ common case — are unaffected; plain `add-relationship` is fine and simpler the
424
424
  (`remove-relationship` is also callable as `delete-relationship` — same command, whichever verb
425
425
  you reach for first.)
426
426
 
427
- `update-axiom` and `remove-relationship` are gated at **different levels**, and that difference is
428
- the whole story for editing an axiom that's already been released:
429
-
430
- - `update-axiom` checks the **axiom's own** `effectiveTime`. If the axiom has ever been versioned
431
- (`released: true` with a real `effectiveTime`, not just inherited from the concept), every call
432
- fails with HTTP 409 — it replaces `relationships` wholesale, so it refuses outright rather than
433
- risk silently changing a released axiom's meaning.
434
- - `remove-relationship` checks the **targeted relationship's own** `effectiveTime` only, never the
435
- axiom's. This mirrors the real Authoring Workbench: its "Remove Relationship" button re-saves the
436
- same axiom (same `axiomId`) with one relationship gone, regardless of whether that axiom has been
437
- released before — only the specific relationship being removed must itself never have been
438
- versioned.
439
-
440
- So: **removing one relationship from a published axiom is `remove-relationship`, not
441
- `update-axiom`.** Get the target's `relationshipId` (or its array index within that axiom) from
442
- `get-concept --axioms`, then:
427
+ Neither `update-axiom` nor `remove-relationship` gates on the axiom's own `effectiveTime` — both
428
+ edit a published axiom's row in place (same `axiomId`), matching the real Authoring Workbench, which
429
+ edits a released axiom's content directly rather than inactivating it and adding a replacement. The
430
+ difference between the two commands is what each is built to touch, not what publication state they
431
+ tolerate:
432
+
433
+ - `remove-relationship` splices out exactly one relationship, addressed by `relationshipId` (or
434
+ array index) — the simplest tool when you know which single relationship has to go and want to
435
+ leave the rest of the axiom untouched.
436
+ - `update-axiom` replaces the whole `relationships` array at once — the tool for rebuilding several
437
+ relationships/groups together in one call (see the multi-group case above). The same applies to
438
+ `update-gci-axiom` on `gciAxioms`.
439
+
440
+ So for removing just one relationship, prefer `remove-relationship`. Get the target's
441
+ `relationshipId` (or its array index within that axiom) from `get-concept --axioms`, then:
443
442
 
444
443
  ```
445
444
  authoring-cli remove-relationship --id <SCTID> --axiom-id <axiomId> --relationship-id <relationshipId>
446
445
  ```
447
446
 
448
- If that specific relationship has its own `effectiveTime` set (it was independently versioned —
449
- uncommon, but possible for a relationship inside an otherwise-unversioned axiom edit history), the
450
- call 409s and there's no way to remove it via the CLI; that's expected residue, same as the fully-
451
- versioned-axiom case in "Redundant stated Is-a relationships" below.
447
+ `remove-relationship` still guards the **targeted relationship's own** `effectiveTime`: if that
448
+ specific relationship has its own `effectiveTime` set (independently versioned — uncommon, but
449
+ possible for a relationship inside an otherwise-unversioned axiom edit history), the call 409s and
450
+ there's no way to remove it via the CLI; that's expected residue, same as the fully-versioned-
451
+ relationship case in "Redundant stated Is-a relationships" below.
452
452
 
453
453
  ### Removing an entire role group
454
454
 
@@ -498,8 +498,8 @@ stated `Is a`) is excluded from matching unless you explicitly pass `--group-id
498
498
  pair that happens to match an ungrouped attribute could sweep up unrelated ungrouped relationships,
499
499
  including `Is a`, as collateral damage. And `remove-role-group` only targets `classAxioms`; a GCI
500
500
  role group still needs the `update-gci-axiom` workaround (rewrite the relationships list with that
501
- group's entries omitted), gated on the whole GCI axiom's own `effectiveTime` since there's no
502
- per-relationship GCI removal endpoint.
501
+ group's entries omitted) — with no axiom-level `effectiveTime` gate either, same in-place-edit
502
+ behavior as `update-axiom`, since there's no per-relationship GCI removal endpoint.
503
503
 
504
504
  Confirm with `authoring-cli validate-concept --id <SCTID>` afterward.
505
505
 
@@ -551,7 +551,16 @@ groups above. Retiring the axiom itself follows the same delete-vs-inactivate sp
551
551
  `delete-gci-axiom --id <SCTID> --axiom-id <axiomId>` 409s on a published one, `inactivate-gci-axiom
552
552
  --id <SCTID> --axiom-id <axiomId>` 409s on a never-versioned one. Unlike `inactivate-axiom`,
553
553
  `inactivate-gci-axiom` has no minimum-active-count guard — GCI axioms are optional, so a concept can
554
- be left with zero active ones.
554
+ be left with zero active ones (inactivating the sole GCI axiom, with nothing to replace it, is a
555
+ legitimate, allowed retirement).
556
+
557
+ **`add-gci-axiom` then `inactivate-gci-axiom` must never be used together to replace one GCI's
558
+ content**, same rule and same reason as class axioms below: `inactivate-gci-axiom` 409s if doing so
559
+ would leave only unpublished GCI axiom(s) active, naming `update-gci-axiom` as the in-place fix. Use
560
+ `update-gci-axiom` to rewrite a published GCI's content; reach for `add-gci-axiom` only when the
561
+ concept genuinely needs an independent, additional GCI axiom — unlike class axioms, a concept
562
+ carrying more than one GCI (or a GCI alongside its single class axiom) is normal, not an edge case,
563
+ so this carve-out is the common path for GCIs even though it's rare for class axioms.
555
564
 
556
565
  **Deciding *whether* and *how* to model with a GCI at all — for any concept type (disorder,
557
566
  procedure, observable, ...), not just this command's mechanics — is its own judgment call.** See
@@ -562,34 +571,60 @@ actually discriminate), how to shape the antecedent (genus + nexus + defining at
562
571
  role-group partition that silently changes an axiom's meaning if got wrong), and how to derive the
563
572
  axiom set from the terminology's own content rather than from theory alone.
564
573
 
565
- ### Replacing a published axiom
574
+ ### Editing a published axiom's content
566
575
 
567
- `update-axiom` and `delete-axiom` both refuse outright once an axiom's own `effectiveTime` is set —
568
- there is no in-place edit for a released axiom's content, by design (rewriting a versioned axiom's
569
- relationships, or removing it wholesale, risks silently changing what already shipped). "Replace"
570
- therefore means two separate calls, not one: add the new axiom, then retire the old one.
576
+ `update-axiom --id <SCTID> --axiom-id <axiomId> --relationships '[...]'` edits a class axiom's
577
+ content in place, published or not — it replaces `relationships` wholesale on the *same* `axiomId`
578
+ row and leaves it there; Snowstorm's own save clears that axiom's `effectiveTime` as part of
579
+ versioning the change. This matches the real Authoring Workbench exactly: editing a released axiom's
580
+ content there does not inactivate the old row and add a new one. `update-gci-axiom` behaves
581
+ identically for `gciAxioms`. Do **not** reach for "add a replacement axiom, then inactivate the old
582
+ one" for a content change — that produces two `OwlAxiom` rows on the concept (one inactive-but-
583
+ published, one newly active) where the real UI produces exactly one; that mismatch is real content
584
+ divergence, not cosmetic, and it's what `authoring-cli` used to do here before this was fixed.
571
585
 
572
586
  ```
573
- authoring-cli add-axiom --id <SCTID> --relationships \
587
+ authoring-cli update-axiom --id <SCTID> --axiom-id <axiomId> --relationships \
574
588
  '[{"active":true,"groupId":0,"type":{"conceptId":"116680003"},"target":{"conceptId":"..."}},
575
589
  {"active":true,"groupId":1,"type":{"conceptId":"363698007"},"target":{"conceptId":"..."}}]'
590
+ ```
591
+
592
+ **`add-axiom` and `inactivate-axiom` must never be used together to replace one axiom's content —
593
+ the CLI itself refuses it.** Calling `add-axiom` with the intended new content, then
594
+ `inactivate-axiom` on the axiom that content replaces, is exactly the two-step "add a replacement,
595
+ then retire the original" anti-pattern the previous section warns about, and `inactivate-axiom` 409s
596
+ on the second call: *"would leave concept ... with only unpublished class axiom(s) active ... Use
597
+ update-axiom to edit ... in place instead."* There is no way around that refusal, and no reason to
598
+ want one — `update-axiom` does the same edit correctly, as one save, with no duplicate row. If you
599
+ find yourself reaching for `add-axiom` immediately before `inactivate-axiom` on the axiom whose
600
+ content you're changing, stop and use `update-axiom` instead.
601
+
602
+ Unlike GCI axioms (see above), a genuinely independent second class axiom is rare: most SNOMED CT
603
+ concepts carry exactly one, and `add-axiom` exists mainly for the unusual editorial case where a
604
+ concept truly needs an additional, independent class axiom alongside the first. That's the only
605
+ legitimate use of `add-axiom`/`inactivate-axiom` together — and even then, the axiom being added and
606
+ the axiom being retired (if any) must be unrelated, with any axiom that survives active alongside a
607
+ newly-added one already published from earlier work, not something created in the same session as
608
+ part of retiring another. If you're not deliberately in that unusual situation, seeing yourself reach
609
+ for `add-axiom` right before `inactivate-axiom` is a sign to stop and use `update-axiom` instead —
610
+ treat it as the exception, not a normal two-step edit.
576
611
 
577
- authoring-cli inactivate-axiom --id <SCTID> --axiom-id <oldAxiomId>
612
+ ```
613
+ authoring-cli add-axiom --id <SCTID> --relationships \
614
+ '[{"active":true,"groupId":0,"type":{"conceptId":"116680003"},"target":{"conceptId":"..."}},
615
+ {"active":true,"groupId":1,"type":{"conceptId":"363698007"},"target":{"conceptId":"..."}}]'
578
616
  ```
579
617
 
580
- Like `add-gci-axiom`, `add-axiom` has **no publication gate** — it appends a brand-new axiom, so a
581
- released concept accepts it normally. `inactivate-axiom` requires the axiom being retired to
582
- already be published (`effectiveTime` set) — setting `active: false` on a released axiom's row is
583
- the normal RF2 retirement path; a never-versioned one has nothing to retire and should be
584
- `delete-axiom`d instead. It also enforces that **at least one class axiom stays active**, so run
585
- `add-axiom` first: the concept must never be left without a stated definition, even momentarily
586
- within the same task.
618
+ `add-axiom` has **no publication gate** — it appends a brand-new axiom, so a released concept
619
+ accepts it normally. `inactivate-axiom` requires the axiom being retired to already be published
620
+ (`effectiveTime` set) — setting `active: false` on a released axiom's row is the normal RF2
621
+ retirement path; a never-versioned one has nothing to retire and should be `delete-axiom`d instead.
622
+ It also enforces that **at least one class axiom stays active**.
587
623
 
588
- The new axiom's `definitionStatus` defaults to `PRIMITIVE` regardless of what the axiom being
589
- replaced was. If the axiom you're retiring was the concept's `FULLY_DEFINED` one and the new axiom
590
- should take over that role, follow up with `set-definition-status --status FULLY_DEFINED
591
- --axiom-index <N>` (index into `classAxioms` from a fresh `get-concept --axioms` — `add-axiom`'s own
592
- output reports the server-assigned `axiomId` for the one you just added).
624
+ The new axiom's `definitionStatus` defaults to `PRIMITIVE` regardless of any other axiom's. If it
625
+ should become the concept's `FULLY_DEFINED` axiom, follow up with `set-definition-status --status
626
+ FULLY_DEFINED --axiom-index <N>` (index into `classAxioms` from a fresh `get-concept --axioms` —
627
+ `add-axiom`'s own output reports the server-assigned `axiomId` for the one you just added).
593
628
 
594
629
  ### Collapsing an axiom to the standard authoring form
595
630
 
@@ -598,9 +633,9 @@ primitive parent(s) plus every currently-inferred attribute — the shape editor
598
633
  expects a primitive concept's stated definition to take, letting the classifier re-derive the more
599
634
  specific hierarchy instead of the axiom asserting it directly. It gets this shape from Snowstorm's
600
635
  own `GET .../authoring-form` (the same proximal-primitive-parent substitution the classifier itself
601
- uses), not a local reimplementation, then routes through exactly the mechanism above: `update-axiom`
602
- in place if the axiom has never been versioned, or `add-axiom` (carrying over the old axiom's
603
- `moduleId` and `definitionStatus`) followed by `inactivate-axiom` if it has.
636
+ uses), not a local reimplementation, then routes through `update-axiom` to rewrite the axiom in
637
+ place — published or not, same `axiomId` row, exactly like the mechanism described in "Editing a
638
+ published axiom's content" above.
604
639
 
605
640
  The one silent trap: **the target concept must already be classified**. `authoring-form` reads the
606
641
  concept's saved *inferred* relationships to do the substitution, not a live reasoner call — call it
@@ -609,9 +644,7 @@ it comes back with no parents and no attributes at all, which `transform-axiom`
609
644
  write as an axiom ("produced no relationships"). That error names the symptom, not the cause; if you
610
645
  see it, `classify --wait` the task first, then retry. If the axiom already matches authoring form,
611
646
  `transform-axiom` checks that before writing anything and reports `alreadyConformed: true` rather
612
- than reaching Snowstorm at all — the naive version of this reached `add-axiom` and let it 400 with
613
- "Active Concept should not have duplicate axioms" for a published axiom, which was a real but
614
- needless error to make the caller decode.
647
+ than reaching Snowstorm at all — avoiding a pointless rewrite-to-identical-content PUT.
615
648
 
616
649
  **`validate-concept`/`validate-review-concepts` deliberately don't run this check.** They're meant
617
650
  to be a quick, synchronous, single-concept (or per-concept-in-a-loop) check, and authoring-form
@@ -692,11 +725,10 @@ more specific one. Resolve it immediately rather than leaving it as residue:
692
725
  <id> --axiom-id <axiomId> --relationship-index <N>` removes just that one relationship
693
726
  cleanly, in one call, **regardless of whether the axiom itself has been released** — prefer
694
727
  this over rewriting the whole axiom.
695
- - Else (that specific relationship has itself been versioned) → try `update-axiom` if the *whole
696
- axiom* has never been versioned (rewrite the full list with the redundant parent dropped). If
697
- the axiom is genuinely versioned too, `update-axiom` 409s — fall back to "Replacing a published
698
- axiom" above: `add-axiom` with the full relationship list minus the redundant parent, then
699
- `inactivate-axiom` on the original. Don't leave both stated parents in place and file it as
728
+ - Else (that specific relationship has itself been versioned) → `update-axiom` with the full
729
+ relationship list minus the redundant parent, same `axiomId`, **regardless of whether the axiom
730
+ itself has been released** — it edits the row in place rather than refusing (see "Editing a
731
+ published axiom's content" above). Don't leave both stated parents in place and file it as
700
732
  expected residue — the warning is real and resolvable in one CLI session.
701
733
  3. Re-run `validate-concept --id <id>` to confirm the warning cleared.
702
734
 
@@ -744,20 +776,17 @@ a reference you're looking straight at.
744
776
  - **Children must be re-parented, not orphaned.** Decide their new parent deliberately: usually the
745
777
  concept that supersedes the one being deleted, or failing that the deleted concept's own parent,
746
778
  so the child doesn't silently jump up the hierarchy. Retarget with `update-axiom`, rewriting the
747
- full relationship list with only that `Is a` target changed — or, if the child's axiom is itself
748
- versioned and `update-axiom` 409s, `add-axiom` with the corrected list followed by
749
- `inactivate-axiom` on the original (see "Replacing a published axiom" above). Dropping the `Is a`
750
- outright is only right when the child has other parents that already place it correctly — check,
751
- don't assume.
779
+ full relationship list with only that `Is a` target changed — it edits the axiom in place, same
780
+ `axiomId`, regardless of whether it's published (see "Editing a published axiom's content" above).
781
+ Dropping the `Is a` outright is only right when the child has other parents that already place it
782
+ correctly — check, don't assume.
752
783
  - **Attribute references** get retargeted the same way, onto whichever concept now carries the
753
784
  meaning.
754
785
  - **A retrofitted `Is a` added to an existing published concept** (the common case when the
755
786
  now-unwanted concept was minted as a new parent for existing content) is removed, not retargeted:
756
- `remove-relationship --id <existingId> --axiom-id <axiomId> --relationship-index <N>`. Its axiom
757
- will usually be `released: true` while the retrofit relationship inside it is not, and
758
- `remove-relationship` gates on the relationship's own `effectiveTime` — this is exactly the case
759
- where `update-axiom` fails with 409 and `remove-relationship` succeeds. See "Removing a
760
- relationship — including from a published axiom" above.
787
+ `remove-relationship --id <existingId> --axiom-id <axiomId> --relationship-index <N>` — simpler
788
+ than `update-axiom` here since it only needs the one relationship's id/index, not the whole
789
+ relationship list rebuilt. See "Removing a relationship — including from a published axiom" above.
761
790
  - **A referrer that is itself being deleted** needs nothing — just delete it first.
762
791
 
763
792
  ### 3. Delete in dependency order
@@ -869,9 +898,17 @@ The same choice exists for a single class axiom too: `delete-axiom --id <SCTID>
869
898
  a never-versioned one — same guard pairing as concept/description. There's no indicator or
870
899
  association target at the axiom level; both commands instead also guard the concept's minimum: it
871
900
  must keep at least one class axiom (`delete-axiom` counts all of them) and, separately, at least
872
- one *active* one (`inactivate-axiom` counts only active ones). See "Replacing a published axiom"
873
- above for the add-axiom-then-inactivate-axiom sequence this feeds into when the goal is swapping an
874
- axiom's content rather than just retiring it.
901
+ one *active* one (`inactivate-axiom` counts only active ones). Unlike the concept/description case,
902
+ this pairing is for retiring an axiom outright (a concept that genuinely no longer needs one of its
903
+ several axioms) — swapping one axiom's *content* for another is `update-axiom` in place, see
904
+ "Editing a published axiom's content" above, not add-then-inactivate.
905
+
906
+ `inactivate-axiom`/`inactivate-gci-axiom` also refuse when every *other* active axiom of the same
907
+ type is itself unpublished: that combination — retiring one axiom while only a brand-new,
908
+ never-versioned one remains active — has no legitimate reading other than "I just added a
909
+ replacement, now let me retire the original", and the error names `update-axiom`/`update-gci-axiom`
910
+ as the in-place fix instead. A concept with a genuinely independent second axiom has both already
911
+ published from earlier work, so this never blocks a real multi-axiom retirement.
875
912
 
876
913
  ## Generating a concept structurally parallel to an existing one
877
914