Skip to content

feat(cli): add a map, a précis, and a size signal (WI-P4/P5/P6)#100

Merged
tjdwls101010 merged 1 commit into
mainfrom
wi-p4-p6-context-efficiency
Jul 19, 2026
Merged

feat(cli): add a map, a précis, and a size signal (WI-P4/P5/P6)#100
tjdwls101010 merged 1 commit into
mainfrom
wi-p4-p6-context-efficiency

Conversation

@tjdwls101010

Copy link
Copy Markdown
Owner

Why

Measured live on 2026-07-19, bytes of the emitted envelope:

command bytes
load-delegated-criteria --budget standard 513,570
load-institutional-system --budget standard 396,609
get-law (139 articles) 276,748
get-case (one decision) 82,700

Nothing warned about any of it. The only narrowing tool was --article, which presumes you already know which article you want — and reading the whole statute to find that out is the expensive way to ask a cheap question.

(The bundle-loader figures were the plan's unmeasured item. load-delegated-criteria turned out to be the largest output in the package, larger than get-law.)

What

get-law --toc (P4) — chapter headings, article numbers and titles, deleted/moved status. No article text. 276,748 → 18,831 bytes (6.8%).

  • Heading rows excluded from article_count: law.go.kr threads them through the article list tagged 전문 reusing a neighbouring article's number, and counting them inflates the very number a caller uses to judge whether a full load is affordable.
  • The 제0조 move placeholder is dropped rather than forwarded — passing it through sends a caller chasing an article that doesn't exist.

--brief (P6) on cases, constitutional decisions and interpretations — blanks text/full_text, keeps the 요지. 82,700 → 14,044 bytes (17.0%). Returns the same type; a narrower one would break every consumer's field access for a difference that belongs on the envelope. flags.brief.withheld lists what was actually present, so brief mode never claims to have hidden a section the source never had.

flags.large_payload (P5) — measured on the serialized data, not guessed from a row count (139 short articles and 20 long ones differ by an order of magnitude), so it also covers commands added later. Searches are exempt: candidate breadth is what resolves ambiguity, and 20 hits already costs ~18,000 characters (§3.1 keeps display=20).

Two pre-existing defects surfaced

  1. 조문내용 nested-array repr leak. When a row carries both a 장 and a 절, law.go.kr returns a nested array; str() on it produced [['제3장 …', '제1절 …']], which travelled through get-law as if it were the statute's own wording. Wrong in a way a reader cannot detect from the output.
  2. The P8 smoke was green while covering nothing for load-legal-context-bundle — it passed a positional query where the parser wants --query, argparse rejected it, and exit 5 was in the allowed set. The smoke now rejects usage_error outright and exercises --toc/--brief as the separate dispatch branches they are.

Deviations from the plan's acceptance criteria

Reporting rather than contorting to hit them:

  • --toc lands at 18.8KB, not ~10KB. Dropping entry_kind too would still leave ~15KB; the estimate predates measuring what 139 entries cost in JSON structure. Serialization gained an opt-in _omit_when_empty which already cut 30.3KB → 18.8KB.
  • --brief lands at 17%, not ≤10%. The remaining 14KB is mostly summary (3,680 chars). Cutting it would hit the number by removing the only thing brief mode is for.

Verification

Live: full get-law fires large_payload {chars: 139078, articles: 139}; 대한민국국기법 (12 articles, 16.5KB) stays quiet; --toc renders headings correctly post-fix; --brief withholds [text, full_text].

474 deterministic tests pass (19 new).

🤖 Generated with Claude Code

…rge_payload)

Measured live: load-delegated-criteria 513,570 bytes, load-institutional-
system 396,609, get-law 276,748, get-case 82,700. Nothing warned about any
of it, and the only narrowing tool was --article, which presumes you already
know which article you want. Reading a whole statute to find that out is the
expensive way to ask a cheap question.

--toc (WI-P4) returns chapter headings, article numbers and titles, and
deleted/moved status, with no article text: 276,748 → 18,831 bytes on
개인정보 보호법, 6.8% of the full load. Heading rows are excluded from
article_count — law.go.kr threads them through the article list tagged 전문
with a neighbouring article's number, and counting them inflates the very
number a caller uses to judge whether a full load is affordable. The 제0조
move placeholder is dropped rather than forwarded, since passing it through
sends a caller chasing an article that does not exist.

--brief (WI-P6) blanks text/full_text on cases, constitutional decisions and
interpretations, keeping the 요지: 82,700 → 14,044 bytes, 17.0%. It returns
the same type — a narrower one would break every consumer's field access for
a difference that belongs on the envelope. flags.brief.withheld lists what
was actually there, so brief mode never claims to have hidden a section the
source never had.

large_payload (WI-P5) is measured on the serialized data, not guessed from a
row count: 139 short articles and 20 long ones differ by an order of
magnitude, and a size check written against real output keeps working for
commands added later. Searches are exempt — candidate breadth is what
resolves ambiguity, and 20 hits already costs ~18,000 characters.

Two defects surfaced while building this, both pre-existing:

- 조문내용 arrives as a nested array when a row carries both a 장 and a 절,
  and `str()` on that produced `[['제3장 …', '제1절 …']]`, which then
  travelled through get-law as if it were the statute's own wording. Wrong
  in a way a reader cannot detect from the output.
- The P8 smoke passed load-legal-context-bundle a positional query when the
  parser wants --query, so argparse rejected it, exit 5 was in the allowed
  set, and the case was green while covering nothing. The smoke now rejects
  usage_error outright, and exercises --toc/--brief as the separate dispatch
  branches they are.

Serialization gains an opt-in `_omit_when_empty`. Present-but-null is
normally the right default — it tells a consumer the concept exists and is
unset — but on a 139-entry map the placeholders outweighed the content.

Note: the plan's ~10KB target for --toc is not met at 18.8KB. Reaching it
would mean dropping entry_kind and still landing at ~15KB; the estimate
predates measuring what 139 entries cost. --brief lands at 17% rather than
the planned ≤10% because the remainder is mostly summary, and cutting 요지
would remove the only thing brief mode is for.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tjdwls101010
tjdwls101010 merged commit 27d2635 into main Jul 19, 2026
5 checks passed
@tjdwls101010
tjdwls101010 deleted the wi-p4-p6-context-efficiency branch July 19, 2026 13:55
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.

1 participant