Status: reference.
CODE-STANDARDS.md says what the code must look like.
This document says where it currently doesn't and, just as important,
where it looks like it doesn't but is right. Nothing here is enforced.
The one part of this project's debt that is enforced, the C1/C2
ratchet, lives in code-standards-register.toml and
tests/test_code_standards_scan.py, and is pointed
at, never restated.
Written for someone deciding what to take next, and for the agent that
picks this repository up cold and needs to know which surprising thing is
a bug and which is a decision. It assumes DEVELOPER-AGENTS.md for the
process around a change.
Not covered here: anything about drafts (AGENTS.md), prose standards (WRITING-STANDARDS.md), or features not yet built (FEATURE-ROADMAP.md). A thing that was never built is not a debt.
An item must meet all three conditions:
It comes off the list the way it went on: in its own pull request, against this file. Coming off means the section is deleted, not marked done and kept. The pull request that closed an item is the record of why it was owed and what paying it cost.
The debt on this list is not a gate. python -m chitragupta.draft gate
is the only gate in the project (SOUL.md). Nothing here goes
red because an item is unpaid.
tests/test_technical_debt_scan.py checks something else: whether this
document describes the C1/C2 register correctly. A wrong sentence about
the register is a factual error in prose, and it is the one class of claim
here with a machine-readable source of truth. Leaving an entry open
forever is fine; saying it is on a register it left is not.
code-standards-register.toml freezes 2 functions over C1 (25
statements) and 0 modules over C2 (250 code lines), each with its
current size recorded beside it, which
test_every_registered_offender_records_its_current_count keeps honest.
Its c1js/c2js tables hold the same ratchet for assets/webapp/.
tests/test_code_standards_scan.py reads that file and is what fails a
build.
That register is the authority, and this section does not copy it. A debt stated in two places will eventually be stated two different ways, and only one of the two is checked on every run. So this tier holds no subsections.
Measured on 2026-11-05 at 6.166.1 over chitragupta/ and scripts/ (not
tests/ or bench/, for the reasons in What is not debt;
R15 is the one exception, since it duplicates config rather than test
setup).
Each item is copies or sizes counted by an AST walk, not a judgement of
style. Each one also costs something already: a fix that lands in one
copy and not the other, or an edit that must split code before it can
change it. None is on the C1/C2 register, and none is a gate. Paying one
deletes its entry, in the PR that pays it.
os.replace writers. _atomic_write.write_atomically
is the shared one, and its own docstring says it is "not yet shared".
The others are core/draft/_json_cache.py:77,
core/overlap_index_doc.py:99 and :143 (_atomic_write_json,
_atomic_write_bytes), core/corpus/enrich/doc_vectors.py:46
and core/draft/registry/_pages.py:168. They differ in cleanup on failure, and
doc_vectors.py uses a fixed .json.tmp name, so two concurrent
writers share one temp file. Refactor: route the other five through
write_atomically. (The retrieval_cache/_docling_cache pair is a
decision, under What is not debt.)core/overlap_index_doc.py and core/overlap_skipgram.py
share three function bodies, identical down to the AST:
fingerprint_document
(:241/:316), _save_doc_cache (:197/:279) and
postings_for_gram (core/overlap_index_query.py:29/core/overlap_skipgram.py:280).
Refactor: one implementation, parameterised by the fingerprint type._area(box) is defined four times: core/figure/_advisory.py:208,
core/figure/_connectors.py:163, core/figure/_contrast.py:167 and
core/review/figure_layout/_geometry.py:105, in two identical pairs.
Refactor: one function in _geometry, where contains and
intersects already live.finding_id in citation_coverage.py, synthesis.py,
uncited_prose.py, _citation_provenance_render.py,
_claim_support_render.py (the last two identical), _citekey_union_render.py,
_quotation_render.py and verbatim_check/_shared.py. In all,
hexdigest()[:12] appears in 11 modules. The agenda's dedup and
--accept rely on every copy agreeing. Refactor: one review._ids.finding_id(*parts).render_markdown is
defined in 10 modules, format_report in 7, _finding_lines in 5,
_summary in 4 and _how_to_read in 3, all under chitragupta/core/review/.
review.header is the only part they share. Refactor: a report
skeleton (header, how-to-read, summary, findings) that each aid fills.Command: line, and they disagree.
_command is in agenda/__init__.py, citation_coverage.py,
citation_provenance.py, citekey_union.py, claim_support.py,
figure_layout/__init__.py, quotation.py, synthesis.py,
uncited_prose.py and verbatim_digest.py. provenance and agenda
leave out --write, five others record it, and the sample project's
reports show both. Refactor: derive the line from the parsed
argparse namespace in one place._grouped is identical in core/draft/registry/_pages.py:29 and
core/draft/registry/_terms.py:53. Refactor: keep one, in core/draft/registry/__init__.py.core/draft/render_output/_equation_captions.py,
_figure_captions.py and _tables.py each define references and
warnings, and _equation_captions.py:75 and _tables.py:78 are
identical. Refactor: one caption-kind table driving the three.drifted property is defined twice, on
core/draft/dossier/_drift.py:81 and core/draft/dossier/_status.py:60.
Refactor: a shared mixin, or a function both call.core/review/figure_layout/_scan.py::declaration
(12 branches) and core/figure/_focal.py::declaration (12 branches) walk
the same grammar: nested options, the first parenthesised group not
introduced by at, and the label brace. They return different
tuples. A spelling one learns, the other misses, which is the shape
of #1162. Refactor: one scanner returning (options, name, label, end).core/version.py:11 and
core/install.py:113 ask the installed metadata, while
core/envelope.py's version() reads this checkout's pyproject.toml
first. Under an editable install of another checkout, --version and
the report headers name different versions.
Refactor: one reader, in core/version.py.scripts/:
check_version_bump.py:168 (_git) and merge_pr.py:202 (_gh); a
third, relock.py's _run, went with that script in the move to uv.
Each re-derives "decode UTF-8, not the locale", and merge_pr
documents this by pointing at check_version_bump. Refactor: one
scripts/_proc.py.sidecar_path. Two are citekey-keyed
paths, core/draft/_passage_sidecar.py:17 and core/draft/tldr.py:41, the second
re-implementing the first's naming "the same way". The third,
core/evidence_appendix.py:120, is a different thing under the same name.
Refactor: one citekey-sidecar helper, and rename the third.run_stage
in core/corpus/enrich/keyword_extract.py, topic_converge.py,
topic_graph.py and topic_seeding.py each spell out {"status", "detail"}.
The placement was forced when the stages lived in
core/corpus/enrich/__main__.py at the C2 ceiling. They have since moved to
core/corpus/enrich/stages.py (72 code lines), so nothing still forces it.
Refactor: a StageResult constructor, with every stage's shaping in
stages.py.tests/conftest.py's isolated_config restates config's paths
by hand: 24 entries, CONTENT_DIR and the 23 paths derived from it in
core/config.py and core/config_enrich.py, "diffable by eye". A path added
to config and missed there leaves a test writing to the real
content/. Refactor: have config expose its derived-path table,
and build both from it.cli/corpus/sync.py::run,
core/corpus/discover/_render.py::render_topic,
core/corpus/enrich/docling_parse.py::parse_corpus,
core/corpus/enrich/topic_converge.py::run_topic_converge,
core/corpus/pdf_text/_converter.py::_docling_converter, seed_topics.py::report,
sync_pool.py::_drain_pool, core/draft/_markdown_inert.py::_Container._item,
core/draft/dossier/_versions.py::take,
core/draft/passages.py::source_passages,
core/draft/render_output/_pandoc.py::_pandoc_command,
core/review/verbatim_check/__init__.py::build_parser and
scripts/check_version_bump.py::main. A further 92 sit at 20 to 24.scripts/generate_unicode_sty.py and
merge_pr.py (248 each), check_version_bump.py (244) and
code_standards.py (243). The cost is already visible: R14's
scattered code, and tests/conftest.py's table, which exists to dodge
C1.core/draft/render_output/__init__.py is the hub of the render
path: 247 code lines, render at 25 statements and 10 parameters, and 50
private names imported from its own siblings. Refactor: a
RenderRequest value passed down, so render sequences steps and
does not thread arguments.core/draft/render_output/_pandoc.py::_pandoc_command takes 14 parameters.
Refactor: the same RenderRequest as R18.verbatim_check/_exact.py's _exact_finding:142,
_exact_findings_from_groups:93 and _exact_tier_findings:20.
Refactor: a scan-context object built once per scan.verbatim_check/_embed.py's _embed_tier_findings:21,
_findings_within:89 and _embed_finding:267. Refactor: the same
context object as R22.verbatim_check/_scan_cmd.py's scan_payload (8) and
build_verbatim_scan (7), and _scan_render.render_scan_markdown
(7), pass the same findings, limits and command trio from hand to
hand. Refactor: one scan result value.core/draft/dossier/_retrieval.py::log_retrieval takes 9
parameters, one per column of the row it writes. Refactor: pass the row.core/figure/_check.py::apply takes 7, and
cli/review/_emit.py::run takes 8, on every aid's output path.
Refactor: run takes an aid-output value, so adding an option means
changing one type, not 11 callers._-prefixed names are imported across module
boundaries. The leaders are core/draft/render_output/__init__.py (50),
core/overlap_index.py (26) and core/review/verbatim_check/__init__.py
(19). A leading underscore no longer tells a reader what is safe to
change. Refactor: promote the cross-module
ones, or re-export them through each package's __init__.chitragupta.cli.review._emit is imported by 12
modules: it is the review layer's printing API under a private name.
Refactor: make it cli/review/emit.py.render_output._figures has two de-facto-public helpers.
_resolve_sibling and _figure_refs are imported by 7 and 6
modules. Refactor: name them as the package's API.verbatim_check._shared._line_at and _masking._DraftWord are each
imported by 4 sibling modules. Refactor: the same promotion,
inside the package.scripts/generate_unicode_sty.py::_styled (14),
core/hook_launchers.py::faults (12), core/review/agenda/_render.py::_aid_note
(11), core/draft/_passage_records.py::passage_records (11) and
core/corpus/discover/_render.py::render_topic (11, and at 25 statements).
Refactor: table-driven dispatch where the branches are cases, as
_aid_note's are.core/draft/_markdown_inert.py holds two of them:
_Container._item (25 statements) and _container (10 branches), in a
247-line module. It is the code every gate run uses to tell prose from code
and comments. Refactor: split the block scanner from the inline one.Tiers 3 and 4 are empty. The numbers here are kept because .pylintrc,
ci.yml and pyproject.toml cite these subsections by number.
ci.yml's lint job enforces four tools, each at a binary
zero-findings bar, never a fail-under score, because
R3 rules out driving a number:
pylint --rcfile=.pylintrc chitragupta scripts .claude/hooksruff check chitragupta scripts .claude/hooksruff format --check chitragupta scripts tests bench .claude/hooksmarkdownlint-cli2 over the repository's own prose (root *.md,
docs/, .claude/, .agents/, .opencode/ and plans/)The configuration files are the authority for what each tool checks:
.pylintrc's disable= list carries the reason beside each disabled
category, and pyproject.toml's [tool.ruff] carries the ruff
selection. bench/ stays outside the linters by its own standing
decision; bench/README.md has the reasoning.
One gap is open. pylint's duplicate-code is in .pylintrc's
disable= list, and no other tool re-implements it for chitragupta/
or scripts/. A new duplicated block there is caught by nothing.
tests/test_duplicate_helper_scan.py covers module-level helpers in
tests/ only.
pylint: a measured baselineMeasured with the .pylintrc this project inherits from DTaaS, before
adoption: 9.50/10, 235 messages across chitragupta/ and scripts/.
Disabling the categories this repository decided against left 44 real
findings:
| Category | Count | Disposition |
|---|---|---|
line-too-long (>100) |
31 | Real. Fixed by wrapping |
unspecified-encoding |
7 | Fixed with the rest of the locale-codec sites; pylint saw only the open() calls |
invalid-name |
2 | pipeline_lock, interrupt_guard: deliberate lowercase context managers; in good-names |
| Miscellaneous | 4 | unused-import, trailing-newlines, use-maxsplit-arg, consider-using-with |
The disabled categories are decisions, each reasoned in .pylintrc:
import-outside-toplevel (the lazy-import pattern that keeps tier-1
modules stdlib-only at import time), the docstring checks (this project
requires why-comments, not a docstring on every small helper),
too-many-* (C1/C2 already measure size, more strictly),
broad-exception-caught (each site carries a stated cause, checked by
ruff's BLE001 instead) and duplicate-code (the open gap above).
The enrich group's third-party imports are in ignored-modules: they are
lazy imports that pylint still resolves statically, so a lint job that
does not install torch would otherwise report import-error at each.
markdownlint: a measured baselineThe baseline over the repository's prose, before adoption:
| Rule | Count | Note |
|---|---|---|
MD060/table-column-style |
827 | Table cell padding, 89% of the total; markdownlint-cli2 --fix applies it |
MD013/line-length |
37 | Low; prose here is wrapped short |
MD040/fenced-code-language |
30 | Real: fenced blocks with no language tag |
| Everything else | 33 | Blank lines around headings and lists, trailing newlines, emphasis style |
MD060's width arithmetic counts an escaped pipe (\|) as the two
characters it is in the source, not the one it renders as. Pad a table
cell that contains one to its source width.
Per-file exceptions are inline directives at the site that needs one.
An overrides: block in .markdownlint.yaml is inert: it is a
markdownlint-cli2 feature read only from .markdownlint-cli2.yaml.
ruff: a measured baselinepyproject.toml's [tool.ruff.lint] selects ["E", "F", "BLE", "RUF100"], deliberately narrower than ruff's own catalogue. BLE makes
a blind except a finding; RUF100 makes a # noqa: BLE001 a checked
claim instead of a comment nothing reads, so the suppression list and
the code cannot disagree. E501 enforces line length.
Baseline for that selection, with no per-file-ignores: 60 findings
across chitragupta/ and scripts/.
| Rule | Count | Disposition |
|---|---|---|
F401 unused-import |
41 | All in __init__.py re-exports; per-file-ignores |
E402 module-import-not-at-top |
11 | The same __init__.py files, importing late on purpose to dodge a circular import; per-file-ignores |
F821 undefined-name |
4 | A missing array import in chitragupta/core/overlap_skipgram.py; fixed |
BLE001 blind-except |
2 | Narrowed to the one exception actually raised; fixed |
E501 line-too-long |
1 | A table row inside an f-string template, which pylint's checker does not see; fixed |
RUF100 unused-noqa |
1 | A marker on an except that re-raises, which BLE001 exempts; removed |
The per-file-ignores entry is "__init__.py" = ["F401", "E402"],
because the pattern is identical at every site.
ruff's pin is exact. RUF100's verdict on an except block depends on
carve-outs such as the re-raise one above, which are narrower than
BLE001 looks. An unpinned bump could move that verdict and turn
ci.yml red on a rule this project never touched.
ruff format uses a fixed hanging indent, never alignment to the opening
paren. .git-blame-ignore-revs lists the whole-tree reformat commit so
git blame skips it; scripts/release.py excludes that file from the
release archive, because it means something only against this
repository's history.
This is the other half of this document's job. Every item below looks like a finding to a reviewer applying a checklist, and every one is a decision with its reasoning attached. Changing any of them makes the codebase worse.
| Looks like | Actually |
|---|---|
Very long comments; .github/workflows/ci.yml roughly half prose |
Debt, paid down deliberately. The comment rules keep only constraints that still bind; the rest is trimmed when a change touches it or in a dedicated PR (#1259), never as a drive-by |
Long developer documents (DEVELOPER-AGENTS.md, this directory) |
Length is not the defect. Shorten by turning a late-firing rule into a command or a check, never by deleting rationale. A word budget is a continuous score, which R3 rules out |
con.execute(f"PRAGMA user_version = {target}") (chitragupta/core/corpus/ledger.py:98) |
Not SQL injection. PRAGMA does not accept ? binding, and target is len(_MIGRATIONS), this module's own constant. The comment above it says exactly that |
_load_cache/_save_cache duplicated in core/draft/retrieval_cache.py and core/corpus/enrich/_docling_cache.py |
Different requirements, and each docstring names them: retrieval needs a per-writer-unique temp name for concurrent subagents and a per-process memo on the index file's (path, size, mtime_ns), because its payload is 14 MB and is read many times per run. Docling's is neither, and says why |
19 broad except Exception handlers in chitragupta/scripts (2 more in bench/) |
Each has a stated cause and a # noqa: BLE001 marker that ruff reads. See 5.4 |
--target host|docker accepted but never branched on |
Deliberate: the probes decide, the flag is informational. Removing it is a CLI break for no gain |
| C2 permits a registered module to grow | Deliberate. Pinning each to today's size fails on every ordinary edit and gets the rule turned off |
| No timestamp in any review report | A product rule: two runs over unchanged input produce byte-identical output, so reports diff across revisions |
| Tests duplicate setup instead of DRYing it | Adopted position: a test that reads top to bottom is worth more than a DRY one |
tests/core/corpus/test_pdf_text.py at over 2,000 code lines |
C2 does not cover tests, for a stated reason: a test module's length tracks the surface of the module under test |
| Tests duplicating setup, several asserts in one test, 2,000-line test modules, five tests with no assert | All four are checked positions, not drift; see .opencodereview/rule.json's tests entry. The assert-free five are documented "does not raise" tests |
class TestRealConfigToml in tests/core/test_config.py asserting against the real config.toml |
Deliberate and named in its own docstring: it is a sanity check on the constants as actually computed. Unlike the two cases tests/test_unversioned_data_scan.py guards against, it does not claim to be testing a default, which is why it is that scan's one registered exception rather than a fixed test |
bench/repro_check.py has no test module |
It self-checks instead. self_check() runs from main() on every invocation, with assertions proving the detector can see a difference before a zero from it is believed. It is a deliberate answer to bench/ sitting outside coverage, stated in its own docstring |
bench/ outside C1/C2, coverage, the release archive and the linters |
A decision, not arrears; bench/README.md's self-check section has the reasoning for each of the four |
Ordered by what breaks if it is left, not by size.
chitragupta/ and scripts/ goes undetected.
See Tier 5. The
cost is a fix landing in one copy and not the other. Any detector
added must be binary, like the others.Command: lines), R1 (doc_vectors.py's fixed temp
name), R11 (the version readers) and R4 (the finding ids the
agenda deduplicates on). Then R10, whose next TikZ spelling would
otherwise be taught to one scanner only.