Skip to content

feat(bindings): expose every resource limit in CLI, Python, Node and WASM - #40

Merged
chaliy merged 16 commits into
mainfrom
claude/project-thread-mx19ge
Oct 27, 2026
Merged

chaliy merged 16 commits into
mainfrom
claude/project-thread-mx19ge

Conversation

@chaliy

@chaliy chaliy commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

This is the follow-up to #27. Every markkit::Limits field can now be set outside Rust:

  • CLI: markkit extract gets a "Limits" help section with one flag per limit: --max-input-size (--max-size still works as an alias), --max-output-size, --timeout (seconds, fractions allowed), --max-nesting-depth, --max-nodes, the archive and sheet flags, and --max-redirects.
  • Python: new markkit.Limits(...) class, a frozen keyword-only constructor with readable attributes. Bad values raise ValueError/OverflowError. Every function accepts limits=.
  • Node.js: MarkkitOptions gets flat keys timeout (seconds, float, and it wins over maxProcessingSecs), maxOutputSize, maxNodes and maxNestingDepth. A negative or NaN timeout is rejected.
  • WASM: Options gets maxOutputSize, maxNodes and maxNestingDepth. There is no timeout, because wasm32 has no clock. Unknown keys throw, so passing timeout fails loudly instead of being ignored.
  • Parity: Node and WASM options also get baseUrl and mainContent (feat(html): resolve relative URLs against a base URL #31, feat(html): Readability-style main-content detection #38), and Python extract_html_sync_with_options gets base_url= and main_content=, so the bindings match the core builder.

The binding READMEs, the knowledge runtime docs and parity table, CHANGELOG and log are updated.

Why

The user asked for limits on every aspect. #27 added them to the core, and this PR makes them reachable from every runtime.

Before / After

Before: the CLI had only --max-size. Python had no limit arguments, and Node and WASM had no output, node or depth caps.
After (CLI, table-amplification input that renders 12 MB of Markdown):

$ markkit extract --file amp.html --max-output-size 1000000
Error: Resource limit exceeded: output exceeds max_output_size 1000000
$ markkit extract --file amp.html --timeout 0
Error: Resource limit exceeded: processing exceeded timeout of 0ns

Python smoke run:

>>> markkit.extract_html_sync('<p>x</p>'*100, limits=markkit.Limits(max_output_size=10))
Resource limit exceeded: output exceeds max_output_size 10   # raised
>>> markkit.Limits(timeout=2.5)
Limits(max_input_size=52428800, max_output_size=134217728, timeout=2.5, max_nesting_depth=256, ...)

Test results: Node options.test.cjs passes 9 of 9, WASM tests pass 19 of 19, and CLI unit and integration tests pass.

Risk

  • Low. All additions are optional, and defaults are unchanged. --max-size is kept.

Checklist

  • Tests added or updated
  • Backward compatibility considered

🤖 Generated with Claude Code

chaliy added 16 commits October 26, 2026 23:42
Move every resource limit into one markkit::Limits struct (bashkit
ExecutionLimits style) on MarkkitBuilder. New limits, generous defaults:

- timeout (60s) now bounds parsing and rendering, not only URL fetch
- max_output_size (128 MiB), checked per block/row; stops table
  amplification
- max_nodes (5M) for HTML DOM and DOCX XML nodes
- max_nesting_depth (256) configurable, hard ceiling 1024 for stack safety

Breaking: limit fields moved to builder.limits; max_processing_secs field
is now limits.timeout (setter kept).
…-mx19ge

# Conflicts:
#	CHANGELOG.md
#	crates/markkit/src/extract.rs
…-mx19ge

# Conflicts:
#	crates/markkit/src/config.rs
#	crates/markkit/src/extract.rs
#	crates/markkit/src/html/parser.rs
…-mx19ge

# Conflicts:
#	CHANGELOG.md
#	crates/markkit/src/extract.rs
#	crates/markkit/src/spreadsheet.rs
…-mx19ge

# Conflicts:
#	knowledge/security/threat-model.md
…WASM

CLI: --max-output-size, --timeout, --max-nesting-depth, --max-nodes plus
archive, sheet and redirect flags under a Limits help heading.
Python: markkit.Limits passed as limits= to every function.
Node: MarkkitOptions gains timeout (seconds), maxOutputSize, maxNodes,
maxNestingDepth. WASM Options gains maxOutputSize, maxNodes,
maxNestingDepth (no timeout: no clock on wasm32).
@chaliy chaliy self-assigned this Oct 27, 2026
@chaliy
chaliy merged commit a42819b into main Oct 27, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant