change: Implement 3: Complete the native-process CLI, JSON request handling, status vocabulary and exit codes #13
Merged
ai-reviewer
merged 2 commits from 2026-11-03 02:05:48 +00:00
change/5-implement-3-complete-the-native-process-cli-json-request-handl into task/1-task
Labels
Clear labels
auto:allowed
claim:active
needs:architecture
role:architect
role:developer
role:product-manager
role:reviewer
role:team-lead
role:tester
status:accepted
status:blocked
status:done
status:draft-acceptance
status:draft-development
status:idea
status:in-architecture
status:in-development
status:in-lead
status:in-review
status:in-test
status:needs-development
status:needs-test
status:proposed
status:ready-for-architecture
status:ready-for-development
status:ready-for-lead
status:ready-for-test
status:waiting-for-acceptance
status:waiting-for-dependency
type:bug
Autonomous agents may claim this issue when role and status labels match.
A non-expired agent claim exists in issue or pull request comments.
Requires architecture planning before implementation.
Turns architecture-marked proposals into ADR-like plans and lead-ready follow-up work.
Implements code and tests, opens PRs, and fixes CI failures.
Creates product proposals from ideas and feedback.
Reviews diffs, tests, CI reports, and returns or accepts work.
Clarifies scope, decomposes tasks, and gates development readiness.
Runs final product acceptance and creates developer bug follow-ups.
Work passed review and can be reported or merged by the outer workflow.
Automation cannot continue without human input.
Workflow item is complete.
Teamlead-agent has created a final acceptance task draft that is not claimable yet.
Teamlead-agent has created a developer task draft that is not claimable yet.
Raw user idea or feedback that has not been shaped yet.
Architect is writing an ADR-like plan or lead follow-up.
Developer is implementing or fixing the task.
Teamlead-agent is decomposing architecture into developer work.
PR is ready for review after CI/deploy feedback.
Tester-agent is running final product acceptance.
Review or CI found issues that must return to development.
Work needs final acceptance testing or retesting.
Product proposal exists, but it is not ready for development.
Proposal needs architecture review before team lead planning.
Task is scoped and may be assigned to a developer.
Proposal is ready for technical planning.
Merged product work is ready for final tester acceptance.
Final acceptance is waiting for all implementation dependencies to complete.
Task is scoped but cannot be claimed until prerequisite child tasks are complete.
Broken or incorrect behavior.
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: projects/product-54354138-1#13
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Completed the native-process CLI for
python -m tools.example. Addedtools/envelope.pywith the fixed status vocabulary (ok,dry_run,invalid_request,no_format,no_size,access_error,partial_download) mapped to exit codes 0/0/2/3/4/5/6 and theResponse/ResponseBuilderJSON envelope (keys: status, source, request, items, error). Extendedtools/errors.pywith request errors (RequestError,RequestDocumentError,RequestFieldError,UnsupportedFormatError) andACCEPTED_FORMATS. Rewrotetools/example.pyas a plain executable CLI accepting either a JSON request document or flags (--topic, --width, --height, --format png|ico, --source, --count, --download, --output-dir, --resize, --dry-run), with a custom parser that turns usage errors intoinvalid_requestenvelopes, unknown sources reported together with the available source ids, unsupported formats rejected with the accepted values, and format/size filtering, download and partial-download handling mapped onto the shared status table.examples/input.jsonis now the canonical offline dry_run request, andtests/test_cli.py(new) plus a rewrittentests/test_example.pycover the status/exit-code table, single-JSON-document output, help text, unknown source/unsupported format rejection and the download branches.Tests:
Facade checks run from /workspace with the prepared .venv:
python -m compileall tools tests(tools.validate) OK;pytest(tools.test) 76 passed;python -m tools.example examples/input.json(tools.smoke) exit 0 with a singledry_runJSON document;python -m tools.example --helpexits 0 and documents every parameter plus the JSON document contract. Origin target branchorigin/task/1-task(1f929c5) is an ancestor of the work branch, so the target is integrated and the checks above ran on the integrated revision. No dependency changes were needed, so no prepare_environment update was required.Progress:
Implemented envelope status/exit-code table and response builder, request errors, the full flag/JSON-document CLI in tools/example.py, canonical offline examples/input.json, and CLI tests; facade validate/test/smoke and --help all pass (76 tests).
Published by developer-agent through Tool Backend.
Closes #5
Developer-agent completed implementation and CI passed, but updating the PR title/body failed.
Intended title: change: Implement 3: Complete the native-process CLI, JSON request handling, status vocabulary and exit codes
Commit:
f20e58e85cCI: CI passed.
Intended body:
Completed the native-process CLI for
python -m tools.example. Addedtools/envelope.pywith the fixed status vocabulary (ok,dry_run,invalid_request,no_format,no_size,access_error,partial_download) mapped to exit codes 0/0/2/3/4/5/6 and theResponse/ResponseBuilderJSON envelope (keys: status, source, request, items, error). Extendedtools/errors.pywith request errors (RequestError,RequestDocumentError,RequestFieldError,UnsupportedFormatError) andACCEPTED_FORMATS. Rewrotetools/example.pyas a plain executable CLI accepting either a JSON request document or flags (--topic, --width, --height, --format png|ico, --source, --count, --download, --output-dir, --resize, --dry-run), with a custom parser that turns usage errors intoinvalid_requestenvelopes, unknown sources reported together with the available source ids, unsupported formats rejected with the accepted values, and format/size filtering, download and partial-download handling mapped onto the shared status table.examples/input.jsonis now the canonical offline dry_run request, andtests/test_cli.py(new) plus a rewrittentests/test_example.pycover the status/exit-code table, single-JSON-document output, help text, unknown source/unsupported format rejection and the download branches.Tests:
Facade checks run from /workspace with the prepared .venv:
python -m compileall tools tests(tools.validate) OK;pytest(tools.test) 76 passed;python -m tools.example examples/input.json(tools.smoke) exit 0 with a singledry_runJSON document;python -m tools.example --helpexits 0 and documents every parameter plus the JSON document contract. Origin target branchorigin/task/1-task(1f929c5) is an ancestor of the work branch, so the target is integrated and the checks above ran on the integrated revision. No dependency changes were needed, so no prepare_environment update was required.Published by developer-agent through Tool Backend.
Task-local checks are genuinely green on
f20e58e(formal AGENT_CI_RESULT for tools.dependencies.restore/tools.validate/tools.test/tools.smoke/acceptance.help-command, help-command target_id resolved), and the envelope/status table, JSON-document parsing, invalid_request paths and offline dry_run example are implemented as specified. However, the size/resize behavior this PR implements in the public CLI contradicts the active product obligations: without --resize the filter requires exact width/height equality, discarding every image larger than the requested size, and --resize changes the acceptance set instead of downscaling, so documented behavior does not occur. The new tests encode this wrong semantics, so green CI does not prove REQ-008/AC-005/REQ-010/AC-008. Changes are required before merge.Findings:
actual_width == width/actual_height == height. REQ-008/AC-005 require every returned image to be at least the desired size in both dimensions (and the architecture constraint says only images 'not smaller than the desired size in both dimensions' are returned). A 400x300 candidate for a 100x100 request must be returned unchanged without the flag; as written it is classified intorejected, so_executereturns STATUS_NO_SIZE. Ordinary live requests (e.g. the canonical 640x480 example) will therefore reportno_sizewhenever no exact-pixel file exists._downloadwritescandidate.fetch_bytes()verbatim under.<format>with no resize step. REQ-010/AC-008 require larger images to be saved with the desired dimensions when the flag is present and unchanged when absent; the flag currently only widens the acceptance set and never changes output dimensions.test_no_size_when_only_smaller_images_existuses a smaller image (fine), but there is no test for a larger image without --resize (must beokwith original dimensions), andtest_resize_accepts_larger_imagesonly asserts the item is listed, never the written dimensions. Fixing_matches_size/download resizing requires updating these tests, otherwise the suite will keep endorsing the wrong contract.mime_type, URL suffix, width/height) and write bytes without validating them; the architecture constraint requires filters to be applied to the actual downloaded/parsed image data, and REQ-007/AC-007 require returned/saved files to really be the requested format.test_download_success_writes_files(tests/test_cli.py:299-309) asserts the saved file equals b'payload', i.e. it is not an image, so this is unverified. Either verify format/dimensions from the fetched bytes in this slice, or explicitly drop the claimed behavior/document it as not yet implemented rather than asserting 'downscale them' in --help.Developer-agent completed implementation and CI passed, but updating the PR title/body failed.
Intended title: change: Implement 3: Complete the native-process CLI, JSON request handling, status vocabulary and exit codes
Commit:
6a7538c07fCI: CI passed.
Intended body:
Review fix for issue #5: aligned the public CLI's size/resize semantics with the active product obligations instead of the previous exact-match behaviour.
tools/example.py: the requested width/height are now a target (minimum) size, never an exact-match filter: any image at least that large is selected regardless of--resize, and smaller images still produceno_size.--resizeno longer widens selection; it now performs real downscaling of downloaded images to a shrink-to-fit box (aspect ratio preserved, never upscaled), implemented with a dependency-free stdlib PNG codec plus ICO container support (PNG-compressed ICO entries), and each item recordsfrom/to/applieddimensions. Undecodable payloads raise the new typedImageResizeErrorand are reported as failed downloads, so the status vocabulary and exit codes stay unchanged (ok/dry_run0,invalid_request2,no_format3,no_size4,access_error5,partial_download6). Help text and theno_sizeerror details were updated to describe the minimum-size contract.tools/errors.py: addedImageResizeError(coderesize_failed) to the typed hierarchy and__all__.tests/test_cli.py: replaced the old "exact size unless --resize" test with minimum-size tests (larger image accepted without--resize, exact size accepted,--resizewithout--downloadkeeps the reported source size) and added offline fixtures/tests for real downscaling: PNG stored at 100x50 for a 100x100 box, original bytes preserved without--resize, no upscaling (already_fits), PNG-in-ICO downscaling, andresize_failedsurfacing asaccess_error.examples/input.jsonremains the canonical offlinedry_runrequest, so the smoke command stays green and network-free.No protected facade/control paths were touched and no dependency declarations changed.
Tests:
Ran the facade commands on the final revision through the prepared environment (
.venvon PATH):python -m compileall tools tests→ exit 0 (tools.validate);pytest→ 83 passed (tools.test);python -m tools.example examples/input.json→ exit 0 with one JSON document, statusdry_run(tools.smoke);python -m tools.example --help→ exit 0 (help-command acceptance).tools/envelope.pyis unchanged and still exports the fixed status/exit-code table checked by tests. Target branchtask/1-taskis already an ancestor of the work branch head, so no integration was needed.Published by developer-agent through Tool Backend.
The prior blocking defect is fixed on
6a7538c: the requested width/height is now a minimum/target size (not an exact-match filter), and --resize performs real shrink-to-fit downscaling of the stored image with per-item from/to/applied metadata and a typed resize_failed error. Formal AGENT_CI_RESULT records for tools.dependencies.restore, tools.validate, tools.test (83 passed, including tests/test_cli.py), tools.smoke (dry_run JSON) and acceptance.help-command (target_id help-command) all passed on this exact head SHA, examples/input.json remains the canonical offline dry_run request, and no protected facade paths or dependency manifests/lock files were touched. All seven task acceptance criteria are satisfied; the residual items below concern REQ-007/AC-007 byte-level verification, REQ-008 actual-dimension measurement and the AC-008 dimension interpretation, and are non-blocking for this CLI/status-vocabulary slice.Findings:
.<format>with no content check (tools/example.py:315-321, 691-696; tests/test_cli.py:327-337 still stores the non-image payload b'payload'). The architecture constraint that filters run on actual downloaded data is only enforced when --resize decodes the payload; verify byte-level format on real downloads before final acceptance.Acceptance evidence for
6a7538c07f2d481e7dc2b5afedd50f23a6493747:pytest) collected 83 items and passed, with the tests/test_cli.py row fully green; its assertions cover the status/exit-code table, one JSON document on stdout, help text, unknown-source/unsupported-format rejection, minimum-size selection and real PNG/ICO downscaling of stored files. (tests/test_cli.py:240-399; tests/test_cli.py:400-550; tests:1-3; CI job 5:315-427)python -m tools.example --help, expect_exit_code 0, required path tools/example.py) and the exact-head log contains the structured AGENT_CI_RESULT command_id=acceptance.help-command with target_type=facade_acceptance, target_id=help-command, exit_code=0 status=passed; the emitted help documents REQUEST.json, every flag (--topic/--width/--height/--format png|ico/--source/--count/--download/--output-dir/--resize/--dry-run) and the JSON envelope keys. (.agent/project.yaml:1-160; tools/example.py:1-160; examples/input.json:1-13; CI job 5:315-427)