fix(tools): an array sent as its own JSON is still an array
## Summary
Reported as "deliver_files is broken". It is not: **the tool never ran.**
Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered:
```
Error: Invalid parameters for tool 'deliver_files': files should be array
```
What the model sent was the array, spelled as a string:
```json
{"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."}
```
`cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify.
## Type
- [x] Fix
- [ ] Feature
## The edge of the forgiving is the design
When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error.
**Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through.
**A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage.
## Not just deliver_files
Six built-in tools declare an array or object parameter and were all exposed:
| tool | parameter |
|---|---|
| `deliver_files` | `files` |
| `ask_user` | `questions` |
| `image_generate` | `images` |
| `message` | `media` |
| `create_playbook` | `skills` |
| `video_generate` | `params` |
The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch.
## Verification
```
make lint-python ruff check + ruff format --check, 1850 files
make lint-imports 9 contracts kept, 0 broken
pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below)
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots -- no user-facing string
**End to end, through the real tool**, with the exact payload that failed five times in production:
```
files sent as: str -> [{"path": ".../poster.png", "title": "..."}]
returned: Delivered 1 file(s): poster.png (72 B).
still "should be array": False
registered in the store: True
```
Twelve cases, five mutations, each killing at least one:
| mutation | red |
|---|---|
| drop the whole branch (the old behaviour) | 3 |
| raise instead of falling through on a parse failure | 5 |
| accept the parse whatever type it yielded | 1 |
| do not re-cast the parsed value, so items are not cast | 1 |
| widen the tuple to include `string` | **survived -- unreachable** |
The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so.
**Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own.
## Risk
- [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before
- [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed
- [x] Rollback path is clear -- single-commit revert
## Related Issues
N/A
## Swept
`mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`.
- **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects.
- **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`.
- **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case).
- **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts.
- **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none.
- **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value.
- **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed.
Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text).
## Deliberately not fixed
The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument.
## Moved from !594
Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name.
Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
|
|
|
"""CI gate against oversized files and report-asset file types in a revision range."""
|
|
|
|
|
|
ci: block report assets in pull request checks (#86)
## Summary
- Add a repository file policy check for pull request ranges.
- Reject report assets regardless of size, including images, GIFs, SVGs,
videos, audio files, PDFs, HTML files, web manifests, and WASM bundles.
- Keep the separate 1 MiB limit for any other added or modified file.
- Document the policy in AGENTS.md, CLAUDE.md, and CONTRIBUTING.md.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
Commands run:
- `make test-python`
- `make lint-python`
- `make check-large-files`
- `make check-commits`
- `uv run pre-commit run --files AGENTS.md CLAUDE.md CONTRIBUTING.md
scripts/check_large_files.py tests/test_large_file_check.py`
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-07-03 11:50:33 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import argparse
|
feat(ppt-engine): deliver where the user named, one route onto a page, and the ten templates
## Summary
This branch folds four merge requests and one unpushed commit into one, so that `main`
takes one review, one approval and one merge instead of four, and so the eight-file
overlap between them is resolved once. It carries, in this order:
- **!602** `feat/ppt_deliver_to_named_path` -- `ppt_build` takes `deliver_to`; every
publish writes the deck under `out/` and copies the same measured bytes to the path
the user named, recording it with `role: "delivery"`. The PDF preview rides along only
where its own `.pdf` name is free: a file already at that stem is the user's and is
left alone, and the reply says the preview stayed under `out/`.
- **!628** `feat/ppt_copy_route_and_page_isolation` -- `adapt` is removed, so cloning a
template page and writing into it with `replace_text` is the only route; a page whose
block raises loses only itself and the pages after it still build; a draft counts
against the tier's build cap and one is released at it.
- **!632** `feat/ship_templates_and_soffice_dep` -- the ten bundled deck templates are
tracked in git with per-file sha256 pins, so a fresh clone can build a deck; the
LibreOffice dependency is declared and resolved through one resolver.
- **!642** `fix/ppt_copy_route_and_clone_typography` -- a copy-route lookup that finds
nothing names the near miss before the inventory; a text frame with no paragraph at
all can be written into; a cloned page's title size is said; `row_type_drift` compares
the same structural slot across a run's units.
- **D57's other-page clause, rewired.** D57 gave five refusals a "did you mean" hint,
and one of them also answered "the string you named is on page N of this template".
That clause needs the file a page was cloned out of, and the only refusal holding it
was `adapt`'s, which !628 removed. It is restored by reading `PPT_TEMPLATE_SOURCE`,
which the runner already sets in the author's own process and which this module
already reads for `bundled()`; the two helpers behind the clause are unchanged.
- **D60** `read the ground under each word, not across the whole box` -- the `unreadable`
contrast gate also measures the render's own word boxes, as extra regions through the
same guards, so a two-line block crossed by a narrow bright ridge can no longer elect
the dark ground and read as legible.
Decisions the union forced, none of which drops a behaviour:
- The publish record is built !602's way, with its delivery `role`, and written the way
D49 requires -- read back off the file, atomic, and refused rather than silent when
the record cannot be written.
- `clear_region`, `shapes_in`, `page_box` and the refusal of a bare four-number region
survive `adapt`'s removal; so do `_heading_rows` and its helpers, which the row
reading loads even though the call they were written for is gone.
- The author-facing guidance names !628's single route and keeps D59's rule that a
region must declare which reading it is.
**The decision log carries a numbering collision, on purpose.** It is a set union with
no wording changed, and the numbers are left exactly as each branch wrote them, so a
reviewer meets this rather than discovers it:
- !602 and !628 each wrote a **D37** and a **D38**, about different decisions.
- !628's **D45** is not `main`'s D45; they are unrelated entries under one number.
- !628's **D42** is `main`'s **D45** word for word, so the merged log carries one
decision under two numbers.
Renumbering touches every cross-reference in the log, and doing that inside a
seventy-commit fold immediately before a merge is how a silent break gets in. The
numbering is being fixed on a separate branch, which carries a script and a test that
fails when a citation points at nothing.
## Type
- [x] Feature
- [x] Fix
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Run on an interpreter carrying `python-pptx`, with `PYTHONPATH` at this worktree and its
`plugins-dist/ppt-engine`, confirmed from a neutral working directory that `raven` and
`raven_ppt` resolve out of the worktree and not the host repo.
- `make test-python` (the whole suite, as CI runs it) -- 20826 passed, 49 skipped, and
26 failures this machine produces on any branch: it has no `/usr/share/zoneinfo`, so
every cron timezone case raises `ValueError: unknown timezone 'Asia/Shanghai'`. Checked
out plain `origin/main` in a clean worktree and ran the same two files: the same 6
failed and 20 errors, the ids identical character for character. Nothing on this branch
touches cron or timezones. The stale `test_trunks_executor_would_have_dropped_that_output`
that failed on the previous revision is retired on the new base and its replacement,
`test_trunks_executor_preserves_output_on_timeout`, was run on its own and passes.
The 6 failures and 20 errors are all cron timezone tests failing identically on plain
`main` in a clean worktree, on a host with no `/usr/share/zoneinfo`.
- `make check-commits` -- exit 0.
- `make check-source-language` -- exit 0.
- `make check-large-files` -- exit 0.
- `make lint-imports` -- exit 0, 9 contracts kept, 0 broken.
- `ruff check` and `ruff format --check` over the 80 changed Python files -- exit 0.
- `pytest tests/test_ppt_engine_templates.py tests/test_utils_office.py
tests/test_cli_doctor_commands.py` -- 97 passed; the ten templates are tracked and
satisfy their pins, and the soffice resolver finds the local binary.
- The delivery contract, the record read-back, the page isolation and the near miss were
each run as a measurement rather than asserted; the `unreadable` gate was run through
the real LibreOffice render chain on a delivered 12-page deck and reports BLOCKING on
page 12 under one word at 1.6:1.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
User-visible changes: `ppt_build` gains `deliver_to` and delivers outside `out/`;
`adapt` is gone from the author-facing template module, so a program calling it fails to
import -- `title=` and `subtitle=` have no replacement and the heading is named by the
words the template put there; a draft now counts against the tier's build cap; three
gates that nothing measured against being wrong no longer refuse; and the ten templates
are now bytes in the repository rather than a private registry fetch.
Two pieces here are about not destroying something the user has. The delivery
refuses to write its `.pdf` where a file the user already owns sits at the same
stem, rather than replacing it; and the large-file roster moved out of the manifest
inside the tree being checked and into the gate's own source, so a change can no
longer grant itself the exception the gate exists to withhold.
Rollback is per piece: each of the five sources is a contiguous run of commits on this
branch, in the order listed above, so any one of them can be reverted as a range without
touching the others.
- [x] Backward compatibility considered
- [x] Security impact considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-09-11 05:52:36 +00:00
|
|
|
import json
|
ci: block report assets in pull request checks (#86)
## Summary
- Add a repository file policy check for pull request ranges.
- Reject report assets regardless of size, including images, GIFs, SVGs,
videos, audio files, PDFs, HTML files, web manifests, and WASM bundles.
- Keep the separate 1 MiB limit for any other added or modified file.
- Document the policy in AGENTS.md, CLAUDE.md, and CONTRIBUTING.md.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
Commands run:
- `make test-python`
- `make lint-python`
- `make check-large-files`
- `make check-commits`
- `uv run pre-commit run --files AGENTS.md CLAUDE.md CONTRIBUTING.md
scripts/check_large_files.py tests/test_large_file_check.py`
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-07-03 11:50:33 +08:00
|
|
|
import os
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
from dataclasses import dataclass
|
fix(tools): an array sent as its own JSON is still an array
## Summary
Reported as "deliver_files is broken". It is not: **the tool never ran.**
Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered:
```
Error: Invalid parameters for tool 'deliver_files': files should be array
```
What the model sent was the array, spelled as a string:
```json
{"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."}
```
`cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify.
## Type
- [x] Fix
- [ ] Feature
## The edge of the forgiving is the design
When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error.
**Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through.
**A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage.
## Not just deliver_files
Six built-in tools declare an array or object parameter and were all exposed:
| tool | parameter |
|---|---|
| `deliver_files` | `files` |
| `ask_user` | `questions` |
| `image_generate` | `images` |
| `message` | `media` |
| `create_playbook` | `skills` |
| `video_generate` | `params` |
The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch.
## Verification
```
make lint-python ruff check + ruff format --check, 1850 files
make lint-imports 9 contracts kept, 0 broken
pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below)
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots -- no user-facing string
**End to end, through the real tool**, with the exact payload that failed five times in production:
```
files sent as: str -> [{"path": ".../poster.png", "title": "..."}]
returned: Delivered 1 file(s): poster.png (72 B).
still "should be array": False
registered in the store: True
```
Twelve cases, five mutations, each killing at least one:
| mutation | red |
|---|---|
| drop the whole branch (the old behaviour) | 3 |
| raise instead of falling through on a parse failure | 5 |
| accept the parse whatever type it yielded | 1 |
| do not re-cast the parsed value, so items are not cast | 1 |
| widen the tuple to include `string` | **survived -- unreachable** |
The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so.
**Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own.
## Risk
- [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before
- [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed
- [x] Rollback path is clear -- single-commit revert
## Related Issues
N/A
## Swept
`mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`.
- **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects.
- **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`.
- **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case).
- **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts.
- **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none.
- **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value.
- **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed.
Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text).
## Deliberately not fixed
The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument.
## Moved from !594
Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name.
Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
|
|
|
from pathlib import Path, PurePosixPath
|
ci: block report assets in pull request checks (#86)
## Summary
- Add a repository file policy check for pull request ranges.
- Reject report assets regardless of size, including images, GIFs, SVGs,
videos, audio files, PDFs, HTML files, web manifests, and WASM bundles.
- Keep the separate 1 MiB limit for any other added or modified file.
- Document the policy in AGENTS.md, CLAUDE.md, and CONTRIBUTING.md.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
Commands run:
- `make test-python`
- `make lint-python`
- `make check-large-files`
- `make check-commits`
- `uv run pre-commit run --files AGENTS.md CLAUDE.md CONTRIBUTING.md
scripts/check_large_files.py tests/test_large_file_check.py`
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-07-03 11:50:33 +08:00
|
|
|
|
|
|
|
|
ZERO_SHA = "0" * 40
|
|
|
|
|
DEFAULT_MAX_BYTES = 1024 * 1024
|
|
|
|
|
MAX_BYTES_ENV = "CHECK_LARGE_FILES_MAX_BYTES"
|
|
|
|
|
BLOCKED_ASSET_EXTENSIONS = {
|
|
|
|
|
".apng",
|
|
|
|
|
".avi",
|
|
|
|
|
".avif",
|
|
|
|
|
".bmp",
|
|
|
|
|
".aac",
|
|
|
|
|
".flv",
|
|
|
|
|
".flac",
|
|
|
|
|
".gif",
|
|
|
|
|
".heic",
|
|
|
|
|
".heif",
|
|
|
|
|
".htm",
|
|
|
|
|
".html",
|
|
|
|
|
".ico",
|
|
|
|
|
".jfif",
|
|
|
|
|
".jpeg",
|
|
|
|
|
".jpg",
|
|
|
|
|
".m4a",
|
|
|
|
|
".m4v",
|
|
|
|
|
".mkv",
|
|
|
|
|
".mov",
|
|
|
|
|
".mp3",
|
|
|
|
|
".mp4",
|
|
|
|
|
".mpeg",
|
|
|
|
|
".mpg",
|
|
|
|
|
".oga",
|
|
|
|
|
".ogg",
|
|
|
|
|
".ogv",
|
|
|
|
|
".opus",
|
|
|
|
|
".pdf",
|
|
|
|
|
".png",
|
|
|
|
|
".svg",
|
|
|
|
|
".tif",
|
|
|
|
|
".tiff",
|
|
|
|
|
".wasm",
|
|
|
|
|
".webm",
|
|
|
|
|
".webmanifest",
|
|
|
|
|
".webp",
|
|
|
|
|
".wmv",
|
|
|
|
|
".wav",
|
|
|
|
|
}
|
|
|
|
|
|
fix(tools): an array sent as its own JSON is still an array
## Summary
Reported as "deliver_files is broken". It is not: **the tool never ran.**
Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered:
```
Error: Invalid parameters for tool 'deliver_files': files should be array
```
What the model sent was the array, spelled as a string:
```json
{"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."}
```
`cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify.
## Type
- [x] Fix
- [ ] Feature
## The edge of the forgiving is the design
When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error.
**Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through.
**A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage.
## Not just deliver_files
Six built-in tools declare an array or object parameter and were all exposed:
| tool | parameter |
|---|---|
| `deliver_files` | `files` |
| `ask_user` | `questions` |
| `image_generate` | `images` |
| `message` | `media` |
| `create_playbook` | `skills` |
| `video_generate` | `params` |
The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch.
## Verification
```
make lint-python ruff check + ruff format --check, 1850 files
make lint-imports 9 contracts kept, 0 broken
pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below)
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots -- no user-facing string
**End to end, through the real tool**, with the exact payload that failed five times in production:
```
files sent as: str -> [{"path": ".../poster.png", "title": "..."}]
returned: Delivered 1 file(s): poster.png (72 B).
still "should be array": False
registered in the store: True
```
Twelve cases, five mutations, each killing at least one:
| mutation | red |
|---|---|
| drop the whole branch (the old behaviour) | 3 |
| raise instead of falling through on a parse failure | 5 |
| accept the parse whatever type it yielded | 1 |
| do not re-cast the parsed value, so items are not cast | 1 |
| widen the tuple to include `string` | **survived -- unreachable** |
The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so.
**Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own.
## Risk
- [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before
- [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed
- [x] Rollback path is clear -- single-commit revert
## Related Issues
N/A
## Swept
`mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`.
- **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects.
- **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`.
- **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case).
- **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts.
- **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none.
- **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value.
- **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed.
Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text).
## Deliberately not fixed
The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument.
## Moved from !594
Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name.
Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
|
|
|
# The asset ban targets report assets and standalone web artifacts. A product
|
|
|
|
|
# frontend legitimately carries its own entry HTML and icon SVGs as source, so
|
|
|
|
|
# these trees are exempt from the extension list. The size limit still applies.
|
|
|
|
|
APP_SOURCE_PREFIXES = (
|
|
|
|
|
"bridge/",
|
|
|
|
|
# "ui-web/" is not a prefix of "ui-tui/" -- the slash ends it -- so each
|
|
|
|
|
# entry matches its own tree and nothing else.
|
|
|
|
|
"ui-web/",
|
|
|
|
|
"ui-tui/",
|
|
|
|
|
)
|
|
|
|
|
ALLOWED_SKILL_REFERENCE_IMAGE_EXTENSIONS = frozenset({".jpg"})
|
chore: add git story film skill (#810)
## Summary
Add a self-contained git-story-film skill for turning repository history
into animated product stories, including the drawing engine, production
helpers, and a complete Raven example.
- Provide English instructions and a Chinese README while preserving the
Chinese film variant and bilingual captions.
- Fix bundled example script paths and bring the Python helpers into
compliance with Ruff.
- Keep the bundled storyboard as a text-only reference with all 24 shots
and bilingual captions. No pre-rendered images are bundled; the studio
draws storyboard frames from code.
- Allow only the required example HTML and localized source data through
the repository gates. Keep the 1 MiB limit; standalone images, generated
exports, neighboring paths, and unsupported assets remain blocked.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [x] Other
## Verification
- `uv run pre-commit run --from-ref origin/main --to-ref HEAD`: all
applicable hooks passed after rebasing onto the latest upstream main.
- `make lint-python`: passed, including format checks for 2,147 files.
- `make lint-types`: passed.
- `make lint-imports lint-deps`: passed; all 10 import contracts held.
- `uv run ruff format --check skills/git-story-film`: passed.
- `uv run ruff check skills/git-story-film`: passed.
- `uv run pytest tests/test_large_file_check.py
tests/test_source_language_check.py -q -o addopts=''
--idle-ceiling-strict`: 50 passed.
- `make check-large-files check-source-language`: passed on the complete
committed PR diff.
Full CI, browser playback, and MP4 rendering have not been verified
locally.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
The skill is an optional development tool and does not change Raven
runtime behavior. Repository policy exceptions are limited to documented
paths; other assets and oversized files remain blocked. Roll back by
reverting this change, including the skill and its matching gate
exceptions.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
Co-authored-by: Codex <noreply@openai.com>
2026-09-27 12:56:53 +08:00
|
|
|
GIT_STORY_FILM_HTML_FILES = frozenset(
|
|
|
|
|
{
|
|
|
|
|
"skills/git-story-film/examples/raven-story/raven.html",
|
|
|
|
|
"skills/git-story-film/examples/raven-story/cast-sheet.html",
|
|
|
|
|
"skills/git-story-film/examples/raven-story/storyboard/storyboard.html",
|
|
|
|
|
}
|
|
|
|
|
)
|
fix(tools): an array sent as its own JSON is still an array
## Summary
Reported as "deliver_files is broken". It is not: **the tool never ran.**
Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered:
```
Error: Invalid parameters for tool 'deliver_files': files should be array
```
What the model sent was the array, spelled as a string:
```json
{"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."}
```
`cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify.
## Type
- [x] Fix
- [ ] Feature
## The edge of the forgiving is the design
When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error.
**Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through.
**A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage.
## Not just deliver_files
Six built-in tools declare an array or object parameter and were all exposed:
| tool | parameter |
|---|---|
| `deliver_files` | `files` |
| `ask_user` | `questions` |
| `image_generate` | `images` |
| `message` | `media` |
| `create_playbook` | `skills` |
| `video_generate` | `params` |
The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch.
## Verification
```
make lint-python ruff check + ruff format --check, 1850 files
make lint-imports 9 contracts kept, 0 broken
pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below)
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots -- no user-facing string
**End to end, through the real tool**, with the exact payload that failed five times in production:
```
files sent as: str -> [{"path": ".../poster.png", "title": "..."}]
returned: Delivered 1 file(s): poster.png (72 B).
still "should be array": False
registered in the store: True
```
Twelve cases, five mutations, each killing at least one:
| mutation | red |
|---|---|
| drop the whole branch (the old behaviour) | 3 |
| raise instead of falling through on a parse failure | 5 |
| accept the parse whatever type it yielded | 1 |
| do not re-cast the parsed value, so items are not cast | 1 |
| widen the tuple to include `string` | **survived -- unreachable** |
The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so.
**Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own.
## Risk
- [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before
- [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed
- [x] Rollback path is clear -- single-commit revert
## Related Issues
N/A
## Swept
`mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`.
- **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects.
- **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`.
- **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case).
- **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts.
- **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none.
- **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value.
- **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed.
Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text).
## Deliberately not fixed
The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument.
## Moved from !594
Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name.
Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
|
|
|
# The one home of the raven-design skill plates: the design-engine wheel they
|
|
|
|
|
# migrated to (verdict C4; the frozen fork seat retired with the tree). The
|
|
|
|
|
# rule is unchanged: .jpg only, only under a skill's references/, and the
|
|
|
|
|
# 1 MiB ceiling still applies.
|
|
|
|
|
RAVEN_DESIGN_SKILL_PREFIXES = (
|
|
|
|
|
(
|
|
|
|
|
"plugins-dist",
|
|
|
|
|
"design-engine",
|
|
|
|
|
"raven_design",
|
|
|
|
|
"skills",
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
feat(ppt-engine): deliver where the user named, one route onto a page, and the ten templates
## Summary
This branch folds four merge requests and one unpushed commit into one, so that `main`
takes one review, one approval and one merge instead of four, and so the eight-file
overlap between them is resolved once. It carries, in this order:
- **!602** `feat/ppt_deliver_to_named_path` -- `ppt_build` takes `deliver_to`; every
publish writes the deck under `out/` and copies the same measured bytes to the path
the user named, recording it with `role: "delivery"`. The PDF preview rides along only
where its own `.pdf` name is free: a file already at that stem is the user's and is
left alone, and the reply says the preview stayed under `out/`.
- **!628** `feat/ppt_copy_route_and_page_isolation` -- `adapt` is removed, so cloning a
template page and writing into it with `replace_text` is the only route; a page whose
block raises loses only itself and the pages after it still build; a draft counts
against the tier's build cap and one is released at it.
- **!632** `feat/ship_templates_and_soffice_dep` -- the ten bundled deck templates are
tracked in git with per-file sha256 pins, so a fresh clone can build a deck; the
LibreOffice dependency is declared and resolved through one resolver.
- **!642** `fix/ppt_copy_route_and_clone_typography` -- a copy-route lookup that finds
nothing names the near miss before the inventory; a text frame with no paragraph at
all can be written into; a cloned page's title size is said; `row_type_drift` compares
the same structural slot across a run's units.
- **D57's other-page clause, rewired.** D57 gave five refusals a "did you mean" hint,
and one of them also answered "the string you named is on page N of this template".
That clause needs the file a page was cloned out of, and the only refusal holding it
was `adapt`'s, which !628 removed. It is restored by reading `PPT_TEMPLATE_SOURCE`,
which the runner already sets in the author's own process and which this module
already reads for `bundled()`; the two helpers behind the clause are unchanged.
- **D60** `read the ground under each word, not across the whole box` -- the `unreadable`
contrast gate also measures the render's own word boxes, as extra regions through the
same guards, so a two-line block crossed by a narrow bright ridge can no longer elect
the dark ground and read as legible.
Decisions the union forced, none of which drops a behaviour:
- The publish record is built !602's way, with its delivery `role`, and written the way
D49 requires -- read back off the file, atomic, and refused rather than silent when
the record cannot be written.
- `clear_region`, `shapes_in`, `page_box` and the refusal of a bare four-number region
survive `adapt`'s removal; so do `_heading_rows` and its helpers, which the row
reading loads even though the call they were written for is gone.
- The author-facing guidance names !628's single route and keeps D59's rule that a
region must declare which reading it is.
**The decision log carries a numbering collision, on purpose.** It is a set union with
no wording changed, and the numbers are left exactly as each branch wrote them, so a
reviewer meets this rather than discovers it:
- !602 and !628 each wrote a **D37** and a **D38**, about different decisions.
- !628's **D45** is not `main`'s D45; they are unrelated entries under one number.
- !628's **D42** is `main`'s **D45** word for word, so the merged log carries one
decision under two numbers.
Renumbering touches every cross-reference in the log, and doing that inside a
seventy-commit fold immediately before a merge is how a silent break gets in. The
numbering is being fixed on a separate branch, which carries a script and a test that
fails when a citation points at nothing.
## Type
- [x] Feature
- [x] Fix
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Run on an interpreter carrying `python-pptx`, with `PYTHONPATH` at this worktree and its
`plugins-dist/ppt-engine`, confirmed from a neutral working directory that `raven` and
`raven_ppt` resolve out of the worktree and not the host repo.
- `make test-python` (the whole suite, as CI runs it) -- 20826 passed, 49 skipped, and
26 failures this machine produces on any branch: it has no `/usr/share/zoneinfo`, so
every cron timezone case raises `ValueError: unknown timezone 'Asia/Shanghai'`. Checked
out plain `origin/main` in a clean worktree and ran the same two files: the same 6
failed and 20 errors, the ids identical character for character. Nothing on this branch
touches cron or timezones. The stale `test_trunks_executor_would_have_dropped_that_output`
that failed on the previous revision is retired on the new base and its replacement,
`test_trunks_executor_preserves_output_on_timeout`, was run on its own and passes.
The 6 failures and 20 errors are all cron timezone tests failing identically on plain
`main` in a clean worktree, on a host with no `/usr/share/zoneinfo`.
- `make check-commits` -- exit 0.
- `make check-source-language` -- exit 0.
- `make check-large-files` -- exit 0.
- `make lint-imports` -- exit 0, 9 contracts kept, 0 broken.
- `ruff check` and `ruff format --check` over the 80 changed Python files -- exit 0.
- `pytest tests/test_ppt_engine_templates.py tests/test_utils_office.py
tests/test_cli_doctor_commands.py` -- 97 passed; the ten templates are tracked and
satisfy their pins, and the soffice resolver finds the local binary.
- The delivery contract, the record read-back, the page isolation and the near miss were
each run as a measurement rather than asserted; the `unreadable` gate was run through
the real LibreOffice render chain on a delivered 12-page deck and reports BLOCKING on
page 12 under one word at 1.6:1.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
User-visible changes: `ppt_build` gains `deliver_to` and delivers outside `out/`;
`adapt` is gone from the author-facing template module, so a program calling it fails to
import -- `title=` and `subtitle=` have no replacement and the heading is named by the
words the template put there; a draft now counts against the tier's build cap; three
gates that nothing measured against being wrong no longer refuse; and the ten templates
are now bytes in the repository rather than a private registry fetch.
Two pieces here are about not destroying something the user has. The delivery
refuses to write its `.pdf` where a file the user already owns sits at the same
stem, rather than replacing it; and the large-file roster moved out of the manifest
inside the tree being checked and into the gate's own source, so a change can no
longer grant itself the exception the gate exists to withhold.
Rollback is per piece: each of the five sources is a contiguous run of commits on this
branch, in the order listed above, so any one of them can be reverted as a range without
touching the others.
- [x] Backward compatibility considered
- [x] Security impact considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-09-11 05:52:36 +00:00
|
|
|
# The ten bundled deck templates the ppt engine offers a task that brings no
|
|
|
|
|
# template of its own. They are tracked because a fresh clone that cannot build
|
|
|
|
|
# a deck is not an install, and seven of them clear the 1 MiB ceiling; the
|
|
|
|
|
# maintainer approved that exception when they entered git.
|
|
|
|
|
#
|
|
|
|
|
# The roster is written out here rather than read from the engine's manifest.
|
|
|
|
|
# A gate that takes its own exception list from a file in the tree it is
|
|
|
|
|
# checking grants exceptions to whoever edits that file, which is the change
|
|
|
|
|
# under review -- adding an oversized file plus a manifest entry would pass.
|
|
|
|
|
# AGENTS.md section 7 wants a per-file maintainer decision, so an eleventh
|
|
|
|
|
# template has to be added here, in the diff a reviewer reads, and the manifest
|
|
|
|
|
# goes on verifying that the bytes are the ones that were approved.
|
|
|
|
|
BUNDLED_DECK_TEMPLATE_DIR = "plugins-dist/ppt-engine/raven_ppt/assets/templates"
|
|
|
|
|
BUNDLED_DECK_TEMPLATE_MANIFEST = "plugins-dist/ppt-engine/templates.manifest.json"
|
|
|
|
|
PINNED_DECK_TEMPLATES = frozenset(
|
|
|
|
|
{
|
|
|
|
|
"amber_wave_quarterly_summary.pptx",
|
|
|
|
|
"beige_geometric_general_report.pptx",
|
|
|
|
|
"black_circuit_tech_launch.pptx",
|
|
|
|
|
"blue_minimal_general_analysis.pptx",
|
|
|
|
|
"gold_panel_year_end_summary.pptx",
|
|
|
|
|
"green_aurora_tech_trends.pptx",
|
|
|
|
|
"mint_memphis_thesis_defense.pptx",
|
|
|
|
|
"red_chinese_traditional_culture.pptx",
|
|
|
|
|
"teal_illustrated_work_analysis.pptx",
|
|
|
|
|
"warm_bauhaus_quarterly_review.pptx",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
ci: block report assets in pull request checks (#86)
## Summary
- Add a repository file policy check for pull request ranges.
- Reject report assets regardless of size, including images, GIFs, SVGs,
videos, audio files, PDFs, HTML files, web manifests, and WASM bundles.
- Keep the separate 1 MiB limit for any other added or modified file.
- Document the policy in AGENTS.md, CLAUDE.md, and CONTRIBUTING.md.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
Commands run:
- `make test-python`
- `make lint-python`
- `make check-large-files`
- `make check-commits`
- `uv run pre-commit run --files AGENTS.md CLAUDE.md CONTRIBUTING.md
scripts/check_large_files.py tests/test_large_file_check.py`
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-07-03 11:50:33 +08:00
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
class FileSizeViolation:
|
|
|
|
|
path: str
|
|
|
|
|
size: int
|
|
|
|
|
limit: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
class BlockedAssetViolation:
|
|
|
|
|
path: str
|
|
|
|
|
extension: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
|
|
|
parser = argparse.ArgumentParser(description="Fail when a PR adds oversized files or blocked report assets.")
|
|
|
|
|
parser.add_argument("revision_range", nargs="?", default=_default_range())
|
|
|
|
|
parser.add_argument("--max-bytes", type=_positive_int, default=_default_max_bytes())
|
|
|
|
|
parser.add_argument("--root", type=Path, default=Path("."))
|
|
|
|
|
args = parser.parse_args(sys.argv[1:] if argv is None else argv)
|
|
|
|
|
|
|
|
|
|
if not args.revision_range:
|
|
|
|
|
print("No commit range detected; skipping large file check")
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
paths = changed_paths(args.revision_range)
|
|
|
|
|
size_violations = find_oversized_files(
|
|
|
|
|
paths,
|
|
|
|
|
max_bytes=args.max_bytes,
|
|
|
|
|
root=args.root,
|
|
|
|
|
)
|
|
|
|
|
asset_violations = find_blocked_asset_files(paths, root=args.root)
|
|
|
|
|
if not size_violations and not asset_violations:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
if size_violations:
|
|
|
|
|
print("Oversized files are not allowed in PRs:", file=sys.stderr)
|
|
|
|
|
for violation in size_violations:
|
|
|
|
|
print(
|
|
|
|
|
f"- {violation.path}: {format_bytes(violation.size)} > {format_bytes(violation.limit)}",
|
|
|
|
|
file=sys.stderr,
|
|
|
|
|
)
|
|
|
|
|
if asset_violations:
|
|
|
|
|
print("Blocked asset files are not allowed in PRs:", file=sys.stderr)
|
|
|
|
|
for violation in asset_violations:
|
|
|
|
|
print(f"- {violation.path}: {violation.extension} files should be stored outside git", file=sys.stderr)
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def find_oversized_files(paths: list[str], *, max_bytes: int, root: Path) -> list[FileSizeViolation]:
|
|
|
|
|
violations: list[FileSizeViolation] = []
|
|
|
|
|
seen: set[str] = set()
|
|
|
|
|
for path in paths:
|
|
|
|
|
if not path or path in seen:
|
|
|
|
|
continue
|
|
|
|
|
seen.add(path)
|
feat(ppt-engine): deliver where the user named, one route onto a page, and the ten templates
## Summary
This branch folds four merge requests and one unpushed commit into one, so that `main`
takes one review, one approval and one merge instead of four, and so the eight-file
overlap between them is resolved once. It carries, in this order:
- **!602** `feat/ppt_deliver_to_named_path` -- `ppt_build` takes `deliver_to`; every
publish writes the deck under `out/` and copies the same measured bytes to the path
the user named, recording it with `role: "delivery"`. The PDF preview rides along only
where its own `.pdf` name is free: a file already at that stem is the user's and is
left alone, and the reply says the preview stayed under `out/`.
- **!628** `feat/ppt_copy_route_and_page_isolation` -- `adapt` is removed, so cloning a
template page and writing into it with `replace_text` is the only route; a page whose
block raises loses only itself and the pages after it still build; a draft counts
against the tier's build cap and one is released at it.
- **!632** `feat/ship_templates_and_soffice_dep` -- the ten bundled deck templates are
tracked in git with per-file sha256 pins, so a fresh clone can build a deck; the
LibreOffice dependency is declared and resolved through one resolver.
- **!642** `fix/ppt_copy_route_and_clone_typography` -- a copy-route lookup that finds
nothing names the near miss before the inventory; a text frame with no paragraph at
all can be written into; a cloned page's title size is said; `row_type_drift` compares
the same structural slot across a run's units.
- **D57's other-page clause, rewired.** D57 gave five refusals a "did you mean" hint,
and one of them also answered "the string you named is on page N of this template".
That clause needs the file a page was cloned out of, and the only refusal holding it
was `adapt`'s, which !628 removed. It is restored by reading `PPT_TEMPLATE_SOURCE`,
which the runner already sets in the author's own process and which this module
already reads for `bundled()`; the two helpers behind the clause are unchanged.
- **D60** `read the ground under each word, not across the whole box` -- the `unreadable`
contrast gate also measures the render's own word boxes, as extra regions through the
same guards, so a two-line block crossed by a narrow bright ridge can no longer elect
the dark ground and read as legible.
Decisions the union forced, none of which drops a behaviour:
- The publish record is built !602's way, with its delivery `role`, and written the way
D49 requires -- read back off the file, atomic, and refused rather than silent when
the record cannot be written.
- `clear_region`, `shapes_in`, `page_box` and the refusal of a bare four-number region
survive `adapt`'s removal; so do `_heading_rows` and its helpers, which the row
reading loads even though the call they were written for is gone.
- The author-facing guidance names !628's single route and keeps D59's rule that a
region must declare which reading it is.
**The decision log carries a numbering collision, on purpose.** It is a set union with
no wording changed, and the numbers are left exactly as each branch wrote them, so a
reviewer meets this rather than discovers it:
- !602 and !628 each wrote a **D37** and a **D38**, about different decisions.
- !628's **D45** is not `main`'s D45; they are unrelated entries under one number.
- !628's **D42** is `main`'s **D45** word for word, so the merged log carries one
decision under two numbers.
Renumbering touches every cross-reference in the log, and doing that inside a
seventy-commit fold immediately before a merge is how a silent break gets in. The
numbering is being fixed on a separate branch, which carries a script and a test that
fails when a citation points at nothing.
## Type
- [x] Feature
- [x] Fix
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Run on an interpreter carrying `python-pptx`, with `PYTHONPATH` at this worktree and its
`plugins-dist/ppt-engine`, confirmed from a neutral working directory that `raven` and
`raven_ppt` resolve out of the worktree and not the host repo.
- `make test-python` (the whole suite, as CI runs it) -- 20826 passed, 49 skipped, and
26 failures this machine produces on any branch: it has no `/usr/share/zoneinfo`, so
every cron timezone case raises `ValueError: unknown timezone 'Asia/Shanghai'`. Checked
out plain `origin/main` in a clean worktree and ran the same two files: the same 6
failed and 20 errors, the ids identical character for character. Nothing on this branch
touches cron or timezones. The stale `test_trunks_executor_would_have_dropped_that_output`
that failed on the previous revision is retired on the new base and its replacement,
`test_trunks_executor_preserves_output_on_timeout`, was run on its own and passes.
The 6 failures and 20 errors are all cron timezone tests failing identically on plain
`main` in a clean worktree, on a host with no `/usr/share/zoneinfo`.
- `make check-commits` -- exit 0.
- `make check-source-language` -- exit 0.
- `make check-large-files` -- exit 0.
- `make lint-imports` -- exit 0, 9 contracts kept, 0 broken.
- `ruff check` and `ruff format --check` over the 80 changed Python files -- exit 0.
- `pytest tests/test_ppt_engine_templates.py tests/test_utils_office.py
tests/test_cli_doctor_commands.py` -- 97 passed; the ten templates are tracked and
satisfy their pins, and the soffice resolver finds the local binary.
- The delivery contract, the record read-back, the page isolation and the near miss were
each run as a measurement rather than asserted; the `unreadable` gate was run through
the real LibreOffice render chain on a delivered 12-page deck and reports BLOCKING on
page 12 under one word at 1.6:1.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
User-visible changes: `ppt_build` gains `deliver_to` and delivers outside `out/`;
`adapt` is gone from the author-facing template module, so a program calling it fails to
import -- `title=` and `subtitle=` have no replacement and the heading is named by the
words the template put there; a draft now counts against the tier's build cap; three
gates that nothing measured against being wrong no longer refuse; and the ten templates
are now bytes in the repository rather than a private registry fetch.
Two pieces here are about not destroying something the user has. The delivery
refuses to write its `.pdf` where a file the user already owns sits at the same
stem, rather than replacing it; and the large-file roster moved out of the manifest
inside the tree being checked and into the gate's own source, so a change can no
longer grant itself the exception the gate exists to withhold.
Rollback is per piece: each of the five sources is a contiguous run of commits on this
branch, in the order listed above, so any one of them can be reverted as a range without
touching the others.
- [x] Backward compatibility considered
- [x] Security impact considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-09-11 05:52:36 +00:00
|
|
|
if _is_pinned_deck_template(path):
|
|
|
|
|
continue
|
ci: block report assets in pull request checks (#86)
## Summary
- Add a repository file policy check for pull request ranges.
- Reject report assets regardless of size, including images, GIFs, SVGs,
videos, audio files, PDFs, HTML files, web manifests, and WASM bundles.
- Keep the separate 1 MiB limit for any other added or modified file.
- Document the policy in AGENTS.md, CLAUDE.md, and CONTRIBUTING.md.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
Commands run:
- `make test-python`
- `make lint-python`
- `make check-large-files`
- `make check-commits`
- `uv run pre-commit run --files AGENTS.md CLAUDE.md CONTRIBUTING.md
scripts/check_large_files.py tests/test_large_file_check.py`
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-07-03 11:50:33 +08:00
|
|
|
candidate = root / path
|
|
|
|
|
if not candidate.is_file():
|
|
|
|
|
continue
|
|
|
|
|
size = candidate.stat().st_size
|
|
|
|
|
if size > max_bytes:
|
|
|
|
|
violations.append(FileSizeViolation(path=path, size=size, limit=max_bytes))
|
|
|
|
|
return violations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def find_blocked_asset_files(paths: list[str], *, root: Path) -> list[BlockedAssetViolation]:
|
|
|
|
|
violations: list[BlockedAssetViolation] = []
|
|
|
|
|
seen: set[str] = set()
|
|
|
|
|
for path in paths:
|
|
|
|
|
if not path or path in seen:
|
|
|
|
|
continue
|
|
|
|
|
seen.add(path)
|
fix(tools): an array sent as its own JSON is still an array
## Summary
Reported as "deliver_files is broken". It is not: **the tool never ran.**
Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered:
```
Error: Invalid parameters for tool 'deliver_files': files should be array
```
What the model sent was the array, spelled as a string:
```json
{"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."}
```
`cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify.
## Type
- [x] Fix
- [ ] Feature
## The edge of the forgiving is the design
When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error.
**Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through.
**A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage.
## Not just deliver_files
Six built-in tools declare an array or object parameter and were all exposed:
| tool | parameter |
|---|---|
| `deliver_files` | `files` |
| `ask_user` | `questions` |
| `image_generate` | `images` |
| `message` | `media` |
| `create_playbook` | `skills` |
| `video_generate` | `params` |
The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch.
## Verification
```
make lint-python ruff check + ruff format --check, 1850 files
make lint-imports 9 contracts kept, 0 broken
pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below)
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots -- no user-facing string
**End to end, through the real tool**, with the exact payload that failed five times in production:
```
files sent as: str -> [{"path": ".../poster.png", "title": "..."}]
returned: Delivered 1 file(s): poster.png (72 B).
still "should be array": False
registered in the store: True
```
Twelve cases, five mutations, each killing at least one:
| mutation | red |
|---|---|
| drop the whole branch (the old behaviour) | 3 |
| raise instead of falling through on a parse failure | 5 |
| accept the parse whatever type it yielded | 1 |
| do not re-cast the parsed value, so items are not cast | 1 |
| widen the tuple to include `string` | **survived -- unreachable** |
The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so.
**Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own.
## Risk
- [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before
- [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed
- [x] Rollback path is clear -- single-commit revert
## Related Issues
N/A
## Swept
`mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`.
- **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects.
- **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`.
- **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case).
- **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts.
- **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none.
- **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value.
- **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed.
Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text).
## Deliberately not fixed
The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument.
## Moved from !594
Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name.
Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
|
|
|
if path.startswith(APP_SOURCE_PREFIXES):
|
|
|
|
|
continue
|
ci: block report assets in pull request checks (#86)
## Summary
- Add a repository file policy check for pull request ranges.
- Reject report assets regardless of size, including images, GIFs, SVGs,
videos, audio files, PDFs, HTML files, web manifests, and WASM bundles.
- Keep the separate 1 MiB limit for any other added or modified file.
- Document the policy in AGENTS.md, CLAUDE.md, and CONTRIBUTING.md.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
Commands run:
- `make test-python`
- `make lint-python`
- `make check-large-files`
- `make check-commits`
- `uv run pre-commit run --files AGENTS.md CLAUDE.md CONTRIBUTING.md
scripts/check_large_files.py tests/test_large_file_check.py`
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-07-03 11:50:33 +08:00
|
|
|
candidate = root / path
|
|
|
|
|
if not candidate.is_file():
|
|
|
|
|
continue
|
|
|
|
|
extension = candidate.suffix.lower()
|
chore: add git story film skill (#810)
## Summary
Add a self-contained git-story-film skill for turning repository history
into animated product stories, including the drawing engine, production
helpers, and a complete Raven example.
- Provide English instructions and a Chinese README while preserving the
Chinese film variant and bilingual captions.
- Fix bundled example script paths and bring the Python helpers into
compliance with Ruff.
- Keep the bundled storyboard as a text-only reference with all 24 shots
and bilingual captions. No pre-rendered images are bundled; the studio
draws storyboard frames from code.
- Allow only the required example HTML and localized source data through
the repository gates. Keep the 1 MiB limit; standalone images, generated
exports, neighboring paths, and unsupported assets remain blocked.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [x] Other
## Verification
- `uv run pre-commit run --from-ref origin/main --to-ref HEAD`: all
applicable hooks passed after rebasing onto the latest upstream main.
- `make lint-python`: passed, including format checks for 2,147 files.
- `make lint-types`: passed.
- `make lint-imports lint-deps`: passed; all 10 import contracts held.
- `uv run ruff format --check skills/git-story-film`: passed.
- `uv run ruff check skills/git-story-film`: passed.
- `uv run pytest tests/test_large_file_check.py
tests/test_source_language_check.py -q -o addopts=''
--idle-ceiling-strict`: 50 passed.
- `make check-large-files check-source-language`: passed on the complete
committed PR diff.
Full CI, browser playback, and MP4 rendering have not been verified
locally.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
The skill is an optional development tool and does not change Raven
runtime behavior. Repository policy exceptions are limited to documented
paths; other assets and oversized files remain blocked. Roll back by
reverting this change, including the skill and its matching gate
exceptions.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
Co-authored-by: Codex <noreply@openai.com>
2026-09-27 12:56:53 +08:00
|
|
|
if (
|
|
|
|
|
extension in BLOCKED_ASSET_EXTENSIONS
|
|
|
|
|
and not _is_allowed_skill_reference_image(path, extension)
|
|
|
|
|
and path not in GIT_STORY_FILM_HTML_FILES
|
|
|
|
|
):
|
ci: block report assets in pull request checks (#86)
## Summary
- Add a repository file policy check for pull request ranges.
- Reject report assets regardless of size, including images, GIFs, SVGs,
videos, audio files, PDFs, HTML files, web manifests, and WASM bundles.
- Keep the separate 1 MiB limit for any other added or modified file.
- Document the policy in AGENTS.md, CLAUDE.md, and CONTRIBUTING.md.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
Commands run:
- `make test-python`
- `make lint-python`
- `make check-large-files`
- `make check-commits`
- `uv run pre-commit run --files AGENTS.md CLAUDE.md CONTRIBUTING.md
scripts/check_large_files.py tests/test_large_file_check.py`
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-07-03 11:50:33 +08:00
|
|
|
violations.append(BlockedAssetViolation(path=path, extension=extension))
|
|
|
|
|
return violations
|
|
|
|
|
|
|
|
|
|
|
feat(ppt-engine): deliver where the user named, one route onto a page, and the ten templates
## Summary
This branch folds four merge requests and one unpushed commit into one, so that `main`
takes one review, one approval and one merge instead of four, and so the eight-file
overlap between them is resolved once. It carries, in this order:
- **!602** `feat/ppt_deliver_to_named_path` -- `ppt_build` takes `deliver_to`; every
publish writes the deck under `out/` and copies the same measured bytes to the path
the user named, recording it with `role: "delivery"`. The PDF preview rides along only
where its own `.pdf` name is free: a file already at that stem is the user's and is
left alone, and the reply says the preview stayed under `out/`.
- **!628** `feat/ppt_copy_route_and_page_isolation` -- `adapt` is removed, so cloning a
template page and writing into it with `replace_text` is the only route; a page whose
block raises loses only itself and the pages after it still build; a draft counts
against the tier's build cap and one is released at it.
- **!632** `feat/ship_templates_and_soffice_dep` -- the ten bundled deck templates are
tracked in git with per-file sha256 pins, so a fresh clone can build a deck; the
LibreOffice dependency is declared and resolved through one resolver.
- **!642** `fix/ppt_copy_route_and_clone_typography` -- a copy-route lookup that finds
nothing names the near miss before the inventory; a text frame with no paragraph at
all can be written into; a cloned page's title size is said; `row_type_drift` compares
the same structural slot across a run's units.
- **D57's other-page clause, rewired.** D57 gave five refusals a "did you mean" hint,
and one of them also answered "the string you named is on page N of this template".
That clause needs the file a page was cloned out of, and the only refusal holding it
was `adapt`'s, which !628 removed. It is restored by reading `PPT_TEMPLATE_SOURCE`,
which the runner already sets in the author's own process and which this module
already reads for `bundled()`; the two helpers behind the clause are unchanged.
- **D60** `read the ground under each word, not across the whole box` -- the `unreadable`
contrast gate also measures the render's own word boxes, as extra regions through the
same guards, so a two-line block crossed by a narrow bright ridge can no longer elect
the dark ground and read as legible.
Decisions the union forced, none of which drops a behaviour:
- The publish record is built !602's way, with its delivery `role`, and written the way
D49 requires -- read back off the file, atomic, and refused rather than silent when
the record cannot be written.
- `clear_region`, `shapes_in`, `page_box` and the refusal of a bare four-number region
survive `adapt`'s removal; so do `_heading_rows` and its helpers, which the row
reading loads even though the call they were written for is gone.
- The author-facing guidance names !628's single route and keeps D59's rule that a
region must declare which reading it is.
**The decision log carries a numbering collision, on purpose.** It is a set union with
no wording changed, and the numbers are left exactly as each branch wrote them, so a
reviewer meets this rather than discovers it:
- !602 and !628 each wrote a **D37** and a **D38**, about different decisions.
- !628's **D45** is not `main`'s D45; they are unrelated entries under one number.
- !628's **D42** is `main`'s **D45** word for word, so the merged log carries one
decision under two numbers.
Renumbering touches every cross-reference in the log, and doing that inside a
seventy-commit fold immediately before a merge is how a silent break gets in. The
numbering is being fixed on a separate branch, which carries a script and a test that
fails when a citation points at nothing.
## Type
- [x] Feature
- [x] Fix
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Run on an interpreter carrying `python-pptx`, with `PYTHONPATH` at this worktree and its
`plugins-dist/ppt-engine`, confirmed from a neutral working directory that `raven` and
`raven_ppt` resolve out of the worktree and not the host repo.
- `make test-python` (the whole suite, as CI runs it) -- 20826 passed, 49 skipped, and
26 failures this machine produces on any branch: it has no `/usr/share/zoneinfo`, so
every cron timezone case raises `ValueError: unknown timezone 'Asia/Shanghai'`. Checked
out plain `origin/main` in a clean worktree and ran the same two files: the same 6
failed and 20 errors, the ids identical character for character. Nothing on this branch
touches cron or timezones. The stale `test_trunks_executor_would_have_dropped_that_output`
that failed on the previous revision is retired on the new base and its replacement,
`test_trunks_executor_preserves_output_on_timeout`, was run on its own and passes.
The 6 failures and 20 errors are all cron timezone tests failing identically on plain
`main` in a clean worktree, on a host with no `/usr/share/zoneinfo`.
- `make check-commits` -- exit 0.
- `make check-source-language` -- exit 0.
- `make check-large-files` -- exit 0.
- `make lint-imports` -- exit 0, 9 contracts kept, 0 broken.
- `ruff check` and `ruff format --check` over the 80 changed Python files -- exit 0.
- `pytest tests/test_ppt_engine_templates.py tests/test_utils_office.py
tests/test_cli_doctor_commands.py` -- 97 passed; the ten templates are tracked and
satisfy their pins, and the soffice resolver finds the local binary.
- The delivery contract, the record read-back, the page isolation and the near miss were
each run as a measurement rather than asserted; the `unreadable` gate was run through
the real LibreOffice render chain on a delivered 12-page deck and reports BLOCKING on
page 12 under one word at 1.6:1.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
User-visible changes: `ppt_build` gains `deliver_to` and delivers outside `out/`;
`adapt` is gone from the author-facing template module, so a program calling it fails to
import -- `title=` and `subtitle=` have no replacement and the heading is named by the
words the template put there; a draft now counts against the tier's build cap; three
gates that nothing measured against being wrong no longer refuse; and the ten templates
are now bytes in the repository rather than a private registry fetch.
Two pieces here are about not destroying something the user has. The delivery
refuses to write its `.pdf` where a file the user already owns sits at the same
stem, rather than replacing it; and the large-file roster moved out of the manifest
inside the tree being checked and into the gate's own source, so a change can no
longer grant itself the exception the gate exists to withhold.
Rollback is per piece: each of the five sources is a contiguous run of commits on this
branch, in the order listed above, so any one of them can be reverted as a range without
touching the others.
- [x] Backward compatibility considered
- [x] Security impact considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-09-11 05:52:36 +00:00
|
|
|
def manifest_deck_template_names(root: Path) -> frozenset[str]:
|
|
|
|
|
"""The template filenames the ppt engine's manifest pins, empty when it cannot be read.
|
|
|
|
|
|
|
|
|
|
Not what the gate allows -- `PINNED_DECK_TEMPLATES` is that, and says why.
|
|
|
|
|
This reads the other side so a test can hold the two together and fail when
|
|
|
|
|
the manifest and the approved roster drift apart.
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
manifest = json.loads((root / BUNDLED_DECK_TEMPLATE_MANIFEST).read_text(encoding="utf-8"))
|
|
|
|
|
except (OSError, ValueError):
|
|
|
|
|
return frozenset()
|
|
|
|
|
files = manifest.get("files")
|
|
|
|
|
if not isinstance(files, list):
|
|
|
|
|
return frozenset()
|
|
|
|
|
return frozenset(str(entry["name"]) for entry in files if isinstance(entry, dict) and "name" in entry)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _is_pinned_deck_template(path: str) -> bool:
|
|
|
|
|
parent, _, name = path.rpartition("/")
|
|
|
|
|
return parent == BUNDLED_DECK_TEMPLATE_DIR and name in PINNED_DECK_TEMPLATES
|
|
|
|
|
|
|
|
|
|
|
fix(tools): an array sent as its own JSON is still an array
## Summary
Reported as "deliver_files is broken". It is not: **the tool never ran.**
Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered:
```
Error: Invalid parameters for tool 'deliver_files': files should be array
```
What the model sent was the array, spelled as a string:
```json
{"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."}
```
`cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify.
## Type
- [x] Fix
- [ ] Feature
## The edge of the forgiving is the design
When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error.
**Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through.
**A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage.
## Not just deliver_files
Six built-in tools declare an array or object parameter and were all exposed:
| tool | parameter |
|---|---|
| `deliver_files` | `files` |
| `ask_user` | `questions` |
| `image_generate` | `images` |
| `message` | `media` |
| `create_playbook` | `skills` |
| `video_generate` | `params` |
The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch.
## Verification
```
make lint-python ruff check + ruff format --check, 1850 files
make lint-imports 9 contracts kept, 0 broken
pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below)
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots -- no user-facing string
**End to end, through the real tool**, with the exact payload that failed five times in production:
```
files sent as: str -> [{"path": ".../poster.png", "title": "..."}]
returned: Delivered 1 file(s): poster.png (72 B).
still "should be array": False
registered in the store: True
```
Twelve cases, five mutations, each killing at least one:
| mutation | red |
|---|---|
| drop the whole branch (the old behaviour) | 3 |
| raise instead of falling through on a parse failure | 5 |
| accept the parse whatever type it yielded | 1 |
| do not re-cast the parsed value, so items are not cast | 1 |
| widen the tuple to include `string` | **survived -- unreachable** |
The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so.
**Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own.
## Risk
- [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before
- [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed
- [x] Rollback path is clear -- single-commit revert
## Related Issues
N/A
## Swept
`mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`.
- **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects.
- **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`.
- **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case).
- **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts.
- **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none.
- **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value.
- **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed.
Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text).
## Deliberately not fixed
The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument.
## Moved from !594
Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name.
Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
|
|
|
def _is_allowed_skill_reference_image(path: str, extension: str) -> bool:
|
|
|
|
|
if extension not in ALLOWED_SKILL_REFERENCE_IMAGE_EXTENSIONS:
|
|
|
|
|
return False
|
|
|
|
|
parts = PurePosixPath(path).parts
|
|
|
|
|
if ".." in parts:
|
|
|
|
|
return False
|
|
|
|
|
for prefix in RAVEN_DESIGN_SKILL_PREFIXES:
|
|
|
|
|
prefix_length = len(prefix)
|
|
|
|
|
if (
|
|
|
|
|
len(parts) >= prefix_length + 3
|
|
|
|
|
and parts[:prefix_length] == prefix
|
|
|
|
|
and parts[prefix_length + 1] == "references"
|
|
|
|
|
):
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
ci: block report assets in pull request checks (#86)
## Summary
- Add a repository file policy check for pull request ranges.
- Reject report assets regardless of size, including images, GIFs, SVGs,
videos, audio files, PDFs, HTML files, web manifests, and WASM bundles.
- Keep the separate 1 MiB limit for any other added or modified file.
- Document the policy in AGENTS.md, CLAUDE.md, and CONTRIBUTING.md.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
Commands run:
- `make test-python`
- `make lint-python`
- `make check-large-files`
- `make check-commits`
- `uv run pre-commit run --files AGENTS.md CLAUDE.md CONTRIBUTING.md
scripts/check_large_files.py tests/test_large_file_check.py`
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
2026-07-03 11:50:33 +08:00
|
|
|
def changed_paths(revision_range: str) -> list[str]:
|
|
|
|
|
output = subprocess.check_output(
|
|
|
|
|
["git", "diff", "--name-only", "--diff-filter=AM", revision_range],
|
|
|
|
|
text=True,
|
|
|
|
|
)
|
|
|
|
|
return [line for line in output.splitlines() if line]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_bytes(size: int) -> str:
|
|
|
|
|
value = float(size)
|
|
|
|
|
for unit in ("bytes", "KiB", "MiB", "GiB"):
|
|
|
|
|
if value < 1024 or unit == "GiB":
|
|
|
|
|
if unit == "bytes":
|
|
|
|
|
return f"{size} byte" if size == 1 else f"{size} bytes"
|
|
|
|
|
return f"{value:.1f} {unit}"
|
|
|
|
|
value /= 1024
|
|
|
|
|
raise AssertionError("unreachable")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _default_range() -> str | None:
|
|
|
|
|
pr_base = os.environ.get("GITHUB_PR_BASE_SHA", "").strip()
|
|
|
|
|
if pr_base:
|
|
|
|
|
return f"{pr_base}..HEAD"
|
|
|
|
|
|
|
|
|
|
before = os.environ.get("GITHUB_EVENT_BEFORE", "").strip()
|
|
|
|
|
if before and before != ZERO_SHA:
|
|
|
|
|
return f"{before}..HEAD"
|
|
|
|
|
|
|
|
|
|
return os.environ.get("RANGE", "").strip() or None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _default_max_bytes() -> int:
|
|
|
|
|
raw = os.environ.get(MAX_BYTES_ENV, "").strip()
|
|
|
|
|
if not raw:
|
|
|
|
|
return DEFAULT_MAX_BYTES
|
|
|
|
|
return _positive_int(raw)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _positive_int(value: str) -> int:
|
|
|
|
|
try:
|
|
|
|
|
parsed = int(value)
|
|
|
|
|
except ValueError as exc:
|
|
|
|
|
raise argparse.ArgumentTypeError("must be an integer") from exc
|
|
|
|
|
if parsed <= 0:
|
|
|
|
|
raise argparse.ArgumentTypeError("must be greater than zero")
|
|
|
|
|
return parsed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
raise SystemExit(main())
|