authoring-cli 0.1.10 → 0.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authoring-cli",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "CLI for SNOMED CT authoring against authoring-services",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
@@ -43,6 +43,34 @@ committing to a sequence of edits. If nothing is selected and no flags are passe
43
43
  rather than guessing. `authoring-cli projects` and `authoring-cli tasks` list what's available to
44
44
  pick from; a session with no valid cookie needs `authoring-cli login [production|uat|dev]` first.
45
45
 
46
+ **A stale session can fail in a way that looks exactly like a server outage.** Symptoms: `get-concept`
47
+ (and everything else) suddenly returns `"Could not resolve branch path for <project>/<task>"` on a
48
+ branch that worked moments before, while `authoring-cli projects` and `authoring-cli tasks --project
49
+ <P> --summary` both come back empty (`"No projects available"` / `"No tasks in project <P>"`).
50
+ Retrying doesn't help — it isn't a transient blip, the session token expired mid-session. Fix:
51
+ `authoring-cli login uat` (or the relevant environment) reuses an already-signed-in Chrome session
52
+ with no browser popup if you're still logged in there. Confirm the branch/server is actually fine
53
+ with one plain `get-concept` call before concluding a real outage — the fix here takes seconds.
54
+
55
+ ## Concurrency: one mutating caller per task branch, at a time
56
+
57
+ Never run more than one mutating call against the same task branch concurrently, and never
58
+ delegate a batch of mutating calls to a subagent working the same branch alongside you. Even a
59
+ single sequential caller can trigger `branch locked, retrying` from the server's own internal
60
+ locking — true concurrent callers (parallel tool calls, an `xargs -P`-style fan-out, a subagent
61
+ mutating the same branch while you also are) compound this and have exhausted their retry budget
62
+ and failed outright with HTTP 400, silently leaving whatever they were doing half-finished despite
63
+ the command appearing to run to completion. This is a property of the branch lock, not of any one
64
+ command — confirmed for `set-definition-status` under `xargs -P 8`, but the same risk applies to
65
+ `create-concept`/`add-relationship`/`replace-fsn`/`add-description`/etc. equally. Reserve
66
+ parallelism for **read-only** calls (a `get-concept` sweep, independent `search-concepts` lookups)
67
+ — queue every mutating call against a given task branch sequentially, one at a time, whether
68
+ you're driving the sequence yourself or via a background loop. After any batch that hit retries or
69
+ ran under uncertain conditions, re-verify the whole target set with fresh `get-concept` calls
70
+ rather than trusting the batch run's exit status alone. See `references/batch-authoring.md`'s
71
+ "Driving a batch of mutating calls" for the fuller reasoning, including why a subagent's
72
+ self-reported summary isn't ground truth either.
73
+
46
74
  The `--project`/`--task` flags are shown on the examples below for explicitness. When a task is
47
75
  already selected via `select-task`, you can omit them everywhere.
48
76
 
@@ -175,6 +203,10 @@ you catch them during review or read the concept back afterward. Watch for these
175
203
  - **Missing or wrong semantic tag**: every FSN must end with a semantic tag; verify it matches the
176
204
  concept's actual domain. A body-structure concept should end with `(body structure)`, a finding
177
205
  with `(finding)`, etc.
206
+ - **A semantic tag on the PT or a synonym.** Only the FSN ever carries one. A PT/synonym built by
207
+ reusing the same tagged string passed to `--fsn` looks like `"Structure of X (body structure)"`
208
+ where it should just be `"Structure of X"` — check `get-concept --description-full`'s PT/synonym
209
+ terms whenever you passed the same source string to both `--fsn` and `--pt`.
178
210
 
179
211
  **Synonym specificity and meaning:**
180
212
  - **Inappropriate synonyms that shift the concept's meaning**: a synonym must name the same clinical
@@ -191,6 +223,15 @@ Run `review-concepts` before promoting a task to check these mistakes aren't hid
191
223
  pending changes — they save cleanly but are real content errors, not save-time constraint
192
224
  violations.
193
225
 
226
+ **`search-concepts` and `get-concept` put the FSN at different JSON paths — using the wrong one
227
+ silently reads as "no results," not an error.** `get-concept` nests it as `.fsn.term` (an object).
228
+ `search-concepts` returns it flat as `.items[].fsn` (a plain string). Applying `.fsn.term` to a
229
+ `search-concepts` result throws a jq parse error that's easy to let scroll past as "no match" —
230
+ this has produced strings of false negatives across a dozen-plus consecutive existence checks in
231
+ practice, nearly causing duplicate mints of concepts that already existed. Before trusting any
232
+ empty or erroring existence check built on `search-concepts` output, confirm the field path against
233
+ one real response rather than assuming the shape that works for `get-concept`.
234
+
194
235
  ## Ground truth vs. echoed validation results
195
236
 
196
237
  Every concept-mutating command (`create-concept`, `add-description`, `set-acceptability`, ...)
@@ -691,9 +732,9 @@ axioms as authored — which is what catches a same-session edit (a new relation
691
732
  `Is a`) before classification has run, exactly the situation right after authoring. Neither view
692
733
  alone is a complete answer on a branch with pending, unclassified changes; the inferred view misses
693
734
  what you just stated, and the stated view misses anything the terminology already carries only
694
- through inference. `--limit`/`--offset` page through `referencesByType[].referencingConcepts` on a
695
- heavily-referenced concept — check `total` against what came back, the same caution as any other
696
- paginated search here.
735
+ through inference. Without `--limit`/`--offset`, the command itself pages through and returns every
736
+ referencing concept on a heavily-referenced concept — pass `--limit`/`--offset` only if you want to
737
+ page through `referencesByType[].referencingConcepts` yourself instead.
697
738
 
698
739
  ### 2. Deal with every reference before deleting anything
699
740
 
@@ -837,7 +878,12 @@ axiom's content rather than just retiring it.
837
878
  A common authoring task, especially at scale: mint a new concept whose defining axiom is identical
838
879
  to an existing source concept's except for one substituted attribute value — a different
839
880
  anatomical site, laterality, substance, or similar. (For a worked example of this pattern applied
840
- across a large source list, see `references/batch-authoring.md`.)
881
+ across a large source list, see `references/batch-authoring.md`.) When the substituted value is
882
+ itself a body-structure anatomy concept, see `references/anatomy-authoring.md` for the
883
+ SNOMED CT-wide patterns this kind of work runs into: the `Structure of X`/`Entire X` pairing
884
+ convention, the laterality exception to it (and the `FULLY_DEFINED` shape a laterality-only axiom
885
+ needs), and the decomposition procedure for finding a concept's other generalization axes beyond
886
+ whichever one prompted the substitution.
841
887
 
842
888
  1. Fetch the source's **real** defining axiom via `get-concept --axioms` — not a rendering or a note from an
843
889
  earlier session; it may have changed. Identify exactly which relationship(s) carry the attribute
