Skip to content

feat!: cli-core 1.0.0-rc.0, the stable API, store version 73 and the 1.0 fixes - #3288

Closed
leemour wants to merge 48 commits into
mainfrom
release/1.0-pr
Closed

leemour wants to merge 48 commits into
mainfrom
release/1.0-pr

Conversation

@leemour

@leemour leemour commented Nov 24, 2026

Copy link
Copy Markdown
Member

Task

Land cli-core 1.0 on main as 1.0.0-rc.0: the stable API, store version 73, the 1.0 fixes and the release rules, in one pull request on top of 0.740.0.

Why

cli-core moves to real semver. A stable core is listed in package.json (wirecat.stable, ten entry points), and the rest is experimental. This needs cli-base 1.0, and it changes the store, so every CLI adopts it on a release/1.0 branch of its own. The work landed on release/1.0 from several sessions. This branch is that work rebased onto main, plus the gaps the consumer branches found.

Not released yet. main names 1.0.0-rc.0 with an empty changelog section. bin/release --major --app-ref release/1.0 collects changes/ into it and publishes on npm's next tag. Without the bump, the next release from main would publish these breaks as 0.741.0 on latest.

What

From release/1.0 (rebased, one conflict resolved: src/cli/documents/manifest/source.ts keeps main's isCliError and takes codegen/runtime):

  • the stable set (wirecat.stable, @experimental inside stable entries, MessageStoreCore/MessageStoreAreas), ./store without the SQLite implementation, ./store/areas;
  • store version 73, including the fixes after the check on a real store: references already broken stay, a refused run removes its rollback copy, and a copy that changes a table's row count stops the migration;
  • the 1.0 correctness and security fixes (one real-path check for every local path an MCP call names, --rescan keeps the mass-deletion guard, and others);
  • the release rules: seven changelog headings, levelled versions, --major, the next tag; every error reason in docs/reasons.md, checked as a contract;
  • parity builds all 19 CLIs on a release.

Added here:

  • API report: api/, written by cli-base 1.0.0-rc.0's cli-dev api-report. CI checks it from now on.
  • Workflows: every cli-base reusable workflow pinned to v1.0.0-rc.0. The changelog guard runs on label changes too, and scripts/changelog-shape.ts takes cli-base's CHANGELOG_HEADINGS.
  • ./internal/*: every module's types can be named here, types only.
    • A CLI that inferred a type cli-core returns failed its declaration emit with TS2883, since TypeScript names a type only through an entry point already in the program.
    • A probe calls every exported function of each of the 51 entry points, each compiled on its own: 127 errors before, 0 after.
    • Node refuses a runtime import of the path.
  • notLocalPaths: exported from ./cli (experimental), so a CLI can mark its own remote path inputs.
  • catalog tree [folder]: the folder is the provider's id, not a local path.
  • ./store/areas: exports crmSettingKey and crmIdentityId, which amo-cli and bitrix24-cli import at run time.
  • Reasons: the four reasons store version 73 raises, and main's new OCR and deletions-feed reasons, are in docs/reasons.md.
  • Stable set: plainSetupText (new on main, no importer) is tagged experimental.
  • known-broken.json: max-cli and mail-cli leave it; both adopted the change on their release/1.0 branches.

Testing

  • Local: typecheck, lint, docs:check (reasons included), schema:check, check:dist, check:agent-process, help:examples, api-report --check.
    • Tests of the touched files, each run alone: path options, setup text, the changelog and version scripts, store version 73, reasons, the manifest source.
    • The full suite was not run locally. The machine was overloaded (load average above 40), so CI judges it.
  • Parity: the dispatched run is the real result: https://github.com/WireCatLabs/cli-core/actions/runs/45320991902 (app_ref=release/1.0, tests=true, all 19 CLIs).
    • This PR's own parity check is expected to fail. It builds the 7 PR consumers from their main, which is still on cli-base 0.x and the old store imports; their adoption is on release/1.0.
    • If branch protection requires that check, the PR merges with --admin once the dispatched parity run and the rest of CI are green, with a comment saying why.

Known follow-up (after rc.0)

About 270 types that stable functions in ./cli take or return are exported from no entry point. With ./internal/* they can be named, but they are not under semver, and a change to them does not show in the API report. A later pass decides which of them become stable exports.

Downstream

Each CLI moves to cli-base 1.0.0-rc.0 and changes its imports from ./store to ./store/areas where it uses them (the list is in changes/1.0-surface.md). cli-memo imports assertSharedContracts from @wirecat/cli-base/commands.

🤖 Generated with Claude Code

@leemour leemour added the major A stable break: waits for a major the owner chose (WC-REL-7) label Nov 24, 2026
@leemour
leemour force-pushed the release/1.0-pr branch 3 times, most recently from c0aa5be to 3447eb9 Compare November 24, 2026 21:30
leemour added a commit that referenced this pull request Nov 25, 2026
The owner chose to keep bots apart from people: a bot in its own table
cannot be proposed as the same person, assigned a task or counted as
known, so no list has to remember to skip it. The sender field goes; reach
and tie stay on persons and bots. Identities move between a person and a
bot, logged, with the owner's choice winning. The order of work now starts
with signals that need no store change, and the bots migration waits for
the 1.0 store version 73 (#3288).

Refs #3314

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour added a commit that referenced this pull request Nov 25, 2026
#3333)

## Task
tg-cli [#917](WireCatLabs/tg-cli#917):
`messages sync` falls from about 75 to 7 messages/s as a big group fills
the store.

## Why
`upsertMessage` ran `UPDATE messages SET thread_root_id=? WHERE
chat_id=? AND thread_external_id=? AND thread_root_id IS NULL` for every
saved message. No index covers `thread_external_id`, so the plan is
`SEARCH messages USING INDEX messages_by_time (chat_id=?)`: a scan of
the whole chat per message. The CPU profile put 85% of the save time in
this SQL.

## What
- `linkThreadChildren` runs that link once per `saveMessages` call, for
all the page's ids (`json_each`). The phone projector calls it for its
one message.
- No migration. The index that removes the remaining scan, `(chat_id,
thread_external_id) WHERE thread_root_id IS NULL AND thread_external_id
IS NOT NULL`, goes into store version 73 with 1.0 (#3288), agreed with
that session.

## Testing
Benchmark: one chat, 100-message pages saved top-down through
`saveMessages` + `markRange`, database on tmpfs. Save time per page:

| stored | before | after |
|---|---|---|
| 10k | 78 ms | 32 ms |
| 30k | 294 ms | 37 ms |
| 60k | 593 ms | 42 ms |
| 90k | 919 ms | — |

The "after" run was on a machine at load average 25. Full write-up to
follow in cli-testing.
- New assertion in `src/store/messaging.test.ts`: a reply and its root
saved in one page are linked.
- `vitest run src/store/messaging.test.ts`: passes. `batches.test.ts`
and `refill.test.ts` time out locally at that load **with and without**
this change, so CI decides.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
leemour added a commit that referenced this pull request Nov 25, 2026
… headers (#3334)

## Task

Slice 1a of the contact-kinds plan ([plan PR
#3323](#3323), not merged).
It builds plan steps 2 and 3 in a read-only form: nothing new is stored
on `persons`. Part of #3314.

## Why

Service mail shows up under Strangers. An example is a bank's statements
from an address with no no-reply word. The mail itself says a program
sent it (`Auto-Submitted`, an empty Return-Path) or that it went to a
list (one-click unsubscribe, `Feedback-ID`). Until now the store did not
keep these headers.

Coordinator decisions for this slice:
- **No migration.** #3288 (1.0) keeps store version 73. Storing
`sender`/`reach` waits until it merges.
- **No `sender`/`reach` columns.** Bots may become an entity of their
own; the owner is deciding that.

## What

- **Mail headers** (`src/mail/headers.ts`). `mailHeadersOf` now also
keeps three headers in `emails.headers`: `auto-submitted` (unless `no`
or `auto-replied`), `list-unsubscribe-post` (one-click only) and
`feedback-id`.
- Each is kept only when a DKIM signature that Gmail's `mx.google.com`
stamp passed covers that header, and the signature's domain has the
From's registrable domain (`signedFieldsOf`, reuses `registrableOf`).
- An empty Return-Path is kept as `null-return-path`, unless the mail is
an auto-reply: an out-of-office makes no bot.
  - No store version: these are JSON keys.
- **Gap, documented in MAIL.md.** Only Gmail's own stamp is trusted.
Mail from an IMAP server never keeps the three signed headers.
- **`people.list` rows** get `reach` (`direct`, `group`, `broadcast` or
`null`) and `signals`. Both come from
`src/store/sqlite/sender-signals.ts`: a pure `senderSignalsOf` plus
`sentMailOf`, a query for the page's people. They are worked out for the
returned page only and never stored.
- **Kind.** A signed `Auto-Submitted` or an empty Return-Path on most of
a sender's mail makes them `automated` (new `KindSignal`s), unless the
owner wrote to them. `KIND_RULES` goes from 5 to 6, so stored kinds are
worked out again. Everything else is unchanged.

Defaults chosen for the plan's open questions:
- **Q2, mixed sender.** One sender. The reach most of their mail had
wins, the wider on a tie. Mail the owner wrote them, or a private chat
both wrote in, makes it `direct`.
- **Q3, discussion lists.** A List-Id that 3 or more addresses send to
(`+tag` aside) is `group`. One sender is a newsletter, `broadcast`.
- **Owner's position.** Only "no To or Cc at all" counts as `broadcast`.
The owner missing from a To/Cc that names others proves nothing, because
an alias the store does not know looks the same. The position comes from
`email_recipients`, which already holds every To/Cc, so old mail counts
too.

Notes for the re-plan:
- **PERF.** On a page with List-Id mail, `sentMailOf` reads every stored
email's List-Id. There is no index, and adding one needs a migration. A
follow-up for the stored version.
- **Inconsistency, existing behaviour.** A discussion-list member can
have `reach: group` and still be `kind: automated` through today's
`bulk-mail` rule. It is left as it is on purpose.
- **Downstream.** cli-memo only reads `ListedPerson` and `kindSignals`.
The widened union is listed under "Changed — may break callers".

## Testing

All with `--maxWorkers=1`:
- New: `src/mail/sender-signals.test.ts` (sync through the fake mail
source to the people list, 3), `src/mail/headers.test.ts` (5),
`src/store/sqlite/sender-signals.test.ts` (3).
- Existing: people-list, people-kinds-stored, person-doubts,
people-matching-rules, mail/score, mail/own (86 passed); mail/sync,
store/mail, mail/rules, sender-scores, probe, mail/cli (135 passed).
- `pnpm typecheck`, `pnpm ci:quick`, `pnpm schema:check`, `pnpm
docs:check`, Biome on the changed files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
leemour and others added 19 commits November 25, 2026 03:06
…, read commander internals in one place

- Remove searchAllIncludingMeetings and its five types, SyncOptions.limitError and
  MeetingTranscriptDocumentStore.transcriptMeetings. No downstream CLI names them on main.
- Peer ranges: @wirecat/cli-base ">=0.125.0 <1.0.0 || ^1.0.0-0" so cli-base 1.0 can come
  first; commander "^15.0.0" instead of ">=15".
- src/cli/commander-internals.ts is the only reader of commander fields with no public
  accessor (_actionHandler, _hidden, _getHelpOption, unknownOption). It is not exported
  from any entry point; its test fails when a commander release renames one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
./store pointed at src/store/index.ts, the barrel cli-core's own modules use, so every
row type, query constant and maintenance helper under src/store/sqlite/ was a public
promise. ./store now points at src/store/public.ts: the same barrel without the ~390
names declared under src/store/sqlite/, except StoreOptions, which openStore takes.

The 76 of those names that downstream CLIs import on main (mostly cli-memo; also
drive, mail, zoom, beeline, notion) are re-exported from the new experimental entry
./store/areas under the same names. src/store/index.ts is unchanged for internal use.

Checked with a TypeScript probe that copies dist away from drizzle-orm: no exported name
of any entry has a member whose type fails to resolve (depth 5), before or after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…te ids

About 120 references to a private journal (NEED-…, SEC-…, BUG-…, FIND-…) sat in doc
comments that tsc copies into the published .d.ts files, where readers cannot resolve
them. Each is removed where the sentence already says why, or replaced by the plain
reason. Plain // comments, which do not ship, are unchanged.

docs:check now fails when a built .d.ts carries such an id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rks the rest inside them

package.json lists the stable export subpaths in wirecat.stable: ".", ./cli, ./cli/start,
./mcp, ./sends, ./skill-validation, ./sqlite-runtime, ./store, ./testing and ./update.
Every other entry point is experimental as a whole.

Inside them, about 990 declarations carry @experimental: the values fewer than two CLIs
import on main (cli-template counts as all of them), and the types no stable name reaches.
MessageStore stays stable in accounts, chats, messages, people, tags and close; its other
56 areas are tagged, as their family entry points are experimental.

MessageStore moves into src/store/message-store.ts (store.ts was at the 500-line cap), and
./cli stops re-exporting five cli-base names no CLI imports from it.

README and REFERENCE describe the 1.0 promise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mental MessageStoreAreas

cli-base's api-report reads @experimental on whole declarations only, so tags on
MessageStore's members left all 62 areas in the stable snapshot. The six stable members
(accounts, chats, messages, people, tags, close) now form MessageStoreCore; the rest form
MessageStoreAreas, tagged @experimental. MessageStore extends both, so callers that name it
change nothing. Checked with cli-base's release/1.0 cli-dev api-report: the store report
keeps MessageStoreCore and leaves MessageStoreAreas out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…able part

./codegen is experimental in cli-base 1.0, and cli-core's stable types must not name
experimental codegen types. Every src import of manifest types, identifier, the sign-in
helpers, graphqlDocument and parseSelection now comes from @wirecat/cli-base/codegen/runtime.
The test fakes (fakeApi, graphqlFake, sampleOf) stay on ./codegen; they are used only by
the experimental crm/testing and tracker/testing entries and by tests.

Needs cli-base 1.0.0-rc.0: the peer range becomes ^1.0.0-0, and the cli-base dev
dependency must move to the rc when it is on npm (typechecked here against cli-base's
release/1.0 worktree through a local, uncommitted link).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ext tag

- The changelog and its fragments accept cli-base's seven headings: `Changed — experimental` and
  `Deprecated` join the five. The list is local until cli-core takes a cli-base that exports all seven
  (released 0.132.0 has five), in cli-base's order, which fragments are collected in.
- scripts/next-version.mjs takes the repository root as an optional fourth argument. It then builds the
  section the release will publish, fragments included, and raises the version to the level its headings
  need with cli-base's levelledVersion: after 1.0.0 a stable break (`Changed — may break callers`,
  `Removed`) becomes a major. Without the root it answers as before, which ci.yml's version job relies on.
  A taken x.y.0 still steps the minor, since package.json keeps the last release's number.
- bin/release passes the root, says when the headings raised the number, and stops on a version that
  raises the major over npm's latest unless `--major` is given.
- A pre-release publishes under npm's `next` tag, from bin/release --local and from release.yml (dry
  run and publish), as cli-base does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tract

REFERENCE.md named 5 of the 613 reasons cli-core raises. A caller that matches on a reason had no list
to match against, and nothing stopped a reason from vanishing in a release.

- scripts/reasons-docs.ts writes docs/reasons.md's table from the built REASONS (CORE_REASONS): reason,
  code, one-line meaning and detail keys, sorted. `pnpm reasons:docs` writes it; `--check` runs in
  `pnpm docs:check` and fails when the page and src/errors/reasons.ts disagree.
- The committed page is the baseline, so no git history or tag is needed in CI. A listed reason that is
  gone, or that moved to another code, blocks both the check and the writer until a changes/ fragment
  names it in backticks under "Changed — may break callers" or "Removed". A rename is a removal plus an
  addition.
- The page says what may change: new reasons and reworded messages in any release, a removal or a
  recode only as a break (a major from 1.0.0 on). Every reason counts as stable for now; marking some
  experimental is left to the stable/experimental markers when they land.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…itution

Shellcheck (SC2046) flagged the $(case …) form copied from cli-base. The tag is now a variable:
next for a pre-release, latest otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n pull requests

Parity covered 9 of the 19 CLIs that depend on cli-core, so a break in amo, asterisk, attio,
beeline, hubspot, linear, notion, slack, wordpress or ydisk showed up only when that CLI bumped.

- downstream.json lists all 19 public consumers (cli-template keeps its own job). `cli` is the file
  name under dist/bin/: `slack` for slack-cli's `slk`, `pbx` for asterisk-cli. ydisk's repository
  is ydisk-cli.
- A release (`tests`), the monthly run and a run by hand build, typecheck, start, generate and, on a
  release, test all of them. A pull request and a push to main build the 7 marked `"pr": true`:
  tg, max and wa (the manifest and wording jobs read their builds), memo, mail, drive and attio
  (a CRM built from a config). Before, a pull request ran 9 legs; now 7, and a release 19.
- downstream-result.sh sums the list the matrix ran (CLIS from downstream-list), so a leg left out
  on a pull request is not reported as "no result". Without CLIS it reads the whole file, as
  bin/downstream-check does.
- Not listed: cli-docs (the website, no CLI, pinned to 0.590.0) and cli-testing (a benchmark
  subpackage).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ule exec leaving MCP

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onnect change

ydisk-cli joins the downstream list with this branch, and its main does not compile against
cli-core: #3234 made FileConflictCommands.connect take the body, and src/commands/mirrors.ts:935
still returns the connection. Listed until 2026-11-30, as the other #3258 adopters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
INT-1 from the 1.0 review. A run asks SEARCH for a folder's UIDs, then
the listing (FETCH) for those UIDs. When the server left one UID out of
its FETCH answer, a run without a budget (memo's timer, a script) did not
compare the two: the message was missing from what the run saw, and the
deletion proof marked it deleted, dropping its text, attachment text,
chunks, vectors and places. Up to 4 messages per run, or under 20 %,
passed the mass-deletion guard.

The search had just shown the message is there, so it is "not seen
this run", not "deleted at the source". Now any folder whose listing
returned fewer UIDs than its search found skips the deletion check for
the run, budgeted or not, before the location-based proof and the
full-window proof. The run says why in deletionsSkipped.

Case from the review: 10 stored mails, the second run's server drops
UID 103 from FETCH once; before, deleted === 1; now 0, and the mail
keeps its text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a gap is held

INT-4 from the 1.0 review. In the CRM, tracker and content syncs,
--rescan did two things: it listed everything again, and it switched off
the guard that holds an id pass which would mark most of a kind deleted
(an empty list, or more than half of ten or more stored rows). --rescan
is also the advice for unrelated problems (a stuck round, a changed
scope), so an agent running it during a rights outage let a 90 %
"deletion" through.

Now --rescan only lists again. The one way past the guard is the
owner-only --allow-deletions <count> (allowDeletions in syncCrm,
syncTracker and syncContent): a held pass goes through when it would
mark at most that many rows deleted, and the held message names the
number. The flag name and type come from cli-base's flag catalogue,
where file mirrors use it the same way. Being owner-only, MCP servers
do not offer it. The content sync's "the site's address changed" hold
still lifts with --rescan: that is a scope change, not the guard.

INT-3 from the 1.0 review. The CRM id pass marked rows deleted even when
the adapter had reported, through context.gap, that it could not read the
whole kind (a Bitrix24 or amo sign-in that lost rights to one pipeline).
2 of 12 deals, or 400 of 1,000, is under the 50 % guard, so those deals
were marked deleted and the digest and stage tasks reported them gone.
The tracker engine already held such a pass; the CRM engine now does
too, and no flag lifts it. Both engines also keep the mark in the pass
state, so a gap reported in an earlier run of a pass that spans several
runs still holds it.

Cases from the review, now tests:
- 12 deals stored; next day the adapter reports a gap for deals and
  leaves out d3 and d4: before, unlisted === 2; now the pass is held,
  also with rescan and allowDeletions, and a whole list later marks the
  two (src/crm/sync.test.ts).
- crmSyncContract, contentSyncContract and the tracker test: a list that
  would mark most rows deleted stays held under rescan, and
  allowDeletions with the named count lets it through.

BREAKING CHANGE: sync --rescan no longer marks most of a kind deleted;
pass --allow-deletions <count>. The kits' contracts check this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le feed event is not marked deleted

INT-2 from the 1.0 review. When a recurring series was deleted between
the round's listing and its occurrences() call, the provider answered
not_found (Google events.instances answers 404/410 then, per its docs).
The error failed the calendar, the round stayed in progress, and every
later run resumed it and failed on the same series first: the cursor
never moved, markUnseen never ran, and the daily full round never
started, until the owner happened to run --rescan.

Now a not_found from occurrences() keeps the series' stored slots as
they are (slots: null, counted as seen), drops the series from the
round, and the round ends. The slots are not cancelled on that signal
alone: the next listing, which names a deleted series, cancels them.

INT-6 from the 1.0 review. readFeed dropped from its entries an event it
could not read (an RRULE the expander refuses, or Outlook's usual
TZID=Customized Time Zone), and the next full round, not seeing it,
marked it and its slots deleted although the feed still held it. Now
readFeed names those UIDs, the ICS source returns them in the new
ChangePage.kept, the round keeps them, and markUnseen leaves them and a
kept series' slots alone (a new optional { keep, dryRun } argument).

The calendar engine also had no share guard, unlike mail, CRM and
tracker: a valid but empty VCALENDAR (a provider glitch) marked the
whole calendar deleted. A full round is now held when it saved nothing
at all, or would mark more than half of ten or more stored entries
deleted. The round still ends; the result's held says why and names
sync --allow-deletions <count>, the owner-only flag the other syncs
use, now on calendar sync too.

Cases from the review, now tests:
- a series whose occurrences() throws not_found: the round completes,
  the cursor holds no round, the slot stays (src/calendar/sync.test.ts);
- an event that parsed once and later uses TZID=Customized Time Zone
  stays live (src/calendar/feeds.test.ts);
- an empty feed marks nothing until --allow-deletions 100
  (src/calendar/feeds.test.ts);
- 12 entries, 8 dropped: held, then allowDeletions: 8 marks them
  (src/calendar/sync.test.ts).
The calendar sync contract's deletion case keeps a second entry, since a
full list that returns nothing is now held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ames

DEBT-2 from the 1.0 review. Each command guarded its own file inputs:
upload and send paths, attachment folders, store backup, document
mirrors. A new option that took a path had no guard until someone
remembered to add one, and several existing ones (commands' paths,
mirror folders, conflict and version paths) had none for agents.

Now program.ts runs refuseAgentPaths in preAction for every MCP call
(options.agent). It takes each option whose placeholder names a file or
folder, and each argument named so, on the command and its parents,
resolves it to its real path (so neither a link nor .. gets past), and
refuses it with permission_error when refusedPlace says no: a
credential folder, a folder of this or another WireCat tool, /proc,
/sys, /dev, or the store and its -wal/-shm. Defaults the command chose
are not checked, nor "-" or URLs. store backup and store restore may
still name the store's own backups folder (inStoreBackups).

Inputs named like a path that name no local file (a remote disk path, a
chat folder's title, a command path) are declared with notLocalPaths on
the command or its group. Serve's relay used its own copy of the path
patterns to make paths absolute against the client's folder, and so also
rewrote those remote names; it now uses the same declarations.

Owner runs from a shell are unchanged, and the commands' own checks stay.
An MCP refusal of attachments extract --output-dir or --from-dir now
answers permission_error, not validation_error.

Tests (src/cli/path-options.test.ts): credential folders by option and
argument; a link and ..; own, other-tool, WireCat folder, store, -wal and
/proc; defaults, URLs and not-local inputs; the backups allowance,
including a link and .. out of it; serve keeps a folder title; the
program refuses an agent's store backup into .ssh but not the owner's;
and a lint over the command trees that fails on any input named like a
path that is neither checked nor declared not local.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The changelog fragment for INT-1, INT-2, INT-3, INT-4, INT-6 and DEBT-2
from the 1.0 review: what may break callers, what is fixed, and the
agent path check, worded without the ways around the old checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tside the call

A path option's value from an environment variable or a config file is the
owner's, not the agent's: an MCP server started with such a variable that
points into a WireCat folder would otherwise refuse every call. Only values
the call itself named (source cli) are checked, as argv-log already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crm.unlisted-held and tracker.unlisted-held no longer name --rescan as the
way through; the page is generated from src/errors/reasons.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour and others added 19 commits November 25, 2026 03:07
…al path

The agent path check made a remote folder id absolute against the client's folder over MCP, since
only <file> was marked. The test that keeps remote inputs off the local list now covers catalog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… cleans up a refused run

A copy of a real store (schema 72, 4.4 GB) was refused by version 73: 44 rows in
emails and email_recipients already pointed at deleted rows, and the check after
the table copies counted them as if the copy had broken them.

- rebuild.ts runs foreign_key_check on the tables to copy before the copy as well
  as after, and refuses only references that are new, by (table, rowid, parent,
  referring columns). The old ones are kept as they are, named in a warning by
  table, column and ids, and saved in store_settings as
  migration:<version>:broken-references. A refusal says the migration would break
  these references, names them, and says the older tool still opens the store.
- migrateLocked deletes the rollback copy its own attempt wrote when the migration
  is refused or fails; older copies in backups/ stay. Each retry used to leave
  another 1.6 GB file.
- version-73.ts seeds counters from integer ids only. On the same store one email
  row holds text in account_id and from_identity_id; SQLite sorts text above every
  number, so max() returned it and the accounts and identities counters were left
  NULL.
- The counters are written as integers: node:sqlite binds a number as a double, and
  101 of the 105 seq values on that store were REAL.

On a fresh copy of that store the migration now succeeds in 345 s, warns about
the 44 rows, and every counter is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…igration

The foreign key check after a table copy looks only at the copied tables' own
references. A copy that dropped parent rows would break the references other
tables hold to them, and only a whole-file foreign_key_check (minutes on a 4.4 GB
store) would see it.

beforeRebuild now counts each copied table's rows, and afterRebuild counts them
again after the rename, inside the same transaction. Any difference refuses the
migration (store.rows-lost), naming the table and both counts, and says the older
tool still opens the store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
store.unknown-columns, store.rows-break-checks, store.foreign-keys and store.rows-lost were raised
but missing from REASONS, so docs/reasons.md left them out and callers could not rely on them.
They sit in their own file, as the SFTP ones do: reasons.ts is at the file length limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s only

A CLI that inferred a type cli-core returns failed declaration emit with TS2883: the .d.ts reach
types through modules no export path leads to, such as dist/store/index.js, which was ./store before
the stable split. TypeScript names a type only through an entry already in the consumer's program, so
exporting each type from ./store/areas fixed nothing for a CLI that imports only ./documents.

A probe that calls every exported function of each of the 51 entries, one program per entry, and
keeps the result with an inferred type: 127 TS2883 errors before, 0 after. The path has only a types
condition, so Node refuses a runtime import of it (ERR_PACKAGE_PATH_NOT_EXPORTED).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both adopted schedule exec leaving MCP on their release/1.0 branches, which parity builds for the
1.0 release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rebase onto 0.740.0 dropped it. bin/release --major collects changes/ into it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n added

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amo-cli and bitrix24-cli import them at run time from ./store, which no longer re-exports
src/store/sqlite, and ./store/areas had left them out. The changelog no longer says no CLI imports
the five cli-base names ./cli dropped: cli-memo imports assertSharedContracts, and takes it from
@wirecat/cli-base/commands instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Store version 73 added the option; the manifest check of tg, max and wa refused it as a row the
manifest lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- rollback copy: a failed migration now deletes the copy it took (bd1aaf9), so the test
  expects no copy instead of a whole one.
- meeting preparation: oversized metadata is valid JSON, since version 73's CHECK refuses text
  that is not.
- connection waits: the store is built before the clock starts. A new store runs all 73
  migrations, about 0.5 s more on a CI runner, which is not the close wait the test measures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… copying them

A store new in this run reached version 73 with a hundred empty tables and copied each one, and
its hundred renames were most of the cost: version 73 took about 580 ms of a new store's
migrations on this machine (all 73: 780 to 1030 ms). Each empty table is now dropped and created
under its own name; a table with rows (the seeded bots, persons and pipelines) is still copied, and
an existing store keeps every copy drizzle-kit wrote. Version 73 now takes about 100 ms, all 73
migrations 360 to 720 ms, measured alternately on the same build at a load average near 20.

The new test checks that such a store took the short path and has the schema and rows of one
copied from 72.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng an id

The comment ships in the .d.ts, where docs:check refuses internal ids since the 1.0 surface work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… CLI file within its line limit

Merging --allow-deletions from the 1.0 branch with --embed from main put src/crm/cli/index.ts 3 lines over its
1,010-line exception. The flags get a named type, and signal, rescan and allowDeletions pass as plain optional values
(syncCrm reads each as optional), which saves 7 lines. The exception rises by the last 2 to 1,012.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reasons page lists document.scan-unturned

messengerSessionCommands (#3304) landed in ./cli after the stable set was drawn; no CLI imports it yet, so it is
experimental like the other new shared commands. docs/reasons.md is regenerated for the reason #3310 added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebasing 1.0 onto 0.751.0 brought reasons.ts to 1005 lines, over Biome's 1000. The store's
open, write and recovery reasons join the migration ones in store-reasons.ts. docs/reasons.md
gains the three reasons main added (crm.activities-unlisted-held, identity.not-a-person,
tracker.kind-unread).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Asked by tg-cli (#917, cli-core #3333): linking replies to their thread runs once per page with
WHERE chat_id = ? AND thread_root_id IS NULL AND thread_external_id IN (...), a scan of the
chat without this index. With it, a page saved in 19 to 25 ms up to 40,000 messages in that
session's benchmark. It goes inside v73, which no release carries yet, so stores take one
migration for 1.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…generator names it

schema:check failed on #3288: schema.ts is checked against scripts/schema/spec.mjs, which lacked
the index. It is now in the spec, named messages_by_chat_id_thread_external_id as gen-schema
names it, and docs/storage/schema.md lists it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour

leemour commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Merging with --admin. The PR's own parity jobs build each CLI from its main, which cannot build against 1.0, so they fail as expected. Parity against the CLIs' release/1.0 branches, tests included, passed on this branch after the rebase onto 0.753.0: https://github.com/WireCatLabs/cli-core/actions/runs/45530944763 (drive-cli passed on a rerun of a 5 s timeout). The head after that run, 45e3150, only puts the v73 thread index into the schema spec; this PR's own CI, test shards and schema check included, passed on it.

@leemour

leemour commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Replaced by #3338: the same commits from release/1.0, so its parity builds the CLIs' release/1.0 adoption branches. Main's ruleset has no bypass, so this PR's parity against the CLIs' main blocked the merge.

@leemour leemour closed this Nov 25, 2026
leemour added a commit that referenced this pull request Nov 25, 2026
…1.0 fixes (#3338)

## Task

Land cli-core 1.0 on `main` as `1.0.0-rc.0`: the stable API, store
version 73, the 1.0 fixes and the release rules, in one pull request on
top of 0.740.0.

## Why

cli-core moves to real semver. A stable core is listed in `package.json`
(`wirecat.stable`, ten entry points), and the rest is experimental. This
needs cli-base 1.0, and it changes the store, so every CLI adopts it on
a `release/1.0` branch of its own. The work landed on `release/1.0` from
several sessions. This branch is that work rebased onto `main`, plus the
gaps the consumer branches found.

**Not released yet.** `main` names `1.0.0-rc.0` with an empty changelog
section. `bin/release --major --app-ref release/1.0` collects `changes/`
into it and publishes on npm's `next` tag. Without the bump, the next
release from `main` would publish these breaks as 0.741.0 on `latest`.

## What

From `release/1.0` (rebased, one conflict resolved:
`src/cli/documents/manifest/source.ts` keeps main's `isCliError` and
takes `codegen/runtime`):
- the stable set (`wirecat.stable`, `@experimental` inside stable
entries, `MessageStoreCore`/`MessageStoreAreas`), `./store` without the
SQLite implementation, `./store/areas`;
- store version 73, including the fixes after the check on a real store:
references already broken stay, a refused run removes its rollback copy,
and a copy that changes a table's row count stops the migration;
- the 1.0 correctness and security fixes (one real-path check for every
local path an MCP call names, `--rescan` keeps the mass-deletion guard,
and others);
- the release rules: seven changelog headings, levelled versions,
`--major`, the `next` tag; every error reason in `docs/reasons.md`,
checked as a contract;
- parity builds all 19 CLIs on a release.

Added here:
- **API report:** `api/`, written by cli-base 1.0.0-rc.0's `cli-dev
api-report`. CI checks it from now on.
- **Workflows:** every cli-base reusable workflow pinned to v1.0.0-rc.0.
The changelog guard runs on label changes too, and
`scripts/changelog-shape.ts` takes cli-base's `CHANGELOG_HEADINGS`.
- **`./internal/*`:** every module's types can be named here, types
only.
- A CLI that inferred a type cli-core returns failed its declaration
emit with TS2883, since TypeScript names a type only through an entry
point already in the program.
- A probe calls every exported function of each of the 51 entry points,
each compiled on its own: 127 errors before, 0 after.
  - Node refuses a runtime import of the path.
- **`notLocalPaths`:** exported from `./cli` (experimental), so a CLI
can mark its own remote path inputs.
- **`catalog tree [folder]`:** the folder is the provider's id, not a
local path.
- **`./store/areas`:** exports `crmSettingKey` and `crmIdentityId`,
which amo-cli and bitrix24-cli import at run time.
- **Reasons:** the four reasons store version 73 raises, and main's new
OCR and deletions-feed reasons, are in `docs/reasons.md`.
- **Stable set:** `plainSetupText` (new on main, no importer) is tagged
experimental.
- **`known-broken.json`:** max-cli and mail-cli leave it; both adopted
the change on their `release/1.0` branches.

## Testing

- Local: typecheck, lint, `docs:check` (reasons included),
`schema:check`, `check:dist`, `check:agent-process`, `help:examples`,
`api-report --check`.
- Tests of the touched files, each run alone: path options, setup text,
the changelog and version scripts, store version 73, reasons, the
manifest source.
- The full suite was not run locally. The machine was overloaded (load
average above 40), so CI judges it.
- **Parity: the dispatched run is the real result:**
https://github.com/WireCatLabs/cli-core/actions/runs/45320991902
(`app_ref=release/1.0`, `tests=true`, all 19 CLIs).
- **This PR's own parity check is expected to fail.** It builds the 7 PR
consumers from their `main`, which is still on cli-base 0.x and the old
store imports; their adoption is on `release/1.0`.
- If branch protection requires that check, the PR merges with `--admin`
once the dispatched parity run and the rest of CI are green, with a
comment saying why.

## Known follow-up (after rc.0)

About 270 types that stable functions in `./cli` take or return are
exported from no entry point. With `./internal/*` they can be named, but
they are not under semver, and a change to them does not show in the API
report. A later pass decides which of them become stable exports.

## Downstream

Each CLI moves to cli-base 1.0.0-rc.0 and changes its imports from
`./store` to `./store/areas` where it uses them (the list is in
`changes/1.0-surface.md`). cli-memo imports `assertSharedContracts` from
`@wirecat/cli-base/commands`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Replaces #3288 (same commits, from `release/1.0`): the PR's parity
builds each CLI from its branch of the same name with an open pull
request, and the 20 CLIs adopt 1.0 on `release/1.0` (draft PRs, e.g.
WireCatLabs/cli-memo#897). The ruleset on main has no bypass, so #3288's
parity against the CLIs' main could not be merged past.


Labelled `major`: 1.0.0 is the first major of cli-core.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
leemour added a commit that referenced this pull request Nov 25, 2026
A program that writes to the owner (a no-reply or notification address, a
messenger bot, signed Auto-Submitted mail, an empty Return-Path, memo's
bulk_never_replied) becomes a sender_bots row instead of a person marked
automated. The bot keeps the person row it was sorted from, so identity links,
ingest, merges, purges and person:<uid> refs keep working, and people.list
lists it as automated with bot: sender-bot:<id> and no ties.

- Store version 74: sender_bots, sender_bot_moves (every move, rules or
  owner, with the reason), triggers in place of foreign keys so older builds
  can still erase and purge, kind-clearing triggers, and emails_by_list_id
  so a page of people no longer reads every stored List-Id.
- Kept kinds move a person to a bot by rule only on a program's signal, when
  the owner wrote them nothing and every identity is the program's; a rule's
  bot goes back when the rules stop holding. KIND_RULES 7.
- store.people.moveToBot / moveToPerson: the owner's choice, for a person,
  a bot or one identity, wins over the rules and KIND_RULES bumps.
- The matcher never joins a bot, tasks.assign refuses one, people.similar
  and people.ties leave bots out.

Part of #3314. Merge after #3288 (store version 73).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour added a commit that referenced this pull request Nov 25, 2026
A program that writes to the owner (a no-reply or notification address, a
messenger bot, signed Auto-Submitted mail, an empty Return-Path, memo's
bulk_never_replied) becomes a sender_bots row instead of a person marked
automated. The bot keeps the person row it was sorted from, so identity links,
ingest, merges, purges and person:<uid> refs keep working, and people.list
lists it as automated with bot: sender-bot:<id> and no ties.

- Store version 74: sender_bots, sender_bot_moves (every move, rules or
  owner, with the reason), triggers in place of foreign keys so older builds
  can still erase and purge, kind-clearing triggers, and emails_by_list_id
  so a page of people no longer reads every stored List-Id.
- Kept kinds move a person to a bot by rule only on a program's signal, when
  the owner wrote them nothing and every identity is the program's; a rule's
  bot goes back when the rules stop holding. KIND_RULES 7.
- store.people.moveToBot / moveToPerson: the owner's choice, for a person,
  a bot or one identity, wins over the rules and KIND_RULES bumps.
- The matcher never joins a bot, tasks.assign refuses one, people.similar
  and people.ties leave bots out.

Part of #3314. Merge after #3288 (store version 73).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour added a commit that referenced this pull request Nov 25, 2026
Rebased onto main after #3338 (store version 73, which replaced #3288).
Version 74 was regenerated from 73's snapshot. Its new tables use
`AUTOINCREMENT`, as 1.0 asks, and `minCompatible` stays 73.
`api/store.api.txt` and `docs/reasons.md` were regenerated.
`version-73.test.ts` now migrates only up to 73, so a later version does
not break it. The changelog entry is under "Changed — experimental":
`KindSignal` and the people list are `@experimental`, and the rest only
adds things, so no major is needed.

## Task

Plan steps 3 and 4 of the contact-kinds plan ([plan
#3323](#3323)): bots as
their own entity, and the owner's choice to move a sender between a
person and a bot. Owner's ruling NEED-109 A. Part of #3314.

## Why

A bot was a person with the kind `automated`. Every list, merge scan and
tie check had to remember to skip it, and each one that forgot was a bug
(#3320 was one). The owner also had no way to say "this is a bot" or
"this is a person" in a way that holds.

## What

**Schema chosen (store version 74).** Tables, an index and triggers
added only. `minCompatible` stays 73.
- `sender_bots` (id, `person_id` unique, name, `organization_id`, author
`rules` or `owner`, reason, times). `bots` was already taken by agents,
and `bot:<n>` refs mean agents, so the table is `sender_bots` and the
ref is `sender-bot:<id>`.
- **A bot keeps the person row it was sorted from.** Its identities stay
in `identity_links` on that row. I chose this over
`identity_links.bot_id` or a `bot_identities` table:
- `identity_links.person_id` is `NOT NULL`. Making it nullable needs a
table rebuild.
- About 60 modules join `identity_links`. Taking an identity out of it
means ingest creates a new person on the next sync (`ensurePerson`). The
emptied person also shows as "added by hand".
- Desktop accepts only `person:<uid>` refs (`person_ref` in
`people.rs`). `people show person:<uid>` keeps working.
- `sender_bot_moves`: one row per identity per move. It holds from
(person or bot), to, author `rules` or `owner`, reason, and time.
- **No foreign keys** on either table, as `document_changes` does, so an
older build can still erase a person or purge an account. Triggers drop
the rows with the person or identity, and clear the organization. Other
triggers clear the stored kind when a bot or a move is written.
- **PERF from #3334:** an expression index `emails_by_list_id` on the
exact List-Id expression `sentMailOf` uses. No new column and no
backfill: `CREATE INDEX` fills it. A test asserts that `EXPLAIN QUERY
PLAN` of the real statement (`LIST_SENDERS`) uses the index. The schema
codegen now passes an expression key through.

**Rule move** (`people-list.ts`, `KIND_RULES` 7). When kinds are kept, a
person moves to a bot when all of these hold:
- their kind is `automated` by a program's signal: the platform bot
flag, a no-reply or notification address, a signed Auto-Submitted, a
null return path, or `bulk_never_replied`;
- the owner wrote them nothing: no mail tie and no two-way private chat
(the platform flag holds anyway);
- no `ALWAYS_SHOWN` reason applies;
- every identity is the program's, or they have only one.

Other cases:
- `automated-name` or a bulk mailbox alone marks a person and moves
nothing. A newsletter a human writes stays a person.
- A rule's bot goes back to a person when the rules stop holding, for
example when the owner writes to it. This is logged.
- No person is emptied by a rule move.

**Owner's choice.** `store.people.moveToBot(subject, by, { bot?, name?,
reason? })` and `moveToPerson(subject, by, { person?, reason? })`.
Subject: `person:<uid>`, `sender-bot:<id>` or an `IdentityRef`. Owner
only (`identity.owner-only`).
- One identity of a person with several gets a person row of its own
first (an owner's unlink).
- A bot the owner made is `author = 'owner'`. An identity whose latest
move is the owner's, to a person, is never moved by a rule. Both survive
`KIND_RULES` bumps (tested).

**Bots are left out of:**
- the matcher (`identity.not-a-person` for email and phone joins too;
name scans already skip `automated`);
- `tasks.assign` (new reason `sender-bot.assignee`);
- `people.similar`;
- `people.ties` (empty).

**`kind:automated` compatibility.** A bot is still listed as `automated`
under its `person:<uid>` ref, with the same counts and paging. The row
gains `bot: "sender-bot:<id>" | null` and has empty `ties`. memo's
`personRow` and Desktop's `listed()` read named fields only, so both
keep working unchanged.

**People counts.** `people.list` counts are the only people tallies in
cli-core. Bots count under `automated` and never under `person`.

**Alias joining the owner later (item 4).** I found no stale kind.
`person_kind_email_au` clears the recipients' kinds when `markOwnMail`
flips `outgoing`. A new test in `src/mail/own.test.ts` proves it:
stranger first, person after the alias joins. No fix was needed.

**Not in this PR (memo needs):** `bots list` and a command for the two
moves (for example `people bot <ref>` and `people person <ref>`), and a
field for the bot ref on `people list` rows. Call that field
`sender_bot`, not `bot`: Desktop's `Listed.bot` already means "has the
messenger bot signal". Desktop needs a Bots tab (plan step 7). No
downstream implements `PeopleStore` (grep of cli-memo, wirecat-desktop,
cli-template).

**RISK.** The first list after the upgrade creates every bot under the
write lock. A synthetic store with 20,000 no-reply senders took 1.4 s
for that list, against 0.66 s with nothing to move (load average about
30). The lock part stays under the other writers' 5 s wait. Chunk it if
a real store shows more.

## Testing

All runs used `--maxWorkers=1`.
- New `src/store/sender-bots.test.ts` (8 tests):
  - a rule move, kept through a sync;
- the owner's moves both ways, through a `KIND_RULES` change, refused
for an agent and for the owner's own person;
  - one identity moved to a new bot and into an existing one;
  - no join by address, and no task assignee;
- an upgrade from 73 moves the programs, and `EXPLAIN` shows the index
is used;
  - a rule's bot goes back once the owner writes to it;
  - a purge and an erase take the bot's rows with them;
  - no proposal by name.
- Existing suites: people-list (19), people-kinds-stored (6),
people-matching-rules (23), person-match-scan (34), person-doubts,
person-merges, schema, sender-signals, mail/own (8), store, upgrade,
rollback-copy, transaction, doctor, store-tables, store-maintenance.
- Under load (average 30–45), one people-list test and one
people-kinds-stored test passed only when run alone. They were over the
time limit, not wrong.
- `pnpm typecheck`, `ci:quick`, `schema:check`, `docs:check`, and Biome
on the changed files.
- Line limits were raised for `spec.mjs` (+2), `schema.ts` (+5) and
`reasons.ts` (in the 1010 group), as version 72 did.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major A stable break: waits for a major the owner chose (WC-REL-7)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant