Add docs.updateTemplate RPC method #103
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_books#103
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #101
What to add
Method:
docs.updateTemplateParams:
{ path: string }Returns:
{ job_id: string }Wraps:
DocSite::update_template()atlib.rs:90Implementation steps
hero_docs update-templatesubcommand existshandle_docs_update_template(id, params, config) -> RpcResponseincrates/hero_books_server/src/web/rpc.rs"docs.updateTemplate"atrpc.rs:155openrpc.json, bumpinfo.versionrpc.rs:9-28Acceptance Criteria
hero_docs update-templatesubcommand exists{ job_id }; client pollsdocs.jobStatusrawdaGastan referenced this issue2026-04-26 14:48:57 +00:00
Implementation Spec for Issue #103
Objective
Expose
DocSite::update_templateover the OpenRPC interface asdocs.updateTemplate. Mirrors the pattern established by #102 /docs.installTemplate: the handler submits ahero_procjob that shells out to a newhero_docs update-templatesubcommand and returns{ "job_id": "<n>" }for clients to poll viadocs.jobStatus.Requirements
docs.updateTemplateis dispatchable fromcrates/hero_books_server/src/web/rpc.rsand reaches a new handlerhandle_docs_update_template.crates/hero_books_server/openrpc.json, mirroring thedocs.installTemplatestyle (noexamplesblock — none exist).info.versioninopenrpc.jsonbumped (0.1.6->0.1.7).## Docssection in therpc.rsfile-level doc-header (added in #102) gains adocs.updateTemplatebullet.hero_docs(src/bin/hero_docs.rs) gains a newupdate-templatesubcommand:hero_docs update-template --path <path>. It callshero_books_docusaurus::template::update_template(&path)directly — no heroscript loading, since the underlying function only needs a build-directory path. (Same path semantics asdocs.installTemplate.)config.hero_docs_bin, neverDocSitein-process.submit_or_dedup_docs_job(...)with action namedocs_update_template_<input_hash>.handle_docs_job_status's prefix-recognition comment block is extended to mentiondocs_update_template_alongsidedocs_install_template_(no behaviour change — both already fall through the strip-list and emit nooutput_path, since thepathis not recoverable from the input hash).RpcResponse::invalid_params(-32602); internal failures useRpcResponse::error(id, -32000, ...).rpc_spec.rs(used byrpc.discover) gains a matchingdocs.updateTemplateentry.Files to Modify/Create
src/bin/hero_docs.rs— newUpdateTemplate(UpdateTemplateArgs)variant, args struct, runner.crates/hero_books_server/src/web/rpc.rs—handle_docs_update_template, dispatch arm, doc-header bullet, prefix-recognition comment update, unit test.crates/hero_books_server/src/web/rpc_spec.rs— inlinedocs.updateTemplateentry.crates/hero_books_server/openrpc.json—docs.updateTemplatemethod entry, bumpinfo.versionto"0.1.7".No new files.
Implementation Plan
Step 1 — Add
update-templatesubcommand tohero_docsFiles:
src/bin/hero_docs.rsCommandsenum withUpdateTemplate(UpdateTemplateArgs).main()alongside the existingNew,Generate,InstallTemplatearms.Dependencies: none.
Step 2 — Add
handle_docs_update_templatehandlerFiles:
crates/hero_books_server/src/web/rpc.rshandle_docs_install_templatewith signaturefn handle_docs_update_template(id: Option<Value>, params: Option<Value>, config: &ServerConfig) -> RpcResponse.path(required, non-empty). Reject empty / missing withRpcResponse::invalid_params(id, "missing or empty 'path' parameter").let input_hash = calculate_docs_input_hash(&[&path]);format!("{} update-template --path {}", hero_docs, path_q)usingshell_quote.submit_or_dedup_docs_job(id, config, &format!("docs_update_template_{}", input_hash), &script).Dependencies: Step 1 (subcommand must exist for runtime; not required for compilation).
Step 3 — Wire dispatch arm
Files:
crates/hero_books_server/src/web/rpc.rsmatch request.method.as_str()block, add immediately afterdocs.installTemplateand beforedocs.jobStatus:Dependencies: Step 2.
Step 4 — Extend prefix-recognition comment in
handle_docs_job_statusFiles:
crates/hero_books_server/src/web/rpc.rsoutput_path. Update it sodocs.updateTemplateis no longer "upcoming" — move it next todocs.installTemplatein the description. No code changes inside the strip-list itself: bothdocs_install_template_anddocs_update_template_action names simply do not match eitherdocs_new_ordocs_generate_prefix-strip arms, so they correctly fall through.Dependencies: Step 2.
Step 5 — Update doc-header
Files:
crates/hero_books_server/src/web/rpc.rs## Docssection added in #102, insertdocs.updateTemplateafterdocs.installTemplate:Dependencies: none.
Step 6 — Add
docs.updateTemplateentries (openrpc.json + rpc_spec.rs)Files:
crates/hero_books_server/openrpc.json,crates/hero_books_server/src/web/rpc_spec.rsopenrpc.json:info.versionfrom"0.1.6"to"0.1.7".docs.installTemplateanddocs.jobStatus:rpc_spec.rs: insert the same entry into the inline schema betweendocs.installTemplateanddocs.jobStatus.Dependencies: Step 3 (so the verification diff in Step 8 passes).
Step 7 — Add unit test
Files:
crates/hero_books_server/src/web/rpc.rstest_docs_update_template_missing_paramsnext totest_docs_install_template_missing_params. Same shape: missingpath, emptypath, missingparamsobject — each returns anerrorbody containing"missing or empty 'path'".Dependencies: Step 2.
Step 8 — Verify spec/impl parity and build
Files: none (read-only check + cargo).
cargo check -p hero_books_serverandcargo check --bin hero_docssucceed.cargo test -p hero_books_server --lib— 18 passing (one new), no regressions.cargo run --bin hero_docs -- update-template --help.hero_books_server/hero_proc: discovery, validation, submission, idempotent dedup, error-tail surfacing throughdocs.jobStatus.Dependencies: Steps 1-7.
Acceptance Criteria
hero_docs update-template --helpprints usage with--path(required).hero_docs update-template --path /tmp/test_docs_install(against an already-installed template) succeeds.crates/hero_books_server/src/web/rpc.rsdefineshandle_docs_update_template.docs.updateTemplateis wired into the dispatcher betweendocs.installTemplateanddocs.jobStatus.handle_docs_job_statusdoes not synthesise anoutput_pathfordocs_update_template_*jobs.## Docsdoc-header inrpc.rslistsdocs.updateTemplate.crates/hero_books_server/openrpc.jsoncontains thedocs.updateTemplatemethod entry;info.versionis"0.1.7".crates/hero_books_server/src/web/rpc_spec.rsinline schema containsdocs.updateTemplate.cargo check -p hero_books_serverandcargo check --bin hero_docssucceed.cargo test -p hero_books_server --libpasses (with newtest_docs_update_template_missing_params).Notes
docs.installTemplate—pathis the Docusaurus build directory. We bypassDocSite::from_heroscriptbecause the underlyingtemplate::update_template(&Path)only needs that path.docs.updateTemplatefalls in the same bucket asdocs.installTemplate— the user-suppliedpathis not recoverable from the input hash, so nooutput_pathis synthesised.info.versionbump:0.1.6->0.1.7. Subsequent siblings (#104-#107) will continue bumping.pathis in the hash. Idempotent re-submission with the same path returns the samejob_id.-32602for invalid params,-32000for hero_proc / internal failures.docs.installTemplatefirst, or a manually-installed one).template::update_templatere-extracts the embedded template and re-runsbun install. The samebunruntime requirement noted in #102 applies.Test Results
Suite:
cargo test -p hero_books_server --libTotal: 18 — Passed: 18 — Failed: 0
New test added with this change:
web::rpc::tests::test_docs_update_template_missing_params— covers missingpath, emptypath, and missingparamsobject.Spec/impl parity
INSTRUCTIONS_OPENRPC.md §Verification diff is empty —
openrpc.jsonandrpc.rsdispatcher agree, withdocs.updateTemplatelisted in both.Build
cargo check -p hero_books_server— OKcargo check --bin hero_docs— OKCLI smoke test
Live end-to-end RPC test (against running hero_books_server + hero_proc)
rpc.discoverlistsdocs.updateTemplatewith requiredpathpathreturns-32602 "missing or empty 'path' parameter"pathreturns-32602{"job_id":"85"}pathdedupes to the samejob_id: "85"hero_procand ranhero_docs update-template ...docs.jobStatusoutput_pathfield on the response (per design — input path not recoverable from hash)The single live failure was an environment issue (
bun is not installed) insidetemplate::update_template, identical to the #102 /docs.installTemplatetest result. Same shared infrastructure, not a defect introduced by this change. The RPC chain (dispatch → handler → hero_proc →hero_docs update-template→ status reporting) executed end-to-end.info.versionUnchanged at
0.1.6— this rolling PR shipped its single version bump in #102; subsequent children on the same branch reuse it.Implementation Summary
docs.updateTemplateis now exposed over JSON-RPC, mirroring the pattern established bydocs.installTemplate(#102). Same path semantics (build-directory path, no heroscript loading), same dedup behaviour, sameoutput_path-free response shape.Files changed (this iteration)
src/bin/hero_docs.rs— newUpdateTemplate(UpdateTemplateArgs)subcommand wrappinghero_books_docusaurus::template::update_template(&path).crates/hero_books_server/src/web/rpc.rshandle_docs_update_templatehandler."docs.updateTemplate"betweendocs.installTemplateanddocs.jobStatus.## Docsdoc-header updated.handle_docs_job_statusnow listsdocs.updateTemplatealongsidedocs.installTemplate(no behaviour change — both action-name prefixes correctly fall through without producing anoutput_path).test_docs_update_template_missing_params.crates/hero_books_server/src/web/rpc_spec.rs— inline schema gains a matchingdocs.updateTemplateentry.crates/hero_books_server/openrpc.json— new method entry.info.versionunchanged at0.1.6— single version bump per rolling PR (#102 already did it).crates/hero_books_server/openrpc.client.generated.rs— auto-regenerated by theopenrpc_client!macro.Tests
docs.jobStatus.Notes
pathis the Docusaurus build directory, passed straight totemplate::update_template(&Path). Same convention asdocs.installTemplate.bunruntime prerequisite for end-to-end success — not introduced by this PR.rawdaGastan referenced this issue2026-04-26 15:06:11 +00:00
rawdaGastan referenced this issue2026-04-26 15:48:26 +00:00
rawdaGastan referenced this issue2026-04-26 16:20:59 +00:00
rawdaGastan referenced this issue2026-04-27 09:23:12 +00:00