mednotes-opencode 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/agents/med-chat-triager.md +204 -0
- package/.opencode/agents/med-flashcard-maker.md +63 -0
- package/.opencode/agents/med-knowledge-architect.md +230 -0
- package/.opencode/agents/med-link-graph-curator.md +177 -0
- package/.opencode/agents/med-publish-guard.md +62 -0
- package/.opencode/commands/flashcards.md +25 -0
- package/.opencode/commands/mednotes/create.md +25 -0
- package/.opencode/commands/mednotes/enrich.md +27 -0
- package/.opencode/commands/mednotes/fix-wiki.md +27 -0
- package/.opencode/commands/mednotes/history.md +22 -0
- package/.opencode/commands/mednotes/link-body.md +25 -0
- package/.opencode/commands/mednotes/link-related.md +27 -0
- package/.opencode/commands/mednotes/link.md +27 -0
- package/.opencode/commands/mednotes/pdf-library.md +27 -0
- package/.opencode/commands/mednotes/process-chats.md +23 -0
- package/.opencode/commands/mednotes/setup.md +21 -0
- package/.opencode/commands/mednotes/status.md +27 -0
- package/.opencode/commands/mednotes/telemetry.md +27 -0
- package/.opencode/commands/report.md +26 -0
- package/.opencode/mednotes/AGENTS.md +57 -0
- package/.opencode/mednotes/agents/med-chat-triager.md +197 -0
- package/.opencode/mednotes/agents/med-flashcard-maker.md +56 -0
- package/.opencode/mednotes/agents/med-knowledge-architect.md +224 -0
- package/.opencode/mednotes/agents/med-link-graph-curator.md +171 -0
- package/.opencode/mednotes/agents/med-publish-guard.md +55 -0
- package/.opencode/mednotes/contracts/.gitkeep +1 -0
- package/.opencode/mednotes/contracts/agents.json +116 -0
- package/.opencode/mednotes/contracts/opencode-plugin.json +70 -0
- package/.opencode/mednotes/docs/agent-prompt-hardening.md +567 -0
- package/.opencode/mednotes/docs/agent-role-contracts.md +94 -0
- package/.opencode/mednotes/docs/anki-mcp-twenty-rules.md +214 -0
- package/.opencode/mednotes/docs/anki-templates/README.md +39 -0
- package/.opencode/mednotes/docs/anki-templates/cloze.back.html +23 -0
- package/.opencode/mednotes/docs/anki-templates/cloze.front.html +14 -0
- package/.opencode/mednotes/docs/anki-templates/qa.back.html +24 -0
- package/.opencode/mednotes/docs/anki-templates/qa.front.html +14 -0
- package/.opencode/mednotes/docs/anki-templates/style.css +182 -0
- package/.opencode/mednotes/docs/atomicity-splitting-policy.md +113 -0
- package/.opencode/mednotes/docs/extension-docs.md +40 -0
- package/.opencode/mednotes/docs/flashcard-ingestion.md +278 -0
- package/.opencode/mednotes/docs/knowledge-architect.md +208 -0
- package/.opencode/mednotes/docs/merge-policy.md +110 -0
- package/.opencode/mednotes/docs/public-vocabulary.md +104 -0
- package/.opencode/mednotes/docs/semantic-linker.md +141 -0
- package/.opencode/mednotes/docs/taxonomy-policy.md +90 -0
- package/.opencode/mednotes/docs/triage-policy.md +187 -0
- package/.opencode/mednotes/docs/vault-version-control.md +758 -0
- package/.opencode/mednotes/docs/vocabulary-db-recovery.md +58 -0
- package/.opencode/mednotes/docs/workflow-output-contract.md +779 -0
- package/.opencode/mednotes/hooks/hooks.json +79 -0
- package/.opencode/mednotes/package-lock.json +6361 -0
- package/.opencode/mednotes/package.json +15 -0
- package/.opencode/mednotes/pyproject.toml +48 -0
- package/.opencode/mednotes/scripts/bootstrap_windows_python_uv.cmd +13 -0
- package/.opencode/mednotes/scripts/bootstrap_windows_python_uv.ps1 +172 -0
- package/.opencode/mednotes/scripts/enrich_notes.py +23 -0
- package/.opencode/mednotes/scripts/full_reset_windows_python_uv.cmd +13 -0
- package/.opencode/mednotes/scripts/hooks/antigravity_hook_status.mjs +212 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/antigravity.mjs +169 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/harness_payload.mjs +103 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/opencode_plugin.mjs +341 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/opencode_user_config_sync.mjs +177 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/anki_preflight.mjs +214 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/cli.mjs +143 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/diagnostics.mjs +11 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/domain/agent_directive_core.mjs +160 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/fsm_directive.mjs +1470 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/hook_errors.mjs +120 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/retention.mjs +114 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/runtime.mjs +174 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/telemetry_capture.mjs +511 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/vault_guard.mjs +624 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook.mjs +5 -0
- package/.opencode/mednotes/scripts/mednotes/_runtime_paths.py +24 -0
- package/.opencode/mednotes/scripts/mednotes/anki_model_validator.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/capture_extension_diff.py +1562 -0
- package/.opencode/mednotes/scripts/mednotes/feedback_report.py +16 -0
- package/.opencode/mednotes/scripts/mednotes/flashcard_index.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/flashcard_pipeline.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/flashcard_report.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/flashcard_sources.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/obsidian/README.md +6 -0
- package/.opencode/mednotes/scripts/mednotes/obsidian_note_utils.py +20 -0
- package/.opencode/mednotes/scripts/mednotes/pdf_library/cli.py +16 -0
- package/.opencode/mednotes/scripts/mednotes/project_fsm.py +229 -0
- package/.opencode/mednotes/scripts/mednotes/setup_telemetry_email.py +404 -0
- package/.opencode/mednotes/scripts/mednotes/sync_anki_twenty_rules.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/sync_opencode_user_config.py +36 -0
- package/.opencode/mednotes/scripts/mednotes/wiki/cli.py +20 -0
- package/.opencode/mednotes/scripts/mednotes/wiki_graph.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/wiki_tree.py +134 -0
- package/.opencode/mednotes/scripts/reset_windows_python_uv.ps1 +625 -0
- package/.opencode/mednotes/scripts/run_python.mjs +109 -0
- package/.opencode/mednotes/scripts/vault/vault_commit.ps1 +19 -0
- package/.opencode/mednotes/scripts/vault/vault_commit.sh +18 -0
- package/.opencode/mednotes/scripts/vault/vault_git.ps1 +19 -0
- package/.opencode/mednotes/scripts/vault/vault_git.py +3107 -0
- package/.opencode/mednotes/scripts/vault/vault_git.sh +18 -0
- package/.opencode/mednotes/scripts/vault/vault_precommit.ps1 +19 -0
- package/.opencode/mednotes/scripts/vault/vault_precommit.sh +18 -0
- package/.opencode/mednotes/skills/THIRD_PARTY_NOTICES.md +45 -0
- package/.opencode/mednotes/skills/create-medical-flashcards/SKILL.md +113 -0
- package/.opencode/mednotes/skills/create-medical-note/SKILL.md +90 -0
- package/.opencode/mednotes/skills/enrich-medical-note/SKILL.md +120 -0
- package/.opencode/mednotes/skills/fix-medical-wiki/SKILL.md +559 -0
- package/.opencode/mednotes/skills/link-medical-wiki/SKILL.md +224 -0
- package/.opencode/mednotes/skills/obsidian-cli/SKILL.md +118 -0
- package/.opencode/mednotes/skills/obsidian-markdown/SKILL.md +207 -0
- package/.opencode/mednotes/skills/obsidian-markdown/references/CALLOUTS.md +58 -0
- package/.opencode/mednotes/skills/obsidian-markdown/references/EMBEDS.md +63 -0
- package/.opencode/mednotes/skills/obsidian-markdown/references/PROPERTIES.md +61 -0
- package/.opencode/mednotes/skills/obsidian-ops/SKILL.md +136 -0
- package/.opencode/mednotes/skills/pdf-library/SKILL.md +45 -0
- package/.opencode/mednotes/skills/process-medical-chats/SKILL.md +246 -0
- package/.opencode/mednotes/skills/workflow-report/SKILL.md +100 -0
- package/.opencode/mednotes/src/mednotes/__init__.py +5 -0
- package/.opencode/mednotes/src/mednotes/domains/__init__.py +5 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/README.md +26 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/__init__.py +2 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/build_demo_apkg.py +177 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/contracts.py +385 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/flashcards_machine.py +522 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/fsm.py +817 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/index.py +630 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/install_models.py +445 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/model.py +359 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/obsidian_links.py +135 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/obsidian_note_utils.py +546 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/pipeline.py +580 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/report.py +510 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/sources.py +682 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/sync_rules.py +184 -0
- package/.opencode/mednotes/src/mednotes/domains/history/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/history/history_fsm.py +852 -0
- package/.opencode/mednotes/src/mednotes/domains/history/history_machine.py +453 -0
- package/.opencode/mednotes/src/mednotes/domains/setup/__init__.py +7 -0
- package/.opencode/mednotes/src/mednotes/domains/setup/setup_fsm.py +808 -0
- package/.opencode/mednotes/src/mednotes/domains/setup/setup_machine.py +973 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/README.md +64 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/api.py +668 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/batch_state.py +102 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/atomicity/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/atomicity/atomicity.py +877 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/body_link/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/body_link/body_linker.py +1562 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/effect_adapters.py +949 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/fix_wiki_runtime_adapters.py +433 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/coverage.py +413 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/graph.py +396 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/graph_fixes.py +161 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/hygiene/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/hygiene/hygiene.py +483 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/__init__.py +2 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/anchors.py +185 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/__init__.py +0 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/cache.py +223 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/config.py +131 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/download.py +224 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/frontmatter.py +59 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/insert.py +227 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/local_import.py +54 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/__init__.py +42 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/web_profiles.py +99 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/web_search.py +203 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/wikimedia.py +102 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_db_adapter.mjs +434 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_node_runtime.py +274 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_query.py +227 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/artifacts.py +605 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/canonical_merge.py +277 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/markdown_zones.py +85 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/meaning_planner.py +307 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_iter.py +67 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_merge.py +278 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_plan.py +409 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_policy.py +22 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/__init__.py +79 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/fixes.py +264 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/frontmatter.py +435 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/models.py +208 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/prompts.py +37 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/tables.py +236 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/validate.py +404 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/provenance.py +478 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/raw_chats.py +273 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/sources_backfill.py +235 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/__init__.py +10 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/anchors.py +16 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/captions.py +47 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/cli.py +179 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/cloud.py +52 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/config.py +196 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/context_packets.py +76 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/db.py +81 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/doctor.py +102 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/figure_ids.py +42 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/ingest.py +326 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/insert.py +316 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/mentions.py +57 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/ocr.py +71 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/paths.py +35 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/pdf_engine.py +77 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/schema.py +155 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/search.py +188 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/app.py +89 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/image_backend.py +29 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/state.py +65 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish.py +1139 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish_receipts.py +365 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish_recovery.py +240 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_behavior_corpus.py +2069 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_report_validation.py +4448 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_run_audit.py +852 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/architect_prompt_eval.py +341 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/body_linker_eval.py +240 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/curator_output_validation.py +175 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/curator_prompt_eval.py +865 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/triager_prompt_eval.py +1295 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/related_notes.py +1920 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/related_notes_headless.py +1186 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/plan_attestation.py +148 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_receipts.py +360 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_runtime.py +52 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_task_runner.py +2470 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/style/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/style/style.py +1952 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/subagents/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/subagents/agents.py +1767 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/alias_projection.py +331 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/link_terms.py +151 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/llm_disambiguation.py +182 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/__init__.py +116 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/audit.py +201 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/migration.py +314 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/normalize.py +72 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/policy.py +135 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/resolve.py +413 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/schema.py +157 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/status.py +137 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_bootstrap.py +509 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_curator_batch.py +1115 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_ingestion.py +632 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_map.py +930 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_recovery.py +1388 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/cli.py +6665 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/common.py +69 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/config.py +210 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/__init__.py +74 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agent_report.py +242 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agent_run_audit.py +196 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agents.py +601 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/curator.py +256 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/effect_payloads.py +519 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/happy_path.py +190 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/link_git.py +110 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/link_runtime_artifact.py +52 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/note_plan.py +75 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/paths.py +114 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/public_report.py +53 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/publish.py +111 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/raw_coverage.py +217 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes.py +136 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes_headless.py +153 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes_runtime.py +395 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/schema_registry.py +637 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/specialist.py +432 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/status.py +62 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/style_rewrite.py +568 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/vocabulary_ingestion.py +223 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_blockers.py +510 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_guardrails.py +637 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_outcomes.py +121 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_receipts.py +100 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/__main__.py +4 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/cli.py +275 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/__init__.py +2 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/candidates.py +193 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/cli.py +189 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/gemini.py +220 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/inputs.py +120 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/models.py +34 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/parsing.py +48 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/prompts.py +216 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/quality.py +54 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/reporting.py +24 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/runner.py +433 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/utils.py +39 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/vault_guard_bridge.py +17 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_context_packets.py +454 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_decision_projection.py +133 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_effects.py +1260 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_fsm.py +2768 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_machine.py +1588 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_plan.py +306 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_primary_objective.py +316 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_problem.py +153 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_receipt_evidence.py +306 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_states.py +290 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_user_report.py +342 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/health.py +6332 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_fsm.py +1119 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_git.py +638 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_machine.py +1106 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_retry_governance.py +374 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_runtime_result.py +485 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_triggers.py +183 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/linking.py +2758 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/reference_repair.py +718 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/related_notes_fsm.py +1855 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link_related/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link_related/link_related_machine.py +834 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_fsm.py +1592 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_machine.py +3097 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_primary_objective.py +28 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_runtime_result.py +185 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/performance.py +97 -0
- package/.opencode/mednotes/src/mednotes/kernel/__init__.py +6 -0
- package/.opencode/mednotes/src/mednotes/kernel/agent_directive.py +336 -0
- package/.opencode/mednotes/src/mednotes/kernel/base.py +51 -0
- package/.opencode/mednotes/src/mednotes/kernel/blockers.py +39 -0
- package/.opencode/mednotes/src/mednotes/kernel/effect_executor.py +55 -0
- package/.opencode/mednotes/src/mednotes/kernel/effect_intent.py +69 -0
- package/.opencode/mednotes/src/mednotes/kernel/effects.py +160 -0
- package/.opencode/mednotes/src/mednotes/kernel/errors.py +38 -0
- package/.opencode/mednotes/src/mednotes/kernel/fsm_event.py +35 -0
- package/.opencode/mednotes/src/mednotes/kernel/fsm_model.py +55 -0
- package/.opencode/mednotes/src/mednotes/kernel/fsm_transition_result.py +75 -0
- package/.opencode/mednotes/src/mednotes/kernel/guardrails.py +188 -0
- package/.opencode/mednotes/src/mednotes/kernel/progress.py +319 -0
- package/.opencode/mednotes/src/mednotes/kernel/public_report.py +346 -0
- package/.opencode/mednotes/src/mednotes/kernel/state_machine.py +164 -0
- package/.opencode/mednotes/src/mednotes/kernel/workflow.py +619 -0
- package/.opencode/mednotes/src/mednotes/platform/__init__.py +5 -0
- package/.opencode/mednotes/src/mednotes/platform/backup_policy.py +382 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/__init__.py +62 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/cli.py +275 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/contracts.py +83 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/core.py +4168 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/integrity.py +989 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/operational_contract.py +2293 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/telemetry.py +875 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/telemetry_config.py +65 -0
- package/.opencode/mednotes/src/mednotes/platform/opencode_runtime_config.py +182 -0
- package/.opencode/mednotes/src/mednotes/platform/paths/__init__.py +1560 -0
- package/.opencode/mednotes/src/mednotes/platform/secrets.py +89 -0
- package/.opencode/mednotes/src/mednotes/platform/user_config.py +103 -0
- package/.opencode/mednotes/src/mednotes/platform/vault_guard.py +214 -0
- package/.opencode/mednotes/uv.lock +932 -0
- package/.opencode/mednotes.generated.json +395 -0
- package/.opencode/opencode.json +31 -0
- package/.opencode/plugins/mednotes-fsm.mjs +7 -0
- package/.opencode/plugins/mednotes_hook/adapters/antigravity.mjs +169 -0
- package/.opencode/plugins/mednotes_hook/adapters/harness_payload.mjs +103 -0
- package/.opencode/plugins/mednotes_hook/adapters/opencode_plugin.mjs +341 -0
- package/.opencode/plugins/mednotes_hook/adapters/opencode_user_config_sync.mjs +177 -0
- package/.opencode/plugins/mednotes_hook/anki_preflight.mjs +214 -0
- package/.opencode/plugins/mednotes_hook/cli.mjs +143 -0
- package/.opencode/plugins/mednotes_hook/diagnostics.mjs +11 -0
- package/.opencode/plugins/mednotes_hook/domain/agent_directive_core.mjs +160 -0
- package/.opencode/plugins/mednotes_hook/fsm_directive.mjs +1470 -0
- package/.opencode/plugins/mednotes_hook/hook_errors.mjs +120 -0
- package/.opencode/plugins/mednotes_hook/retention.mjs +114 -0
- package/.opencode/plugins/mednotes_hook/runtime.mjs +174 -0
- package/.opencode/plugins/mednotes_hook/telemetry_capture.mjs +511 -0
- package/.opencode/plugins/mednotes_hook/vault_guard.mjs +624 -0
- package/AGENTS.md +57 -0
- package/README.md +194 -0
- package/adapters/antigravity/agents.json +80 -0
- package/adapters/antigravity/templates/med-chat-triager.md +214 -0
- package/adapters/antigravity/templates/med-flashcard-maker.md +72 -0
- package/adapters/antigravity/templates/med-knowledge-architect.md +241 -0
- package/adapters/antigravity/templates/med-link-graph-curator.md +187 -0
- package/adapters/antigravity/templates/med-publish-guard.md +71 -0
- package/adapters/gemini-cli/gemini-extension.json +14 -0
- package/adapters/gemini-cli/package.json +15 -0
- package/adapters/gemini-cli/pyproject.toml +48 -0
- package/bin/mednotes-opencode.mjs +155 -0
- package/contracts/agents.json +116 -0
- package/core/agents/med-chat-triager.md +197 -0
- package/core/agents/med-flashcard-maker.md +56 -0
- package/core/agents/med-knowledge-architect.md +224 -0
- package/core/agents/med-link-graph-curator.md +171 -0
- package/core/agents/med-publish-guard.md +55 -0
- package/core/commands/flashcards.toml +22 -0
- package/core/commands/mednotes/create.toml +22 -0
- package/core/commands/mednotes/enrich.toml +24 -0
- package/core/commands/mednotes/fix-wiki.toml +24 -0
- package/core/commands/mednotes/history.toml +19 -0
- package/core/commands/mednotes/link-body.toml +22 -0
- package/core/commands/mednotes/link-related.toml +24 -0
- package/core/commands/mednotes/link.toml +24 -0
- package/core/commands/mednotes/pdf-library.toml +24 -0
- package/core/commands/mednotes/process-chats.toml +20 -0
- package/core/commands/mednotes/setup.toml +18 -0
- package/core/commands/mednotes/status.toml +24 -0
- package/core/commands/mednotes/telemetry.toml +24 -0
- package/core/commands/report.toml +23 -0
- package/core/skills/THIRD_PARTY_NOTICES.md +45 -0
- package/core/skills/create-medical-flashcards/SKILL.md +113 -0
- package/core/skills/create-medical-note/SKILL.md +90 -0
- package/core/skills/enrich-medical-note/SKILL.md +120 -0
- package/core/skills/fix-medical-wiki/SKILL.md +559 -0
- package/core/skills/link-medical-wiki/SKILL.md +224 -0
- package/core/skills/obsidian-cli/SKILL.md +118 -0
- package/core/skills/obsidian-markdown/SKILL.md +207 -0
- package/core/skills/obsidian-markdown/references/CALLOUTS.md +58 -0
- package/core/skills/obsidian-markdown/references/EMBEDS.md +63 -0
- package/core/skills/obsidian-markdown/references/PROPERTIES.md +61 -0
- package/core/skills/obsidian-ops/SKILL.md +136 -0
- package/core/skills/pdf-library/SKILL.md +45 -0
- package/core/skills/process-medical-chats/SKILL.md +246 -0
- package/core/skills/workflow-report/SKILL.md +100 -0
- package/package.json +45 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"""Dry-run receipts for destructive publish-batch CLI runs."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import hashlib
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import time
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from pydantic import Field, StrictBool, StrictInt, StrictStr
|
|
11
|
+
from pydantic import ValidationError as PydanticValidationError
|
|
12
|
+
|
|
13
|
+
from mednotes.domains.wiki.batch_state import batch_state_from, canonical_json_hash
|
|
14
|
+
from mednotes.domains.wiki.capabilities.notes.raw_chats import atomic_write_text
|
|
15
|
+
from mednotes.domains.wiki.common import ValidationError, _now_iso
|
|
16
|
+
from mednotes.domains.wiki.config import MedConfig, _path, _user_state_dir
|
|
17
|
+
from mednotes.domains.wiki.contracts.publish import PublishReceipt
|
|
18
|
+
from mednotes.kernel.base import ContractModel, JsonObject, JsonObjectAdapter, contract_error
|
|
19
|
+
|
|
20
|
+
PUBLISH_DRY_RUN_RECEIPTS_SCHEMA = "medical-notes-workbench.publish-dry-run-receipts.v1"
|
|
21
|
+
DEFAULT_PUBLISH_DRY_RUN_TTL_SECONDS = 30 * 60
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _default_new_leaf_authorization() -> JsonObject:
|
|
25
|
+
return {"required": False, "note_count": 0, "notes": []}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _default_new_leaf_authorization_hash() -> str:
|
|
29
|
+
return canonical_json_hash(_default_new_leaf_authorization())
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class _NewTaxonomyLeafAuthorizationFields(ContractModel):
|
|
33
|
+
required: StrictBool = False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class _PublishDryRunReceipt(ContractModel):
|
|
37
|
+
manifest: StrictStr = Field(min_length=1)
|
|
38
|
+
manifest_sha256: StrictStr = Field(min_length=1)
|
|
39
|
+
manifest_hash: StrictStr = ""
|
|
40
|
+
cwd: StrictStr = Field(min_length=1)
|
|
41
|
+
wiki_dir: StrictStr = Field(min_length=1)
|
|
42
|
+
raw_dir: StrictStr = Field(min_length=1)
|
|
43
|
+
collision: StrictStr = Field(min_length=1)
|
|
44
|
+
allow_new_taxonomy_leaf: StrictBool
|
|
45
|
+
require_coverage: StrictBool
|
|
46
|
+
dry_run_options_hash: StrictStr = Field(min_length=1)
|
|
47
|
+
batch_state: list[JsonObject] = Field(default_factory=list)
|
|
48
|
+
new_taxonomy_leaf_authorization: JsonObject = Field(default_factory=_default_new_leaf_authorization)
|
|
49
|
+
new_taxonomy_leaf_authorization_hash: StrictStr = Field(default_factory=_default_new_leaf_authorization_hash)
|
|
50
|
+
dry_run_at: StrictStr = Field(min_length=1)
|
|
51
|
+
expires_at: StrictInt
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def build_publish_receipt_payload(
|
|
55
|
+
*,
|
|
56
|
+
status: str,
|
|
57
|
+
batch_id: str,
|
|
58
|
+
published_count: int,
|
|
59
|
+
skipped_count: int,
|
|
60
|
+
items: list[JsonObject],
|
|
61
|
+
next_action: str = "",
|
|
62
|
+
error_context: JsonObject | None = None,
|
|
63
|
+
) -> JsonObject:
|
|
64
|
+
payload: JsonObject = {
|
|
65
|
+
"schema": "medical-notes-workbench.publish-receipt.v1",
|
|
66
|
+
"status": status,
|
|
67
|
+
"batch_id": batch_id,
|
|
68
|
+
"published_count": published_count,
|
|
69
|
+
"skipped_count": skipped_count,
|
|
70
|
+
"items": JsonObjectAdapter.validate_python({"items": items})["items"],
|
|
71
|
+
"next_action": next_action,
|
|
72
|
+
}
|
|
73
|
+
if error_context is not None:
|
|
74
|
+
payload["error_context"] = JsonObjectAdapter.validate_python({"error_context": error_context})[
|
|
75
|
+
"error_context"
|
|
76
|
+
]
|
|
77
|
+
return PublishReceipt.model_validate(payload).to_payload()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def publish_receipts_path() -> Path:
|
|
81
|
+
override = os.environ.get("MEDNOTES_PUBLISH_RECEIPTS_PATH")
|
|
82
|
+
if override:
|
|
83
|
+
return _path(override)
|
|
84
|
+
return _user_state_dir() / "publish-dry-run-receipts.json"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def publish_receipt_ttl_seconds() -> int:
|
|
88
|
+
value = os.environ.get("MEDNOTES_PUBLISH_DRY_RUN_TTL_SECONDS")
|
|
89
|
+
if not value:
|
|
90
|
+
return DEFAULT_PUBLISH_DRY_RUN_TTL_SECONDS
|
|
91
|
+
try:
|
|
92
|
+
seconds = int(value)
|
|
93
|
+
except ValueError:
|
|
94
|
+
return DEFAULT_PUBLISH_DRY_RUN_TTL_SECONDS
|
|
95
|
+
return min(24 * 60 * 60, max(1, seconds))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _manifest_key(manifest: Path) -> str:
|
|
99
|
+
try:
|
|
100
|
+
return str(manifest.resolve())
|
|
101
|
+
except OSError:
|
|
102
|
+
return str(manifest)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _sha256_file(path: Path) -> str:
|
|
106
|
+
try:
|
|
107
|
+
data = path.read_bytes()
|
|
108
|
+
except FileNotFoundError as exc:
|
|
109
|
+
raise ValidationError(f"Manifest not found: {path}") from exc
|
|
110
|
+
return hashlib.sha256(data).hexdigest()
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _manifest_batch_state(manifest: Path) -> list[dict[str, str]]:
|
|
114
|
+
try:
|
|
115
|
+
data = json.loads(manifest.read_text(encoding="utf-8"))
|
|
116
|
+
except (FileNotFoundError, json.JSONDecodeError):
|
|
117
|
+
return []
|
|
118
|
+
if not isinstance(data, dict):
|
|
119
|
+
return []
|
|
120
|
+
raw_batches = data.get("batches") if "batches" in data else [data]
|
|
121
|
+
if not isinstance(raw_batches, list):
|
|
122
|
+
return []
|
|
123
|
+
states: list[dict[str, str]] = []
|
|
124
|
+
for batch in raw_batches:
|
|
125
|
+
if not isinstance(batch, dict):
|
|
126
|
+
continue
|
|
127
|
+
state = batch_state_from(batch)
|
|
128
|
+
raw_file = batch.get("raw_file")
|
|
129
|
+
raw_files = batch.get("raw_files")
|
|
130
|
+
coverage_path = batch.get("coverage_path")
|
|
131
|
+
if raw_file:
|
|
132
|
+
state["raw_file"] = str(raw_file)
|
|
133
|
+
if isinstance(raw_files, list) and raw_files:
|
|
134
|
+
state["raw_files"] = ",".join(str(item) for item in raw_files if str(item).strip())
|
|
135
|
+
if coverage_path:
|
|
136
|
+
state["coverage_path"] = str(coverage_path)
|
|
137
|
+
if state:
|
|
138
|
+
states.append(state)
|
|
139
|
+
return states
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _dry_run_options_hash(
|
|
143
|
+
*,
|
|
144
|
+
cwd: str,
|
|
145
|
+
wiki_dir: str,
|
|
146
|
+
raw_dir: str,
|
|
147
|
+
collision: str,
|
|
148
|
+
allow_new_taxonomy_leaf: bool,
|
|
149
|
+
require_coverage: bool,
|
|
150
|
+
) -> str:
|
|
151
|
+
return canonical_json_hash(
|
|
152
|
+
{
|
|
153
|
+
"cwd": cwd,
|
|
154
|
+
"wiki_dir": wiki_dir,
|
|
155
|
+
"raw_dir": raw_dir,
|
|
156
|
+
"collision": collision,
|
|
157
|
+
"allow_new_taxonomy_leaf": bool(allow_new_taxonomy_leaf),
|
|
158
|
+
"require_coverage": bool(require_coverage),
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _empty_state() -> JsonObject:
|
|
164
|
+
return {"schema": PUBLISH_DRY_RUN_RECEIPTS_SCHEMA, "receipts": {}}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _load_state(path: Path | None = None) -> JsonObject:
|
|
168
|
+
state_path = path or publish_receipts_path()
|
|
169
|
+
try:
|
|
170
|
+
data = json.loads(state_path.read_text(encoding="utf-8"))
|
|
171
|
+
except (FileNotFoundError, json.JSONDecodeError):
|
|
172
|
+
return _empty_state()
|
|
173
|
+
try:
|
|
174
|
+
payload = JsonObjectAdapter.validate_python(data)
|
|
175
|
+
except PydanticValidationError:
|
|
176
|
+
return _empty_state()
|
|
177
|
+
receipts = payload["receipts"] if "receipts" in payload else {}
|
|
178
|
+
if not isinstance(receipts, dict):
|
|
179
|
+
payload["receipts"] = {}
|
|
180
|
+
payload["schema"] = PUBLISH_DRY_RUN_RECEIPTS_SCHEMA
|
|
181
|
+
return payload
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def _save_state(state: JsonObject, path: Path | None = None) -> None:
|
|
185
|
+
state_path = path or publish_receipts_path()
|
|
186
|
+
state["schema"] = PUBLISH_DRY_RUN_RECEIPTS_SCHEMA
|
|
187
|
+
atomic_write_text(state_path, json.dumps(state, ensure_ascii=False, indent=2) + "\n")
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _signature(
|
|
191
|
+
manifest: Path,
|
|
192
|
+
config: MedConfig,
|
|
193
|
+
*,
|
|
194
|
+
collision: str,
|
|
195
|
+
allow_new_taxonomy_leaf: bool,
|
|
196
|
+
require_coverage: bool,
|
|
197
|
+
) -> JsonObject:
|
|
198
|
+
manifest_hash = _sha256_file(manifest)
|
|
199
|
+
cwd = str(Path.cwd().resolve())
|
|
200
|
+
wiki_dir = str(config.wiki_dir)
|
|
201
|
+
raw_dir = str(config.raw_dir)
|
|
202
|
+
return JsonObjectAdapter.validate_python({
|
|
203
|
+
"manifest": _manifest_key(manifest),
|
|
204
|
+
"manifest_sha256": manifest_hash,
|
|
205
|
+
"manifest_hash": manifest_hash,
|
|
206
|
+
"cwd": cwd,
|
|
207
|
+
"wiki_dir": wiki_dir,
|
|
208
|
+
"raw_dir": raw_dir,
|
|
209
|
+
"collision": collision,
|
|
210
|
+
"allow_new_taxonomy_leaf": bool(allow_new_taxonomy_leaf),
|
|
211
|
+
"require_coverage": bool(require_coverage),
|
|
212
|
+
"dry_run_options_hash": _dry_run_options_hash(
|
|
213
|
+
cwd=cwd,
|
|
214
|
+
wiki_dir=wiki_dir,
|
|
215
|
+
raw_dir=raw_dir,
|
|
216
|
+
collision=collision,
|
|
217
|
+
allow_new_taxonomy_leaf=allow_new_taxonomy_leaf,
|
|
218
|
+
require_coverage=require_coverage,
|
|
219
|
+
),
|
|
220
|
+
"batch_state": _manifest_batch_state(manifest),
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def _new_leaf_authorization_payload(authorization: object | None) -> JsonObject:
|
|
225
|
+
if authorization is None:
|
|
226
|
+
return _default_new_leaf_authorization()
|
|
227
|
+
try:
|
|
228
|
+
return JsonObjectAdapter.validate_python(authorization)
|
|
229
|
+
except PydanticValidationError as exc:
|
|
230
|
+
raise contract_error(exc, prefix="new taxonomy leaf authorization invalid") from exc
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def _new_leaf_authorization_fields(authorization: JsonObject) -> _NewTaxonomyLeafAuthorizationFields:
|
|
234
|
+
raw_fields: JsonObject = {}
|
|
235
|
+
if "required" in authorization:
|
|
236
|
+
raw_fields["required"] = authorization["required"]
|
|
237
|
+
try:
|
|
238
|
+
return _NewTaxonomyLeafAuthorizationFields.model_validate(raw_fields)
|
|
239
|
+
except PydanticValidationError as exc:
|
|
240
|
+
raise contract_error(exc, prefix="new taxonomy leaf authorization invalid") from exc
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _new_leaf_authorization_hash(authorization: object | None) -> str:
|
|
244
|
+
return canonical_json_hash(_new_leaf_authorization_payload(authorization))
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _state_receipts(state: JsonObject) -> JsonObject:
|
|
248
|
+
receipts = state["receipts"] if "receipts" in state else {}
|
|
249
|
+
if not isinstance(receipts, dict):
|
|
250
|
+
return {}
|
|
251
|
+
return JsonObjectAdapter.validate_python(receipts)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _receipt_from_state(state: JsonObject, key: str) -> object | None:
|
|
255
|
+
receipts = state["receipts"] if "receipts" in state else {}
|
|
256
|
+
if not isinstance(receipts, dict) or key not in receipts:
|
|
257
|
+
return None
|
|
258
|
+
return receipts[key]
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def _dry_run_receipt_fields(receipt: object) -> _PublishDryRunReceipt:
|
|
262
|
+
try:
|
|
263
|
+
payload = JsonObjectAdapter.validate_python(receipt)
|
|
264
|
+
return _PublishDryRunReceipt.model_validate(payload)
|
|
265
|
+
except PydanticValidationError as exc:
|
|
266
|
+
detail = contract_error(exc, prefix="publish dry-run receipt invalid")
|
|
267
|
+
raise ValidationError(
|
|
268
|
+
"Bloqueado: o dry-run receipt salvo é inválido. Rode publish-batch --dry-run novamente. "
|
|
269
|
+
f"Detalhe: {detail}"
|
|
270
|
+
) from exc
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def record_publish_dry_run(
|
|
274
|
+
manifest: Path,
|
|
275
|
+
config: MedConfig,
|
|
276
|
+
*,
|
|
277
|
+
collision: str,
|
|
278
|
+
allow_new_taxonomy_leaf: bool,
|
|
279
|
+
require_coverage: bool,
|
|
280
|
+
new_taxonomy_leaf_authorization: JsonObject | None = None,
|
|
281
|
+
) -> JsonObject:
|
|
282
|
+
state = _load_state()
|
|
283
|
+
now = int(time.time())
|
|
284
|
+
authorization_payload = _new_leaf_authorization_payload(new_taxonomy_leaf_authorization)
|
|
285
|
+
receipt = {
|
|
286
|
+
**_signature(
|
|
287
|
+
manifest,
|
|
288
|
+
config,
|
|
289
|
+
collision=collision,
|
|
290
|
+
allow_new_taxonomy_leaf=allow_new_taxonomy_leaf,
|
|
291
|
+
require_coverage=require_coverage,
|
|
292
|
+
),
|
|
293
|
+
"new_taxonomy_leaf_authorization": authorization_payload,
|
|
294
|
+
"new_taxonomy_leaf_authorization_hash": _new_leaf_authorization_hash(authorization_payload),
|
|
295
|
+
"dry_run_at": _now_iso(),
|
|
296
|
+
"expires_at": now + publish_receipt_ttl_seconds(),
|
|
297
|
+
}
|
|
298
|
+
receipts = _state_receipts(state)
|
|
299
|
+
receipts[_manifest_key(manifest)] = JsonObjectAdapter.validate_python(receipt)
|
|
300
|
+
state["receipts"] = receipts
|
|
301
|
+
_save_state(state)
|
|
302
|
+
return JsonObjectAdapter.validate_python(receipt)
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def require_publish_dry_run(
|
|
306
|
+
manifest: Path,
|
|
307
|
+
config: MedConfig,
|
|
308
|
+
*,
|
|
309
|
+
collision: str,
|
|
310
|
+
allow_new_taxonomy_leaf: bool,
|
|
311
|
+
require_coverage: bool,
|
|
312
|
+
new_taxonomy_leaf_authorization: JsonObject | None = None,
|
|
313
|
+
) -> JsonObject:
|
|
314
|
+
state = _load_state()
|
|
315
|
+
key = _manifest_key(manifest)
|
|
316
|
+
receipt_value = _receipt_from_state(state, key)
|
|
317
|
+
if receipt_value is None:
|
|
318
|
+
raise ValidationError(
|
|
319
|
+
"dry_run_receipt_invalid: rode publish-batch --dry-run para este manifest antes do publish real."
|
|
320
|
+
)
|
|
321
|
+
receipt = _dry_run_receipt_fields(receipt_value)
|
|
322
|
+
|
|
323
|
+
if int(time.time()) > receipt.expires_at:
|
|
324
|
+
raise ValidationError(
|
|
325
|
+
"dry_run_receipt_invalid: o dry-run desse manifest expirou. Rode publish-batch --dry-run novamente."
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
current = _signature(
|
|
329
|
+
manifest,
|
|
330
|
+
config,
|
|
331
|
+
collision=collision,
|
|
332
|
+
allow_new_taxonomy_leaf=allow_new_taxonomy_leaf,
|
|
333
|
+
require_coverage=require_coverage,
|
|
334
|
+
)
|
|
335
|
+
if receipt.manifest_sha256 != current["manifest_sha256"]:
|
|
336
|
+
raise ValidationError(
|
|
337
|
+
"dry_run_receipt_invalid: o manifest mudou desde o dry-run. Rode publish-batch --dry-run novamente."
|
|
338
|
+
)
|
|
339
|
+
receipt_signature = {
|
|
340
|
+
"cwd": receipt.cwd,
|
|
341
|
+
"wiki_dir": receipt.wiki_dir,
|
|
342
|
+
"raw_dir": receipt.raw_dir,
|
|
343
|
+
"collision": receipt.collision,
|
|
344
|
+
"allow_new_taxonomy_leaf": receipt.allow_new_taxonomy_leaf,
|
|
345
|
+
"require_coverage": receipt.require_coverage,
|
|
346
|
+
}
|
|
347
|
+
for field, value in receipt_signature.items():
|
|
348
|
+
if value != current[field]:
|
|
349
|
+
raise ValidationError(
|
|
350
|
+
"dry_run_receipt_invalid: caminhos ou opcoes de publish mudaram desde o dry-run. "
|
|
351
|
+
"Rode publish-batch --dry-run novamente."
|
|
352
|
+
)
|
|
353
|
+
expected_auth = _new_leaf_authorization_payload(new_taxonomy_leaf_authorization)
|
|
354
|
+
if _new_leaf_authorization_fields(expected_auth).required:
|
|
355
|
+
expected_hash = _new_leaf_authorization_hash(expected_auth)
|
|
356
|
+
if receipt.new_taxonomy_leaf_authorization_hash != expected_hash:
|
|
357
|
+
raise ValidationError("new_taxonomy_leaf_requires_dry_run_authorization")
|
|
358
|
+
return receipt.to_payload()
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def clear_publish_dry_run(manifest: Path) -> None:
|
|
362
|
+
state = _load_state()
|
|
363
|
+
receipts = state.setdefault("receipts", {})
|
|
364
|
+
if receipts.pop(_manifest_key(manifest), None) is not None:
|
|
365
|
+
_save_state(state)
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"""Read-only publish/process-chats recovery diagnostics."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import shlex
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from pydantic import ConfigDict, Field, StrictInt, StrictStr
|
|
8
|
+
from pydantic import ValidationError as PydanticValidationError
|
|
9
|
+
|
|
10
|
+
from mednotes.domains.wiki.batch_state import file_sha256
|
|
11
|
+
from mednotes.domains.wiki.capabilities.publish.publish import (
|
|
12
|
+
publish_batch_operation_result,
|
|
13
|
+
)
|
|
14
|
+
from mednotes.domains.wiki.capabilities.publish.publish_receipts import require_publish_dry_run
|
|
15
|
+
from mednotes.domains.wiki.common import ValidationError
|
|
16
|
+
from mednotes.domains.wiki.config import MedConfig
|
|
17
|
+
from mednotes.domains.wiki.contracts.workflow_guardrails import PUBLISH_REQUIRED_INPUTS, annotate_payload, error_context
|
|
18
|
+
from mednotes.kernel.base import ContractModel, JsonObject, JsonObjectAdapter, contract_error
|
|
19
|
+
|
|
20
|
+
PUBLISH_STATE_DIAGNOSIS_SCHEMA = "medical-notes-workbench.publish-state-diagnosis.v1"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class _PublishStateDryRunReceipt(ContractModel):
|
|
24
|
+
expires_at: StrictInt
|
|
25
|
+
manifest_hash: StrictStr = ""
|
|
26
|
+
manifest_sha256: StrictStr = ""
|
|
27
|
+
dry_run_options_hash: StrictStr = ""
|
|
28
|
+
batch_state: list[JsonObject] = Field(default_factory=list)
|
|
29
|
+
|
|
30
|
+
def status_payload(self) -> JsonObject:
|
|
31
|
+
return JsonObjectAdapter.validate_python(
|
|
32
|
+
{
|
|
33
|
+
"expires_at": self.expires_at,
|
|
34
|
+
"manifest_hash": self.manifest_hash or self.manifest_sha256,
|
|
35
|
+
"dry_run_options_hash": self.dry_run_options_hash,
|
|
36
|
+
"batch_state": [dict(item) for item in self.batch_state],
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class _PublishStatePlannedBatch(ContractModel):
|
|
42
|
+
model_config = ConfigDict(extra="ignore")
|
|
43
|
+
|
|
44
|
+
notes: list[JsonObject] = Field(default_factory=list)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class _PublishStatePreviewResult(ContractModel):
|
|
48
|
+
"""Typed lens over publish dry-run output consumed by publish-status."""
|
|
49
|
+
|
|
50
|
+
model_config = ConfigDict(extra="ignore")
|
|
51
|
+
|
|
52
|
+
status: StrictStr
|
|
53
|
+
blocked_reason: StrictStr = ""
|
|
54
|
+
next_action: StrictStr = ""
|
|
55
|
+
planned_batches: list[_PublishStatePlannedBatch] = Field(default_factory=list)
|
|
56
|
+
batch_state: list[JsonObject] = Field(default_factory=list)
|
|
57
|
+
new_taxonomy_leaf_authorization: JsonObject = Field(default_factory=dict)
|
|
58
|
+
error_context: JsonObject = Field(default_factory=dict)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _dry_run_receipt_status_payload(receipt: object) -> JsonObject:
|
|
62
|
+
try:
|
|
63
|
+
payload = JsonObjectAdapter.validate_python(receipt)
|
|
64
|
+
status_fields: JsonObject = {
|
|
65
|
+
key: payload[key]
|
|
66
|
+
for key in ("expires_at", "manifest_hash", "manifest_sha256", "dry_run_options_hash", "batch_state")
|
|
67
|
+
if key in payload
|
|
68
|
+
}
|
|
69
|
+
return _PublishStateDryRunReceipt.model_validate(status_fields).status_payload()
|
|
70
|
+
except PydanticValidationError as exc:
|
|
71
|
+
detail = contract_error(exc, prefix="publish-status dry-run receipt invalid")
|
|
72
|
+
raise ValidationError(
|
|
73
|
+
"Bloqueado: o dry-run receipt retornado pela recuperação de publish é inválido. "
|
|
74
|
+
"Rode publish-batch --dry-run novamente. "
|
|
75
|
+
f"Detalhe: {detail}"
|
|
76
|
+
) from exc
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _cmd(manifest: Path, *, dry_run: bool = False) -> str:
|
|
80
|
+
parts = ["publish-batch", "--manifest", str(manifest)]
|
|
81
|
+
if dry_run:
|
|
82
|
+
parts.append("--dry-run")
|
|
83
|
+
return " ".join(shlex.quote(part) for part in parts)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _blocked_payload(
|
|
87
|
+
*,
|
|
88
|
+
manifest: Path,
|
|
89
|
+
status_payload: JsonObject,
|
|
90
|
+
blocked_reason: str,
|
|
91
|
+
affected_artifact: str,
|
|
92
|
+
error_summary: str,
|
|
93
|
+
suggested_fix: str,
|
|
94
|
+
retry_scope: str,
|
|
95
|
+
next_action: str,
|
|
96
|
+
missing_inputs: list[str] | None = None,
|
|
97
|
+
) -> JsonObject:
|
|
98
|
+
missing_inputs = missing_inputs or []
|
|
99
|
+
payload: JsonObject = JsonObjectAdapter.validate_python({
|
|
100
|
+
**status_payload,
|
|
101
|
+
"dry_run_receipt_status": "invalid" if blocked_reason == "dry_run_receipt_invalid" else "not_checked",
|
|
102
|
+
"mutated": False,
|
|
103
|
+
"missing_inputs": missing_inputs,
|
|
104
|
+
})
|
|
105
|
+
payload["error_context"] = error_context(
|
|
106
|
+
phase="publish-status",
|
|
107
|
+
blocked_reason=blocked_reason,
|
|
108
|
+
root_cause=blocked_reason,
|
|
109
|
+
affected_artifact=affected_artifact,
|
|
110
|
+
error_summary=error_summary,
|
|
111
|
+
suggested_fix=suggested_fix,
|
|
112
|
+
next_action=next_action,
|
|
113
|
+
retry_scope=retry_scope,
|
|
114
|
+
missing_inputs=missing_inputs,
|
|
115
|
+
)
|
|
116
|
+
return annotate_payload(
|
|
117
|
+
payload,
|
|
118
|
+
phase="publish_status",
|
|
119
|
+
status="blocked",
|
|
120
|
+
blocked_reason=blocked_reason,
|
|
121
|
+
next_action=next_action,
|
|
122
|
+
required_inputs=PUBLISH_REQUIRED_INPUTS,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _blocked_payload_from_preview(
|
|
127
|
+
*,
|
|
128
|
+
manifest: Path,
|
|
129
|
+
status_payload: JsonObject,
|
|
130
|
+
preview: _PublishStatePreviewResult,
|
|
131
|
+
) -> JsonObject:
|
|
132
|
+
error_ctx = preview.error_context
|
|
133
|
+
blocked_reason = str(
|
|
134
|
+
error_ctx.get("blocked_reason")
|
|
135
|
+
or error_ctx.get("root_cause")
|
|
136
|
+
or preview.blocked_reason
|
|
137
|
+
or "publish_state_blocked"
|
|
138
|
+
)
|
|
139
|
+
next_action = str(
|
|
140
|
+
error_ctx.get("next_action")
|
|
141
|
+
or preview.next_action
|
|
142
|
+
or "Corrigir o erro estruturado e repetir publish-status antes de publicar."
|
|
143
|
+
)
|
|
144
|
+
missing_inputs = error_ctx.get("missing_inputs")
|
|
145
|
+
return _blocked_payload(
|
|
146
|
+
manifest=manifest,
|
|
147
|
+
status_payload=status_payload,
|
|
148
|
+
blocked_reason=blocked_reason,
|
|
149
|
+
affected_artifact=str(error_ctx.get("affected_artifact") or "publish_state"),
|
|
150
|
+
error_summary=str(error_ctx.get("error_summary") or "Publish dry-run blocked."),
|
|
151
|
+
suggested_fix=str(error_ctx.get("suggested_fix") or next_action),
|
|
152
|
+
retry_scope=str(error_ctx.get("retry_scope") or "inspect_publish_state"),
|
|
153
|
+
next_action=next_action,
|
|
154
|
+
missing_inputs=[str(item) for item in missing_inputs] if isinstance(missing_inputs, list) else [],
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _dry_run_receipt_blocked_payload(*, manifest: Path, status_payload: JsonObject, message: str) -> JsonObject:
|
|
159
|
+
next_action = f"Rodar {_cmd(manifest, dry_run=True)} com as mesmas opções antes do publish real."
|
|
160
|
+
return _blocked_payload(
|
|
161
|
+
manifest=manifest,
|
|
162
|
+
status_payload=status_payload,
|
|
163
|
+
blocked_reason="dry_run_receipt_invalid",
|
|
164
|
+
affected_artifact="dry_run_receipt",
|
|
165
|
+
error_summary=message,
|
|
166
|
+
suggested_fix="Gerar novo dry-run receipt com publish-batch --dry-run.",
|
|
167
|
+
retry_scope="publish_dry_run_then_apply",
|
|
168
|
+
next_action=next_action,
|
|
169
|
+
missing_inputs=["dry_run_receipt"],
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def diagnose_publish_state(
|
|
174
|
+
manifest: Path,
|
|
175
|
+
config: MedConfig,
|
|
176
|
+
*,
|
|
177
|
+
collision: str = "abort",
|
|
178
|
+
allow_new_taxonomy_leaf: bool = True,
|
|
179
|
+
require_coverage: bool = True,
|
|
180
|
+
) -> JsonObject:
|
|
181
|
+
"""Return a non-mutating publish readiness diagnosis for agents."""
|
|
182
|
+
manifest = Path(manifest)
|
|
183
|
+
status_payload: JsonObject = {
|
|
184
|
+
"schema": PUBLISH_STATE_DIAGNOSIS_SCHEMA,
|
|
185
|
+
"manifest": str(manifest),
|
|
186
|
+
"manifest_exists": manifest.exists(),
|
|
187
|
+
"manifest_hash": file_sha256(manifest) if manifest.exists() else "",
|
|
188
|
+
"collision": collision,
|
|
189
|
+
"allow_new_taxonomy_leaf": bool(allow_new_taxonomy_leaf),
|
|
190
|
+
"require_coverage": bool(require_coverage),
|
|
191
|
+
"planned_batch_count": 0,
|
|
192
|
+
"planned_note_count": 0,
|
|
193
|
+
"batch_state": [],
|
|
194
|
+
"mutated": False,
|
|
195
|
+
}
|
|
196
|
+
preview = _PublishStatePreviewResult.model_validate(
|
|
197
|
+
publish_batch_operation_result(
|
|
198
|
+
manifest,
|
|
199
|
+
config,
|
|
200
|
+
collision=collision,
|
|
201
|
+
dry_run=True,
|
|
202
|
+
allow_new_taxonomy_leaf=allow_new_taxonomy_leaf,
|
|
203
|
+
require_coverage=require_coverage,
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
if preview.status == "blocked":
|
|
207
|
+
return _blocked_payload_from_preview(manifest=manifest, status_payload=status_payload, preview=preview)
|
|
208
|
+
status_payload.update(
|
|
209
|
+
{
|
|
210
|
+
"planned_batch_count": len(preview.planned_batches),
|
|
211
|
+
"planned_note_count": sum(len(batch.notes) for batch in preview.planned_batches),
|
|
212
|
+
"batch_state": preview.batch_state,
|
|
213
|
+
"new_taxonomy_leaf_authorization_required": bool(preview.new_taxonomy_leaf_authorization.get("required")),
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
try:
|
|
217
|
+
receipt = require_publish_dry_run(
|
|
218
|
+
manifest,
|
|
219
|
+
config,
|
|
220
|
+
collision=collision,
|
|
221
|
+
allow_new_taxonomy_leaf=allow_new_taxonomy_leaf,
|
|
222
|
+
require_coverage=require_coverage,
|
|
223
|
+
new_taxonomy_leaf_authorization=preview.new_taxonomy_leaf_authorization,
|
|
224
|
+
)
|
|
225
|
+
except ValidationError as exc:
|
|
226
|
+
return _dry_run_receipt_blocked_payload(
|
|
227
|
+
manifest=manifest,
|
|
228
|
+
status_payload=status_payload,
|
|
229
|
+
message=str(exc),
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
status_payload["dry_run_receipt_status"] = "valid"
|
|
233
|
+
status_payload["dry_run_receipt"] = _dry_run_receipt_status_payload(receipt)
|
|
234
|
+
return annotate_payload(
|
|
235
|
+
status_payload,
|
|
236
|
+
phase="publish_status",
|
|
237
|
+
status="ready",
|
|
238
|
+
next_action=f"Rodar {_cmd(manifest)} com as mesmas opções.",
|
|
239
|
+
required_inputs=PUBLISH_REQUIRED_INPUTS,
|
|
240
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""quality."""
|