@@ -0,0 +1,131 @@
1
+ # Body-structure anatomy authoring patterns
2
+
3
+ General SNOMED CT body-structure modeling rules that recur across any anatomy content authoring project.
4
+
5
+ ## The `Structure of X` / `Entire X` pair
6
+
7
+ SNOMED CT routinely models a body-structure site as **two** concepts:
8
+
9
+ - `Structure of X (body structure)` — the general/partial-structure concept, used as the value of
10
+ a `Finding site`/`Procedure site` attribute elsewhere.
11
+ - `Entire X (body structure)` — Is-a `Structure of X` — representing the site as a whole
12
+ organ/part rather than "some of it".
13
+
14
+ This is not an occasional pattern; it recurs throughout SNOMED CT's body-structure hierarchy. The
15
+ naming isn't always a clean textual pair either — e.g. `Finger joint structure` pairs with
16
+ `Entire joint of finger`, not a mechanical word-order swap — so confirm a candidate pair via the
17
+ real stated parent (`get-concept`'s `classAxioms[].relationships`), never guess from FSN text
18
+ alone.
19
+
20
+ **Whenever you generalize, retarget, or otherwise touch one half of a pair, check the other
21
+ half.** Leaving one half unhandled produces an under-parented `Entire X` concept that falls back
22
+ to a generic ancestor instead of the specific `Structure of X` it should actually be a subtype of,
23
+ and silently strands the pair-mate's own work item even though it was directly relevant to work
24
+ already done. This check runs in **both directions** and needs both:
25
+ - From a `Structure of X` concept, an `Entire X` pair-mate (if one exists) is a **descendant** —
26
+ invisible to an ordinary ancestor/parent walk. Hypothesize the child's FSN and confirm via
27
+ `get-concept` that it actually states the `Structure of X` concept as a parent before treating
28
+ it as a real pair-mate.
29
+ - From an `Entire X` concept, its `Structure of X` pair-mate is among its own **stated parents** —
30
+ already visible from a `get-concept` on it, but `Entire X` concepts can carry 2-4 parents, so
31
+ check every one, not just the first plausible match.
32
+
33
+ **An `Entire X` concept's own parent should be another `Entire X` concept, not a `Structure of X`
34
+ concept, once you're one level up the hierarchy.** Getting this backwards silently produces
35
+ classifier-flagged equivalent concepts, with no save-time validation warning at all — confirmed
36
+ real case: an `Entire X` concept was stated Is-a a `Structure of X` concept (plus a qualifying
37
+ attribute) when it should have been Is-a the broader, already-existing `Entire X` ancestor plus
38
+ the same attribute. The only symptom is `classify`/`review-concepts` reporting
39
+ `equivalentConceptsFound: true` — the CLI has no command listing which concepts are actually
40
+ flagged as equivalent (only the Authoring Workbench UI shows the pair), so whenever that flag
41
+ appears, check every `Entire X` concept touched this session for a stated parent that isn't
42
+ itself `Entire X`-named before searching further; that's the pattern to check first.
43
+
44
+ ## Laterality is an exception to the pairing pattern, not a variant of it
45
+
46
+ **A laterality-specific `Structure of X` never gets its own laterality-specific `Entire X`.**
47
+ `Structure of X of left hand` / `Structure of X of right hand` does not pair with a minted
48
+ `Entire X of left hand` / `Entire X of right hand` — there is exactly one `Entire X`,
49
+ laterality-neutral, the same way there is exactly one `Structure of X`. Laterality is expressed
50
+ as a `Laterality` attribute value applied to the generic pair, not by duplicating the
51
+ whole-structure concept once per side. Skip the pairing check above entirely whenever the source
52
+ concept being processed is itself laterality-qualified (FSN mentions "of left/right X", or it
53
+ carries a stated `Laterality` relationship) — running the pair-mate search anyway either finds
54
+ nothing (correct, but for the wrong apparent reason) or, worse, surfaces the real generic-level
55
+ `Entire X` and risks it being wrongly treated as a duplicate-candidate for renaming.
56
+
57
+ **A laterality-only axiom is a `FULLY_DEFINED` shape, and `create-concept` will not set that for
58
+ you.** If a concept's stated axiom is exactly one Is-a (to a generic parent) plus one `Laterality`
59
+ relationship and nothing else, that combination is definitionally sufficient — SNOMED CT already
60
+ treats it as such. Confirmed against native, decades-old content: `85151006 |Structure of left
61
+ hand|` is `FULLY_DEFINED` off a stated axiom of Is-a `40983000 |Hand structure|` (itself
62
+ `PRIMITIVE`) + `Laterality` = `Left` — the *parent's* own primitiveness is irrelevant; what
63
+ matters is that Laterality is the *sole* distinguishing attribute added. `create-concept` has no
64
+ `--definition-status` flag at all — every newly minted concept starts `PRIMITIVE` regardless of
65
+ its axiom's actual shape, and nothing downstream flags a laterality-specific concept left that way
66
+ as wrong (it doesn't trip any Snowstorm convention check). If the axiom carries *any* other
67
+ relationship beyond the one Is-a and the one Laterality (an extra site, a morphology, a second
68
+ parent from the decomposition check below, etc.), do **not** set `FULLY_DEFINED` — verify the
69
+ exact shape with `get-concept --axioms` every time, then `set-definition-status --id <id> --status
70
+ FULLY_DEFINED`, and re-`get-concept` to confirm it actually changed. When fixing this across a
71
+ batch of concepts, see `SKILL.md`'s "Concurrency: one mutating caller per task branch, at a time"
72
+ — queue the calls sequentially rather than in parallel, and re-verify the whole target set
73
+ afterward with fresh `get-concept` calls rather than trusting the batch run's exit status.
74
+
75
+ ## Additional parents via decomposition — don't assume one axis is universal
76
+
77
+ A body-structure FSN is usually a composite of several semantic entities: a part/region word, a
78
+ tissue- or bone-class word, a containing structure, sometimes an articular/functional
79
+ relationship. Each entity is its own potential generalization axis, and each can have a real,
80
+ already-existing SNOMED CT concept that a concept being generalized or newly minted should also be
81
+ Is-a — beyond whatever single axis it was originally derived from.
82
+
83
+ **Evidence for any given axis has to come from the source's own real relationship history (active
84
+ *and* inactive) or from a genuine relationship between concepts already in the same batch — never
85
+ from analogy to a sibling that happened to have the axis.** A real, confirmed mistake: a
86
+ tissue-type parent (e.g. "soft tissue") was applied uniformly across several concept families in
87
+ one batch because it was correct for two of them — but wrong for others in the same batch that
88
+ had no such relationship at any point in their history (a vein family, correctly classified under
89
+ the vascular hierarchy instead) or that reached the same target only *transitively*, through a
90
+ real chain among the batch's own source concepts, making a direct link redundant on top of being
91
+ the wrong axis to reach for.
92
+
93
+ **Procedure:**
94
+ 1. Decompose the concept's FSN into its semantic entities (part/region, tissue/bone-class,
95
+ containing structure, any articular/functional relationship implied).
96
+ 2. For each entity, hypothesize a more generic categorization concept at the same specificity
97
+ level and `search-concepts` for it.
98
+ 3. For each hit, `get-concept` it and confirm it's a genuine categorization — read its own
99
+ FSN/definition, don't just accept a plausible-sounding name.
100
+ 4. Check whether two of the *current batch's own* source concepts are related to each other at a
101
+ more generic level — if so, mirror that relationship at the level you're working at too; this
102
+ is easy to miss because each source is naturally processed as an independent candidate.
103
+ 5. Add each confirmed axis as its own stated Is-a. Absence of evidence for an axis is a judgment
104
+ call, not an automatic skip or an automatic apply — don't force a categorization without a
105
+ real, confirmable target, and don't assume an axis is universal just because it applied to a
106
+ sibling in the same batch.
107
+ 6. After adding any second (or third+) parent, `classify --wait` and confirm
108
+ `equivalentConceptsFound: false` before treating the axiom as final — two parents in an
109
+ unexpected ancestor/descendant relationship, or that make two sibling concepts equivalent,
110
+ would surface here.
111
+
112
+ This decomposition check applies retroactively too, not just to concepts being minted right now —
113
+ a concept minted before this check was part of your process can just as easily be missing a real
114
+ axis that was sitting on its own source's `get-concept` output the whole time. Treat every batch
115
+ of related concepts as needing this audit, not as a one-time sweep.
116
+
117
+ ## A retrofitted relationship and a renamed/updated description are independent checklist items
118
+
119
+ When generalizing a specific concept into a broader one, the stated Is-a retrofit (the specific
120
+ concept pointing at the new broader one) and any accompanying description change (an FSN
121
+ disambiguation, a new synonym) are two **separately skippable** steps — never treat one as proof
122
+ the other happened. This risk is highest when the retrofit relationship already existed natively
123
+ in the terminology, sometimes for years, before your project touched the concept: it's easy to
124
+ reason "the relationship is already there, so this concept's work is done" and skip the
125
+ description change entirely, even though that change has nothing to do with whether the
126
+ relationship needed adding.
127
+
128
+ On a tracker or project resumed from a prior session, run a live check of the actual current
129
+ description text — not a cached/frozen value from when a tracker row was seeded — for every
130
+ concept marked complete, at least once, rather than assuming an earlier pass gave every one the
131
+ full treatment.
@@ -112,6 +112,45 @@ Either way, such a script should only ever *find candidates*, never decide fitne
112
112
  its own — keep the compound-word/idiom/cardinality judgment calls (see `SKILL.md`) as an explicit
113
113
  manual step after the script (or this flag) narrows the field.
114
114
 
115
+ ## Driving a batch of mutating calls
116
+
117
+ Queue mutating calls sequentially against one task branch; never run them in parallel, and never
118
+ delegate the batch itself to a subagent — see `SKILL.md`'s "Concurrency: one mutating caller per
119
+ task branch, at a time" for why this holds regardless of which command you're batching. The rest
120
+ of this section is the concrete driving mechanics for a large multi-session batch specifically.
121
+
122
+ - **Never run mutating calls in parallel against the same task branch.** Even a single sequential
123
+ caller can surface "branch locked, retrying" from the server's own internal locking — true
124
+ concurrent callers (multiple background loops, or an `xargs -P`-style fan-out) compound this and
125
+ have produced real, silent data loss (a call that appears to succeed but didn't land). Reserve
126
+ parallelism for **read-only** calls (a `get-concept` audit sweep) — never for
127
+ `create-concept`/`add-relationship`/`replace-fsn`/`add-description`/etc.
128
+ - **A real shell array, not an unquoted loop variable.** In zsh, `for id in $VAR; do ... done` does
129
+ **not** word-split an unquoted space-separated variable the way bash does — the loop silently
130
+ runs once with the whole string as one bogus "ID," which looks like a hang (the CLI chokes on
131
+ garbage input) rather than an obvious error. Use a real array (`IDS=(...)` / `"${IDS[@]}"`), which
132
+ is safe and is exactly the right pattern for a backgrounded batch — don't avoid arrays on the
133
+ mistaken belief that all shell-loop batch driving is equally risky; the specific risk is the
134
+ unquoted-variable word-splitting bug and true parallel execution, not arrays or backgrounding
135
+ themselves.
136
+ - **Never delegate the batch itself to a subagent.** A subagent's self-reported summary is not
137
+ ground truth — subagents have been observed to report a relationship added when none existed on
138
+ either concept, and to report an "exact match" for an ID that doesn't correspond to anything
139
+ relevant. Whoever runs the batch should drive it directly and re-verify every created/modified ID
140
+ (and every claimed pre-existing match) against live `get-concept`/`search-concepts` output before
141
+ recording it in the tracker — never trust a delegate's summary as the record of what happened.
142
+ - **Never reimplement the touched-concept list with a hand-tracked file.**
143
+ `authoring-cli get-concepts-for-review` already returns every concept with pending stated changes
144
+ on the task, flags entries created-then-deleted on the same branch (`"deleted": true` — filter
145
+ these out before validating or reporting), and needs no bookkeeping of your own. Call it fresh
146
+ whenever you need the list — for a structural self-check, a validation pass, or close-out — rather
147
+ than trusting a list assembled earlier in the session; a hand-rolled tracking mechanism drifts the
148
+ moment something gets deleted, retried, or added out of band.
149
+ - Don't let one script's early exit (`set -e` plus a transient network blip) silently truncate a
150
+ batch — check the actual per-concept completion count against the expected total before trusting a
151
+ "completed" exit status, and build retry logic for known-transient errors (socket disconnects,
152
+ "branch locked") rather than letting the whole run die on the first one.
153
+
115
154
  ## Closing out a session
116
155
 
117
156
  Report, and record in the tracker: how many created, how many skipped and why (grouped by