diff --git a/.cursor/rules/avoid-debug-loops.mdc b/.cursor/rules/avoid-debug-loops.mdc deleted file mode 100644 index 8a241ec9..00000000 --- a/.cursor/rules/avoid-debug-loops.mdc +++ /dev/null @@ -1,57 +0,0 @@ ---- -description: When stuck in debugging loops, break the cycle by minimizing to an MVP, removing debugging cruft, and documenting the issue completely for a fresh approach -globs: *.py -alwaysApply: true ---- -# Avoid Debug Loops - -When debugging becomes circular and unproductive, follow these steps: - -## Detection -- You have made multiple unsuccessful attempts to fix the same issue -- You are adding increasingly complex code to address errors -- Each fix creates new errors in a cascading pattern -- You are uncertain about the root cause after 2-3 iterations - -## Action Plan - -1. **Pause and acknowledge the loop** - - Explicitly state that you are in a potential debug loop - - Review what approaches have been tried and failed - -2. **Minimize to MVP** - - Remove all debugging cruft and experimental code - - Revert to the simplest version that demonstrates the issue - - Focus on isolating the core problem without added complexity - -3. **Comprehensive Documentation** - - Provide a clear summary of the issue - - Include minimal but complete code examples that reproduce the problem - - Document exact error messages and unexpected behaviors - - Explain your current understanding of potential causes - -4. **Format for Portability** - - Present the problem in quadruple backticks for easy copying: - -```` -# Problem Summary -[Concise explanation of the issue] - -## Minimal Reproduction Code -```python -# Minimal code example that reproduces the issue -``` - -## Error/Unexpected Output -``` -[Exact error messages or unexpected output] -``` - -## Failed Approaches -[Brief summary of approaches already tried] - -## Suspected Cause -[Your current hypothesis about what might be causing the issue] -```` - -This format enables the user to easily copy the entire problem statement into a fresh conversation for a clean-slate approach. diff --git a/.cursor/rules/dev-loop.mdc b/.cursor/rules/dev-loop.mdc deleted file mode 100644 index f8b6e40b..00000000 --- a/.cursor/rules/dev-loop.mdc +++ /dev/null @@ -1,187 +0,0 @@ ---- -description: QA every edit -globs: *.py -alwaysApply: true ---- - -# Development Process - -## Project Stack - -The project uses the following tools and technologies: - -- **uv** - Python package management and virtual environments -- **ruff** - Fast Python linter and formatter -- **py.test** - Testing framework - - **pytest-watcher** - Continuous test runner -- **ty** - Static type checking -- **doctest** - Testing code examples in documentation - -## 1. Start with Formatting - -Format your code first: - -``` -uv run ruff format . -``` - -## 2. Run Tests - -Verify that your changes pass the tests: - -``` -uv run py.test -``` - -For continuous testing during development, use pytest-watcher: - -``` -# Watch all tests -uv run ptw . - -# Watch and run tests immediately, including doctests -uv run ptw . --now --doctest-modules - -# Watch specific files or directories -uv run ptw . --now --doctest-modules src/libtmux/_internal/ -``` - -## 3. Commit Initial Changes - -Make an atomic commit for your changes using conventional commits. -Use `@git-commits.mdc` for assistance with commit message standards. - -## 4. Run Linting and Type Checking - -Check and fix linting issues: - -``` -uv run ruff check . --fix --show-fixes -``` - -Check typings: - -``` -uv run ty check . -``` - -## 5. Verify Tests Again - -Ensure tests still pass after linting and type fixes: - -``` -uv run py.test -``` - -## 6. Final Commit - -Make a final commit with any linting/typing fixes. -Use `@git-commits.mdc` for assistance with commit message standards. - -## Development Loop Guidelines - -If there are any failures at any step due to your edits, fix them before proceeding to the next step. - -## Python Code Standards - -### Docstring Guidelines - -For `src/**/*.py` files, follow these docstring guidelines: - -1. **Use reStructuredText format** for all docstrings. - ```python - """Short description of the function or class. - - Detailed description using reStructuredText format. - - Parameters - ---------- - param1 : type - Description of param1 - param2 : type - Description of param2 - - Returns - ------- - type - Description of return value - """ - ``` - -2. **Keep the main description on the first line** after the opening `"""`. - -3. **Use NumPy docstyle** for parameter and return value documentation. - -### Doctest Guidelines - -For doctests in `src/**/*.py` files: - -1. **Use narrative descriptions** for test sections rather than inline comments: - ```python - """Example function. - - Examples - -------- - Create an instance: - - >>> obj = ExampleClass() - - Verify a property: - - >>> obj.property - 'expected value' - """ - ``` - -2. **Move complex examples** to dedicated test files at `tests/examples//test_.py` if they require elaborate setup or multiple steps. - -3. **Utilize pytest fixtures** via `doctest_namespace` for more complex test scenarios: - ```python - """Example with fixture. - - Examples - -------- - >>> # doctest_namespace contains all pytest fixtures from conftest.py - >>> example_fixture = getfixture('example_fixture') - >>> example_fixture.method() - 'expected result' - """ - ``` - -4. **Keep doctests simple and focused** on demonstrating usage rather than comprehensive testing. - -5. **Add blank lines between test sections** for improved readability. - -6. **Test your doctests continuously** using pytest-watcher during development: - ``` - # Watch specific modules for doctest changes - uv run ptw . --now --doctest-modules src/path/to/module.py - ``` - -### Pytest Testing Guidelines - -1. **Use existing fixtures over mocks**: - - Use fixtures from conftest.py instead of `monkeypatch` and `MagicMock` when available - - For instance, if using libtmux, use provided fixtures: `server`, `session`, `window`, and `pane` - - Document in test docstrings why standard fixtures weren't used for exceptional cases - -2. **Preferred pytest patterns**: - - Use `tmp_path` (pathlib.Path) fixture over Python's `tempfile` - - Use `monkeypatch` fixture over `unittest.mock` - -### Import Guidelines - -1. **Prefer namespace imports**: - - Import modules and access attributes through the namespace instead of importing specific symbols - - Example: Use `import enum` and access `enum.Enum` instead of `from enum import Enum` - - This applies to standard library modules like `pathlib`, `os`, and similar cases - -2. **Standard aliases**: - - For `typing` module, use `import typing as t` - - Access typing elements via the namespace: `t.NamedTuple`, `t.TypedDict`, etc. - - Note primitive types like unions can be done via `|` pipes and primitive types like list and dict can be done via `list` and `dict` directly. - -3. **Benefits of namespace imports**: - - Improves code readability by making the source of symbols clear - - Reduces potential naming conflicts - - Makes import statements more maintainable diff --git a/.cursor/rules/git-commits.mdc b/.cursor/rules/git-commits.mdc deleted file mode 100644 index f9c0980d..00000000 --- a/.cursor/rules/git-commits.mdc +++ /dev/null @@ -1,95 +0,0 @@ ---- -description: git-commits: Git commit message standards and AI assistance -globs: git-commits: Git commit message standards and AI assistance | *.git/* .gitignore .github/* CHANGELOG.md CHANGES.md -alwaysApply: true ---- -# Optimized Git Commit Standards - -## Commit Message Format -``` -Component/File(commit-type[Subcomponent/method]): Concise description - -why: Explanation of necessity or impact. -what: -- Specific technical changes made -- Focused on a single topic - -refs: #issue-number, breaking changes, or relevant links -``` - -## Component Patterns -### General Code Changes -``` -Component/File(feat[method]): Add feature -Component/File(fix[method]): Fix bug -Component/File(refactor[method]): Code restructure -``` - -### Packages and Dependencies -| Language | Standard Packages | Dev Packages | Extras / Sub-packages | -|------------|------------------------------------|-------------------------------|-----------------------------------------------| -| General | `lang(deps):` | `lang(deps[dev]):` | | -| Python | `py(deps):` | `py(deps[dev]):` | `py(deps[extra]):` | -| JavaScript | `js(deps):` | `js(deps[dev]):` | `js(deps[subpackage]):`, `js(deps[dev{subpackage}]):` | - -#### Examples -- `py(deps[dev]): Update pytest to v8.1` -- `js(deps[ui-components]): Upgrade Button component package` -- `js(deps[dev{linting}]): Add ESLint plugin` - -### Documentation Changes -Prefix with `docs:` -``` -docs(Component/File[Subcomponent/method]): Update API usage guide -``` - -### Test Changes -Prefix with `tests:` -``` -tests(Component/File[Subcomponent/method]): Add edge case tests -``` - -## Commit Types Summary -- **feat**: New features or enhancements -- **fix**: Bug fixes -- **refactor**: Code restructuring without functional change -- **docs**: Documentation updates -- **chore**: Maintenance (dependencies, tooling, config) -- **test**: Test-related updates -- **style**: Code style and formatting - -## General Guidelines -- Subject line: Maximum 50 characters -- Body lines: Maximum 72 characters -- Use imperative mood (e.g., "Add", "Fix", not "Added", "Fixed") -- Limit to one topic per commit -- Separate subject from body with a blank line -- Mark breaking changes clearly: `BREAKING:` -- Use `See also:` to provide external references - -## AI Assistance Workflow in Cursor -- Stage changes with `git add` -- Use `@commit` to generate initial commit message -- Review and refine generated message -- Ensure adherence to these standards - -## Good Commit Example -``` -Pane(feat[capture_pane]): Add screenshot capture support - -why: Provide visual debugging capability -what: -- Implement capturePane method with image export -- Integrate with existing Pane component logic -- Document usage in Pane README - -refs: #485 -See also: https://example.com/docs/pane-capture -``` - -## Bad Commit Example -``` -fixed stuff and improved some functions -``` - -These guidelines ensure clear, consistent commit histories, facilitating easier code review and maintenance. \ No newline at end of file diff --git a/.cursor/rules/notes-llms-txt.mdc b/.cursor/rules/notes-llms-txt.mdc deleted file mode 100644 index ac170977..00000000 --- a/.cursor/rules/notes-llms-txt.mdc +++ /dev/null @@ -1,42 +0,0 @@ ---- -description: LLM-friendly markdown format for notes directories -globs: notes/**/*.md,**/notes/**/*.md -alwaysApply: true ---- - -# Instructions for Generating LLM-Optimized Markdown Content - -When creating or editing markdown files within the specified directories, adhere to the following guidelines to ensure the content is optimized for LLM understanding and efficient token usage: - -1. **Conciseness and Clarity**: - - **Be Brief**: Present information succinctly, avoiding unnecessary elaboration. - - **Use Clear Language**: Employ straightforward language to convey ideas effectively. - -2. **Structured Formatting**: - - **Headings**: Utilize markdown headings (`#`, `##`, `###`, etc.) to organize content hierarchically. - - **Lists**: Use bullet points (`-`) or numbered lists (`1.`, `2.`, etc.) to enumerate items clearly. - - **Code Blocks**: Enclose code snippets within triple backticks (```) to distinguish them from regular text. - -3. **Semantic Elements**: - - **Emphasis**: Use asterisks (`*`) or underscores (`_`) for italicizing text to denote emphasis. - - **Strong Emphasis**: Use double asterisks (`**`) or double underscores (`__`) for bold text to highlight critical points. - - **Inline Code**: Use single backticks (`) for inline code references. - -4. **Linking and References**: - - **Hyperlinks**: Format links using `[Link Text](mdc:URL)` to provide direct access to external resources. - - **References**: When citing sources, use footnotes or inline citations to maintain readability. - -5. **Avoid Redundancy**: - - **Eliminate Repetition**: Ensure that information is not unnecessarily repeated within the document. - - **Use Summaries**: Provide brief summaries where detailed explanations are not essential. - -6. **Standard Compliance**: - - **llms.txt Conformance**: Structure the document in alignment with the `llms.txt` standard, which includes: - - An H1 heading with the project or site name. - - A blockquote summarizing the project's purpose. - - Additional markdown sections providing detailed information. - - H2-delimited sections containing lists of URLs for further details. - -By following these guidelines, the markdown files will be tailored for optimal LLM processing, ensuring that the content is both accessible and efficiently tokenized for AI applications. - -For more information on the `llms.txt` standard, refer to the official documentation: https://llmstxt.org/ diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 61c47844..34d10d79 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -13,7 +13,8 @@ How this project writes prose — README, `CHANGES`, release notes, commit messages, CLI help text, logging, docstrings, and source comments — is set out separately in [WRITING.md](WRITING.md). Read that before changing any of it. The constraints every change is held to, and the map of what is where, -are in [AGENTS.md](../AGENTS.md). +are in [AGENTS.md](../AGENTS.md); architectural ownership and review criteria +are in [REVIEW.md](../REVIEW.md). ## Getting set up @@ -64,6 +65,19 @@ CI runs Ruff, ty, and the test suite with coverage on Python 3.15. It type-checks the project twice, once at the minimum supported Python version and once at the matrix version. +Check declared upstream workarounds in `.github/workarounds.toml` against +`uv.lock`. + +CI runs the shared +[check-workarounds](https://github.com/libtmux/.github/tree/main/actions/check-workarounds) +action for this. To run it locally, set `CHECK_WORKAROUNDS` to +`actions/check-workarounds/check_workarounds.py` in a checkout of +`libtmux/.github`: + +```console +$ python3 -B "${CHECK_WORKAROUNDS:?path to check_workarounds.py}" --root . +``` + Before claiming a test or a gate works, show it failing. A gate that has never been red is an assumption. Fix a regression rather than disabling or skipping its test. @@ -101,6 +115,43 @@ matching — see the testing-logs guidance in Watch mode: `uv run ptw .` (`just start` runs the suite once, then watches). `just watch-test` uses `entr(1)` instead, when installed. +### Verifying test bite + +For bug fixes and behavioral changes, show that the regression test fails +inside the real owner call once modified non-test production files are back at +`origin/master` (or `` when fixing a defect introduced earlier in +the same pull request) and newly added production files are gone: + +```console +$ : "${BITE_TEST:?set BITE_TEST to the regression test}" && \ + wt=$(mktemp -d) && \ + git worktree add --quiet --detach "$wt" HEAD && \ + ( cd "$wt" && \ + base=${BITE_BASE:-origin/master} && \ + git diff --name-only --no-renames "$base" HEAD | \ + grep -E '\.py$' | \ + grep -Ev '(^|/)tests?/|(^|/)conftest\.py$|(^|/)test_[^/]*\.py$|_test\.py$' \ + > bite.files && \ + git restore --source="$base" --worktree \ + --pathspec-from-file=bite.files && \ + { uv run pytest -rf "$BITE_TEST" 2>&1 | tee bite.log; \ + grep -E '^FAILED ' bite.log | \ + grep -F -- "$BITE_TEST" | \ + grep -Ev 'ImportError|ModuleNotFoundError'; } ); \ + bite=$?; \ + git worktree remove --force "$wt"; \ + test "$bite" -eq 0 +``` + +This runs in a disposable `git worktree` at `HEAD`, so the checkout and any +uncommitted edit stay untouched; commit the change first. Set `BITE_TEST` to a +pytest node id such as `tests/test_x.py::test_name`. `BITE_BASE` defaults to +`origin/master`; set it to the pre-fix commit when the defect was introduced +earlier in the same pull request. The command succeeds only when the runner +reports that test as failed, and it prints the failure line. A missing runner, +a build error or an import error prints no such line, so it is not a bite. +Check that the printed failure is the assertion that describes the defect. + ## Documentation ```console diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..e6c92f2f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,26 @@ + + +Closes # + +### 1. Owner and boundary + +- Rule changed and module/package that owns it: +- Sibling entry points checked (`sync`/`async`, CLI/API, single/batch, or `N/A`): +- Why this belongs here (owner fix, boundary adapter, or single-PR ownership transfer): + +### 2. Failure before the fix (`N/A` for docs, lockfile bumps, or pure refactors) + +- Baseline (`` commit, or `` SHA if fixing a defect introduced in this PR): +- Failing input / command and observed failure before the fix: + +### 3. Verification and tool disclosure + +- Repository gates run (plus production-only revert check for behavioral fixes, or `N/A`): +- `.github/workarounds.toml` updates (`None` if none): +- Tool use: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a802483c..aa0c5454 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,6 +15,9 @@ jobs: steps: - uses: actions/checkout@v7 + - name: Check declared workarounds + uses: libtmux/.github/actions/check-workarounds@22703e1b8ee1c176ca72d9ffc9520f2ca0ce3a85 # main + - name: Install uv uses: astral-sh/setup-uv@v10.2.0 with: diff --git a/.windsurfrules b/.windsurfrules deleted file mode 100644 index 3c0b6886..00000000 --- a/.windsurfrules +++ /dev/null @@ -1,136 +0,0 @@ -# libtmux Python Project Rules - - -- uv - Python package management and virtual environments -- ruff - Fast Python linter and formatter -- py.test - Testing framework - - pytest-watcher - Continuous test runner -- ty - Static type checking -- doctest - Testing code examples in documentation - - - -- Use a consistent coding style throughout the project -- Format code with ruff before committing -- Run linting and type checking before finalizing changes -- Verify tests pass after each significant change - - - -- Use reStructuredText format for all docstrings in src/**/*.py files -- Keep the main description on the first line after the opening `"""` -- Use NumPy docstyle for parameter and return value documentation -- Format docstrings as follows: - ```python - """Short description of the function or class. - - Detailed description using reStructuredText format. - - Parameters - ---------- - param1 : type - Description of param1 - param2 : type - Description of param2 - - Returns - ------- - type - Description of return value - """ - ``` - - - -- Use narrative descriptions for test sections rather than inline comments -- Format doctests as follows: - ```python - """ - Examples - -------- - Create an instance: - - >>> obj = ExampleClass() - - Verify a property: - - >>> obj.property - 'expected value' - """ - ``` -- Add blank lines between test sections for improved readability -- Keep doctests simple and focused on demonstrating usage -- Move complex examples to dedicated test files at tests/examples//test_.py -- Utilize pytest fixtures via doctest_namespace for complex scenarios - - - -- Run tests with `uv run py.test` before committing changes -- Use pytest-watcher for continuous testing: `uv run ptw . --now --doctest-modules` -- Fix any test failures before proceeding with additional changes - - - -- Make atomic commits with conventional commit messages -- Start with an initial commit of functional changes -- Follow with separate commits for formatting, linting, and type checking fixes - - - -- Use the following commit message format: - ``` - Component/File(commit-type[Subcomponent/method]): Concise description - - why: Explanation of necessity or impact. - what: - - Specific technical changes made - - Focused on a single topic - - refs: #issue-number, breaking changes, or relevant links - ``` - -- Common commit types: - - **feat**: New features or enhancements - - **fix**: Bug fixes - - **refactor**: Code restructuring without functional change - - **docs**: Documentation updates - - **chore**: Maintenance (dependencies, tooling, config) - - **test**: Test-related updates - - **style**: Code style and formatting - -- Prefix Python package changes with: - - `py(deps):` for standard packages - - `py(deps[dev]):` for development packages - - `py(deps[extra]):` for extras/sub-packages - -- General guidelines: - - Subject line: Maximum 50 characters - - Body lines: Maximum 72 characters - - Use imperative mood (e.g., "Add", "Fix", not "Added", "Fixed") - - Limit to one topic per commit - - Separate subject from body with a blank line - - Mark breaking changes clearly: `BREAKING:` - - - -- Use fixtures from conftest.py instead of monkeypatch and MagicMock when available -- For instance, if using libtmux, use provided fixtures: server, session, window, and pane -- Document in test docstrings why standard fixtures weren't used for exceptional cases -- Use tmp_path (pathlib.Path) fixture over Python's tempfile -- Use monkeypatch fixture over unittest.mock - - - -- Prefer namespace imports over importing specific symbols -- Import modules and access attributes through the namespace: - - Use `import enum` and access `enum.Enum` instead of `from enum import Enum` - - This applies to standard library modules like pathlib, os, and similar cases -- For typing, use `import typing as t` and access via the namespace: - - Access typing elements as `t.NamedTuple`, `t.TypedDict`, etc. - - Note primitive types like unions can be done via `|` pipes - - Primitive types like list and dict can be done via `list` and `dict` directly -- Benefits of namespace imports: - - Improves code readability by making the source of symbols clear - - Reduces potential naming conflicts - - Makes import statements more maintainable - diff --git a/AGENTS.md b/AGENTS.md index d7815f6e..09811ced 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,6 +24,8 @@ was asked for. ## Which policy applies +- Architecture boundaries, module ownership, rejected patterns, and review + criteria: [REVIEW.md](REVIEW.md) - Documentation, user-facing text, `CHANGES`, release notes, commit messages, docstrings, and source comments: [.github/WRITING.md](.github/WRITING.md) @@ -45,6 +47,8 @@ stated twice, the file listed above is the one that governs. for every change to the public API, CLI, configuration, or output. - A passing gate is evidence only once it has been shown capable of failing. Pair a new test with a deliberate break that proves it bites. +- Keep `AGENTS.md` (with `CLAUDE.md` symlinked to it) as the single agent + entrypoint; do not reintroduce `.cursor/rules` or `.windsurfrules`. cihai-cli is a thin front end over the `cihai` library; UNIHAN data comes through `cihai`'s `unihan_etl` dependency. On first use, `cihai` bootstraps diff --git a/REVIEW.md b/REVIEW.md new file mode 100644 index 00000000..a727be4c --- /dev/null +++ b/REVIEW.md @@ -0,0 +1,100 @@ +# Code and architecture review (`cihai/cihai-cli`) + +Posture: `experimental` (pre-1.0 command-line front end for the `cihai` CJK +character library). + +[Posture](https://github.com/cihai/.github/blob/HEAD/CONTRIBUTING.md#posture) +defines `experimental`, `stable` and `private`. + +Review the complete change against ``, including untracked files. Report +all findings in one pass without editing files. Follow +[.github/WRITING.md](.github/WRITING.md) and +[cihai/.github/WRITING.md](https://github.com/cihai/.github/blob/HEAD/WRITING.md). + +## Module and ecosystem ownership + +| Module / package | Owns | Must not own | +| --- | --- | --- | +| `src/cihai_cli/cli.py` | `argparse` parser construction (`create_parser`), CLI logger setup, `Cihai` initialization/bootstrap trigger, `command_info` and `command_reverse` field filtering (`HUMAN_UNIHAN_FIELDS`, `--all`), YAML output serialization | Direct SQLAlchemy table definitions, raw Unihan archive parsing, or asymmetric flag behavior between `info` and `reverse` | +| `src/cihai_cli/_formatter.py` | `--help` layout and colorized help formatting (`CihaiHelpFormatter`, `HelpTheme`, `create_formatter`) | Query execution, `Cihai` configuration loading, or global environment mutation | +| `src/cihai_cli/_colors.py` | `NO_COLOR` and `FORCE_COLOR` precedence (`Colors`, `ColorMode`, `style`) | Hardcoded TTY assumptions ignoring `NO_COLOR` / `FORCE_COLOR` | +| Upstream `cihai/cihai` and `cihai/unihan-etl` | `Cihai` config expansion, dataset/plugin registration, Unihan database bootstrap (`lookup_char`, `reverse_char`), and raw Unihan ETL (`unihan-etl`) | Cross-package imports of `cihai._internal` or `unihan_etl._internal` inside `cihai_cli` | + +### Adapter versus duplicated rule + +`cihai_cli` is a thin terminal adapter over `cihai.core.Cihai`: it parses CLI +flags, delegates database bootstrap and character queries to `Cihai`, filters +columns for human display unless `--all` is passed, and formats YAML output. +Block when `cihai_cli` duplicates SQL query filters, config template expansion, +or Unihan table bootstrap logic owned by `cihai` or `unihan_etl`. + +### Changing the map + +Do not `BLOCK` against `:REVIEW.md`'s prior owner row when a pull request +migrates an invariant cleanly to a single owner, updates callers, tests, and +`REVIEW.md` in the same diff, and states the old and new owner in the pull +request description. Before blocking on placement, state the strongest case +that the change is a valid boundary adapter or ownership transfer and explain +why that case fails. + +### Rejected here + +- **Duplicating `cihai` query or bootstrap internals in `cli.py`**: Route + configuration files through `Cihai.from_file`, bootstrap checks through + `c.unihan.is_bootstrapped` / `c.unihan.bootstrap`, and lookups through + `c.unihan.lookup_char` and `c.unihan.reverse_char`. Never import + `cihai._internal` or `unihan_etl._internal`. +- **Asymmetric subcommand behavior or unaligned output changes** + (`src/cihai_cli/cli.py`): Check both `command_info` and `command_reverse` + whenever touching field filtering (`HUMAN_UNIHAN_FIELDS` vs `--all`), empty + result handling, or YAML serialization. Output channel changes (moving from + `logging` to stdout) must align with + [#341](https://github.com/cihai/cihai-cli/issues/341) and update + `docs/index.md` and `tests/test_docs_examples.py` together. +- **Import-time side effects, live network downloads, or mocked library + owners**: Keep `setup_logger()` inside `cli()` rather than module import, run + tests against the zipped fixtures in `tests/conftest.py` (`zip_file`, + `unihan_options`, `tmpdb_file`) instead of mocking `Cihai` or hitting + `unicode.org`, and assert on `caplog.records` rather than raw `caplog.text` + substrings where structured records apply. +- **Untested type narrowing or suppressed diagnostics**: Never add bare + `# type: ignore` or `# noqa`, silent `except Exception: pass` blocks, or + `TypeGuard` / `TypeIs` helpers without runtime structural checks. + +## Regression baseline and decision + +1. For bug fixes and behavioral changes, prove the regression test fails on + `` (or on `` when fixing a defect introduced earlier in + the same open pull request) through `cli()` against offline `Cihai` fixtures. +2. Run the production-only revert check (for behavioral changes), + `uv run ruff check .`, `uv run ruff format . --check`, `uv run ty check .`, + `uv run pytest`, and the shared `check-workarounds` action in CI. +3. Require temporary upstream workarounds to be declared in + `.github/workarounds.toml` with a pinned issue URL, a + `pypi:>=` removal predicate (or `issue_only = true` with + `reason_no_lock`), and the workaround `id` cited in source, verified by the + shared `check-workarounds` action in CI. +4. Emit `BLOCK` or `NO FINDINGS` (plus optional non-blocking `NOTE` items). + Every `BLOCK` must cite the file and rule or failing input and state a + concrete test, command, or code observation that would prove the finding + wrong. + +## Verdict + +These rules decide which findings block. + +- **Base run**: A finding that code misbehaves shows its check run on `` + and on the change, with one line of output from each. +- **Existing and separate**: Behavior `` already has does not block. + Report it as a `NOTE`, unless the change adds a promise the behavior breaks; + then the broken promise is the finding. +- **Unverified**: A gate nobody ran is unverified. Name the command that would + run it. It holds the merge until someone runs it, and it does not make the + verdict `BLOCK`. +- **Behavior defects**: A behavior defect blocks when a caller can reach it in + a supported environment, or when it breaks a promise in the pull request + description, a docstring, help text or the changelog. Otherwise it is a + `NOTE`. +- **Checks and claims**: A weakened check, a rule written in a second place and + a behavior claimed as tested with no test that bites block whether or not a + caller reaches them.