Skip to content

feat: bound and summarize get node output - #75

Merged
sergej-koscejev merged 6 commits into
mainfrom
issue-48-get-node-depth
Oct 22, 2026
Merged

sergej-koscejev merged 6 commits into
mainfrom
issue-48-get-node-depth

Conversation

@sergej-koscejev

Copy link
Copy Markdown
Member

Closes #48

Summary

get node gains bounded views and readable output. The full Node Subtree stays the default.

 mops get node [--ancestry] NODE_REF
+  --depth N     N levels exported in full, level N as Node Stubs, top-level truncatedAt: N
+  --summary     find-style summary + children: {role: count}, no subtree
+  --compact     single-line JSON (pretty-printed by default)
+  stderr hint when an unbounded export exceeds 16 KB compact

Export shape with --depth 1:

{ model, concept, id, truncatedAt: 1, parent, properties, references,
  children: [ { role, concept, name?, reference, childCount }, ... ] }

Daemon side: ModelGetNodeRequest.depth flows into JsonNodeExporter, which recurses with a remaining depth (0 drops
children, 1 emits stubs); --summary is its own request pair (model-get-node-summary) built on the nodeSummary
that find and check already use. Both node commands get a customSynopsis so --help shows one line per positional
form.

Evidence

  • Before: get node printed one ~43 KB line; get node --help showed NODE_REFERENCE | MODEL_TARGET NODE_ID [NODE_REFERENCE | MODEL_TARGET NODE_ID].
    After: GetNodeSemanticsTest (stubs at depth 1 and 2, truncatedAt, depth 0, summary counts and ancestry),
    ModelGetNodeCommandTest (pretty default, --compact byte-identical to the old output, option validation, stderr
    hint present/absent), DaemonProtocolJsonTest (round-trips, compact encoding unchanged), CommandHelpTest (synopsis).
    :protocol:test :daemon:test :cli:test green; integrationTestMps2026.1.1 for CliSmokeTest and
    BundledExamplesIntegrationTest green; :cli:updateExamples leaves the tree clean.

Decisions

  • Stubs are MpsNodeJson instances with only role, concept, conceptValid, name, reference, and childCount set; no separate stub type, so the children list stays homogeneous and data-class equality keeps working in tests.
  • Stubs carry reference (not the spec's ref), matching parent.reference, find output, and list --json, which all spell the serialized node reference as reference.
  • Stubs also carry role, like every other child entry, so a consumer knows which containment role the stub sits in.
  • --depth N means N levels below the target are exported in full and the nodes at level N are stubs; --depth 0 exports the target with no children key at all and truncatedAt: 0.
  • truncatedAt is placed before parent in field order so head shows it; default output is unaffected because the field is omitted when null.
  • --summary reuses the find/check summary vocabulary (MpsNodeSummaryJson: type, name, concept, reference, parent) and adds children: {role: count}; it is a separate request/response pair (model-get-node-summary) rather than an MpsNodeJson whose children changes shape. It is therefore not literally --depth 0 sugar: it lacks model, id, properties, references, and truncatedAt.
  • Summary child counts are keyed in first-appearance order of the roles among the node's children.
  • --summary and --depth are mutually exclusive (same rule as list); --ancestry combines with both.
  • Pretty output uses two-space indentation.
  • The size hint fires when the compact UTF-8 encoding exceeds 16 * 1024 bytes and reads mops: this node is N KB of compact JSON; pass --depth N or --summary for a bounded view; the compact form is encoded for the measurement even when the pretty form is printed, because the threshold is defined on it.
  • The size threshold is covered by a CLI unit test with a synthetic large node; in test-projects/base-language-sandbox the largest export (the Calculator class) is 8 KB compact, so no fixture reaches the threshold and there is no fixture-based threshold test (the spec's premise about that project does not hold).
  • The get node/render node synopsis is fixed with picocli customSynopsis as mops get node [OPTIONS] NODE_REFERENCE / ... MODEL_TARGET NODE_ID (the full option list would wrap at 80 columns), plus hideParamSyntax so the positional row in the parameter list is readable; the help-layout rework in Show subcommands near the top of help output #52 is left alone.
  • --depth is validated as non-negative with no upper bound, unlike list, since a large depth simply degrades to the full export.
  • GLOSSARY.md gains Node Stub; skills/mops/SKILL.md recommends --summary/--depth first on nodes that may be large.

Merge Danger

Door: two-way

Revert restores the previous single-line output; no persisted data changes.

Blast Radius: output-format

get node stdout is now multi-line by default. Scripts that parsed it as one line need --compact, which is
byte-identical to the previous output. MpsNodeSummaryJson gains an optional children field that find and check
never populate, so their output is unchanged.

@sergej-koscejev sergej-koscejev changed the title Bound and summarize get node output feat: bound and summarize get node output Oct 17, 2026
@sergej-koscejev
sergej-koscejev force-pushed the issue-48-get-node-depth branch 3 times, most recently from 848fdd9 to e51074a Compare October 22, 2026 09:41
@sergej-koscejev
sergej-koscejev enabled auto-merge (squash) October 22, 2026 11:32
@sergej-koscejev
sergej-koscejev force-pushed the issue-48-get-node-depth branch from 5f37a85 to 4938b3c Compare October 22, 2026 15:17
@sergej-koscejev
sergej-koscejev merged commit 4bb1171 into main Oct 22, 2026
11 checks passed
@sergej-koscejev
sergej-koscejev deleted the issue-48-get-node-depth branch October 22, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bound and summarize get node output

1 participant