howhard 3.0.0__tar.gz → 3.0.2__tar.gz

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.
Files changed (102) hide show
  1. {howhard-3.0.0 → howhard-3.0.2}/.antigravity-plugin/plugin.json +1 -1
  2. {howhard-3.0.0 → howhard-3.0.2}/.claude-plugin/plugin.json +1 -1
  3. {howhard-3.0.0 → howhard-3.0.2}/CHANGELOG.md +26 -0
  4. {howhard-3.0.0/src/howhard.egg-info → howhard-3.0.2}/PKG-INFO +1 -1
  5. {howhard-3.0.0 → howhard-3.0.2}/docs/capability.md +23 -8
  6. {howhard-3.0.0 → howhard-3.0.2}/docs/concurrency.md +49 -4
  7. {howhard-3.0.0 → howhard-3.0.2}/docs/context.md +5 -1
  8. {howhard-3.0.0 → howhard-3.0.2}/docs/index.md +2 -2
  9. {howhard-3.0.0 → howhard-3.0.2}/docs/reference.md +5 -2
  10. {howhard-3.0.0 → howhard-3.0.2}/docs/semantic-memory.md +5 -2
  11. {howhard-3.0.0 → howhard-3.0.2}/docs/skills.md +4 -0
  12. {howhard-3.0.0 → howhard-3.0.2}/plugin.json +1 -1
  13. {howhard-3.0.0 → howhard-3.0.2}/skills/howhard/SKILL.md +4 -1
  14. {howhard-3.0.0 → howhard-3.0.2}/skills/howhard/references/workflow.md +8 -1
  15. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/__init__.py +3 -2
  16. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/capability.py +11 -4
  17. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/cli.py +2 -1
  18. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/decisions.py +8 -1
  19. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/engine.py +98 -26
  20. howhard-3.0.2/src/howhard/request_state.py +182 -0
  21. {howhard-3.0.0 → howhard-3.0.2/src/howhard.egg-info}/PKG-INFO +1 -1
  22. {howhard-3.0.0 → howhard-3.0.2}/src/howhard.egg-info/SOURCES.txt +2 -0
  23. {howhard-3.0.0 → howhard-3.0.2}/tests/test_capability_filter.py +51 -0
  24. {howhard-3.0.0 → howhard-3.0.2}/tests/test_context.py +2 -1
  25. howhard-3.0.2/tests/test_request_dependencies.py +387 -0
  26. {howhard-3.0.0 → howhard-3.0.2}/tests/test_semantic_only.py +2 -3
  27. {howhard-3.0.0 → howhard-3.0.2}/tests/test_write_queue.py +13 -8
  28. {howhard-3.0.0 → howhard-3.0.2}/.agents/plugins/marketplace.json +0 -0
  29. {howhard-3.0.0 → howhard-3.0.2}/.claude-plugin/marketplace.json +0 -0
  30. {howhard-3.0.0 → howhard-3.0.2}/.readthedocs.yaml +0 -0
  31. {howhard-3.0.0 → howhard-3.0.2}/AGENTS.md +0 -0
  32. {howhard-3.0.0 → howhard-3.0.2}/MANIFEST.in +0 -0
  33. {howhard-3.0.0 → howhard-3.0.2}/README.md +0 -0
  34. {howhard-3.0.0 → howhard-3.0.2}/benchmarks/__init__.py +0 -0
  35. {howhard-3.0.0 → howhard-3.0.2}/benchmarks/bench_rule_retrieval.py +0 -0
  36. {howhard-3.0.0 → howhard-3.0.2}/benchmarks/rule_cases.json +0 -0
  37. {howhard-3.0.0 → howhard-3.0.2}/benchmarks/rule_retrieval.py +0 -0
  38. {howhard-3.0.0 → howhard-3.0.2}/docs/changelog.md +0 -0
  39. {howhard-3.0.0 → howhard-3.0.2}/docs/conf.py +0 -0
  40. {howhard-3.0.0 → howhard-3.0.2}/docs/configuration.md +0 -0
  41. {howhard-3.0.0 → howhard-3.0.2}/docs/contributing.md +0 -0
  42. {howhard-3.0.0 → howhard-3.0.2}/docs/evaluation.md +0 -0
  43. {howhard-3.0.0 → howhard-3.0.2}/docs/quickstart.md +0 -0
  44. {howhard-3.0.0 → howhard-3.0.2}/docs/releasing.md +0 -0
  45. {howhard-3.0.0 → howhard-3.0.2}/docs/requirements.txt +0 -0
  46. {howhard-3.0.0 → howhard-3.0.2}/docs/retrieval.md +0 -0
  47. {howhard-3.0.0 → howhard-3.0.2}/docs/rule-benchmark.md +0 -0
  48. {howhard-3.0.0 → howhard-3.0.2}/docs/session_handoff_format.md +0 -0
  49. {howhard-3.0.0 → howhard-3.0.2}/docs/upgrading-1.0.md +0 -0
  50. {howhard-3.0.0 → howhard-3.0.2}/docs/upgrading-2.0.md +0 -0
  51. {howhard-3.0.0 → howhard-3.0.2}/docs/upgrading-3.0.md +0 -0
  52. {howhard-3.0.0 → howhard-3.0.2}/pyproject.toml +0 -0
  53. {howhard-3.0.0 → howhard-3.0.2}/scripts/check +0 -0
  54. {howhard-3.0.0 → howhard-3.0.2}/scripts/check-plugins.py +0 -0
  55. {howhard-3.0.0 → howhard-3.0.2}/scripts/check-skills.py +0 -0
  56. {howhard-3.0.0 → howhard-3.0.2}/scripts/verify-wheel.py +0 -0
  57. {howhard-3.0.0 → howhard-3.0.2}/setup.cfg +0 -0
  58. {howhard-3.0.0 → howhard-3.0.2}/skills/attribute-failure/SKILL.md +0 -0
  59. {howhard-3.0.0 → howhard-3.0.2}/skills/howhard/references/accounting.md +0 -0
  60. {howhard-3.0.0 → howhard-3.0.2}/skills/howhard/references/hosts.md +0 -0
  61. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/__main__.py +0 -0
  62. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/accounting.py +0 -0
  63. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/config.py +0 -0
  64. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/context.py +0 -0
  65. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/data/context.toml +0 -0
  66. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/data/default_config.toml +0 -0
  67. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/data/semantic.toml +0 -0
  68. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/files.py +0 -0
  69. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/llm.py +0 -0
  70. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/memory.py +0 -0
  71. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/native.py +0 -0
  72. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/report.py +0 -0
  73. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/retrieval.py +0 -0
  74. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/selector.py +0 -0
  75. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/semantic.py +0 -0
  76. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/state.py +0 -0
  77. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/storage.py +0 -0
  78. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/success.py +0 -0
  79. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/validation.py +0 -0
  80. {howhard-3.0.0 → howhard-3.0.2}/src/howhard/writes.py +0 -0
  81. {howhard-3.0.0 → howhard-3.0.2}/src/howhard.egg-info/dependency_links.txt +0 -0
  82. {howhard-3.0.0 → howhard-3.0.2}/src/howhard.egg-info/entry_points.txt +0 -0
  83. {howhard-3.0.0 → howhard-3.0.2}/src/howhard.egg-info/requires.txt +0 -0
  84. {howhard-3.0.0 → howhard-3.0.2}/src/howhard.egg-info/top_level.txt +0 -0
  85. {howhard-3.0.0 → howhard-3.0.2}/tests/conftest.py +0 -0
  86. {howhard-3.0.0 → howhard-3.0.2}/tests/test_cli.py +0 -0
  87. {howhard-3.0.0 → howhard-3.0.2}/tests/test_configured_candidates.py +0 -0
  88. {howhard-3.0.0 → howhard-3.0.2}/tests/test_cost_to_success.py +0 -0
  89. {howhard-3.0.0 → howhard-3.0.2}/tests/test_current_contract.py +0 -0
  90. {howhard-3.0.0 → howhard-3.0.2}/tests/test_execution_accounting.py +0 -0
  91. {howhard-3.0.0 → howhard-3.0.2}/tests/test_fast_reranking.py +0 -0
  92. {howhard-3.0.0 → howhard-3.0.2}/tests/test_measurement_corrections.py +0 -0
  93. {howhard-3.0.0 → howhard-3.0.2}/tests/test_memory.py +0 -0
  94. {howhard-3.0.0 → howhard-3.0.2}/tests/test_native_startup.py +0 -0
  95. {howhard-3.0.0 → howhard-3.0.2}/tests/test_portable_core.py +0 -0
  96. {howhard-3.0.0 → howhard-3.0.2}/tests/test_retrieval.py +0 -0
  97. {howhard-3.0.0 → howhard-3.0.2}/tests/test_retrieval_config.py +0 -0
  98. {howhard-3.0.0 → howhard-3.0.2}/tests/test_rule_benchmark.py +0 -0
  99. {howhard-3.0.0 → howhard-3.0.2}/tests/test_semantic.py +0 -0
  100. {howhard-3.0.0 → howhard-3.0.2}/tests/test_semantic_cli.py +0 -0
  101. {howhard-3.0.0 → howhard-3.0.2}/tests/test_skill_workflow.py +0 -0
  102. {howhard-3.0.0 → howhard-3.0.2}/tests/test_storage.py +0 -0
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
3
  "name": "howhard",
4
4
  "displayName": "howhard",
5
- "version": "3.0.0",
5
+ "version": "3.0.2",
6
6
  "description": "Recommend model and reasoning effort from task context, then learn from actual feedback through writable semantic memory.",
7
7
  "author": {"name": "howhard contributors"},
8
8
  "repository": "https://github.com/xu-hao/howhard"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "howhard",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Recommend model and reasoning effort from task context, then learn from actual feedback through writable semantic memory.",
5
5
  "author": {"name": "howhard contributors"},
6
6
  "repository": "https://github.com/xu-hao/howhard"
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.2 — 2026-11-11
4
+
5
+ - Bound the learned capability band when no inventory cell reaches
6
+ `reliability_probability`. Treat that as an explicit case: anchor the gain-margin cut
7
+ at the lower cut and measure it against the best attained clearing probability,
8
+ instead of running the band to the strongest cell. Easy tasks with low lower bounds
9
+ are no longer refused with `max_forecast_cells exceeded after re-filter` merely
10
+ because the inventory is large. Stronger cells are classified overpowered and remain
11
+ reachable through stronger-only widening. A band that is genuinely wider than the
12
+ budget still gets one re-filter and then the refusal. Receipt formats are unchanged
13
+ (#72).
14
+
15
+ ## 3.0.1 — 2026-11-10
16
+
17
+ - Keep concurrent routing requests valid across unrelated observations and memory
18
+ writes. Capture one consistent read snapshot, freeze belief/capability weights, and
19
+ validate only surfaced memory/evidence dependencies plus bound configuration (#69).
20
+ - Return typed `StaleRequest` conflicts with changed IDs/versions or evidence digests
21
+ and a refreshed request. Preserve dependency tracking through extra retrieval,
22
+ filtering, forecasting and widening; retain FIFO admission and strict writer revisions
23
+ (#69).
24
+ - Preserve the original dependency conflict if refresh or failure-audit admission times
25
+ out; return bounded recovery diagnostics without masking the changed inputs (#69).
26
+ - Record the snapshot policy and dependency manifest in new immutable receipts while
27
+ retaining existing v6 receipt and conservative legacy v5 request compatibility (#69).
28
+
3
29
  ## 3.0.0 — 2026-11-09
4
30
 
5
31
  - Accept any nonempty distinct candidate inventory and learn a task-specific capability
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: howhard
3
- Version: 3.0.0
3
+ Version: 3.0.2
4
4
  Summary: Choose an agent's model and reasoning effort, and learn from outcomes.
5
5
  Project-URL: Repository, https://github.com/xu-hao/howhard
6
6
  Project-URL: Issues, https://github.com/xu-hao/howhard/issues
@@ -16,11 +16,22 @@ within-model order. Cross-model placements can change with related execution evi
16
16
 
17
17
  Fitness is a band: underpowered, fit, then overpowered. Threshold-clearing probability
18
18
  is monotone along this decision's order; fitness is not a score that improves forever
19
- with capability. A stronger cell is overpowered when a weaker one already meets the
20
- reliability target and the additional clearing probability is below the gain margin.
21
- The upper cut uses a reliable weaker cell whose gain to the strongest remaining cell
22
- is below the margin, so the entire excluded suffix qualifies. Price, retry cost, and
23
- accepted-result silent risk belong to stage 2.
19
+ with capability. A stronger cell is overpowered when a weaker fit cell already gives
20
+ nearly all the clearing probability this inventory offers: the additional clearing
21
+ probability is below the gain margin. The lower cut is the first cell reaching
22
+ `min_clear_probability`. The upper cut is the first cell at or above its anchor whose
23
+ gain to the strongest cell is below the margin, so the entire excluded suffix
24
+ qualifies. The strongest cell attains the best clearing probability because the
25
+ probability is monotone along the order.
26
+
27
+ The anchor is the first cell reaching `reliability_probability`, so the band always
28
+ includes a reliable cell when one exists. If no cell reaches that target, the target
29
+ is unattainable within this inventory and cannot anchor the band. "No reliable cell" is
30
+ then an explicit case: the anchor is the lower cut, and the gain cut alone, measured
31
+ against the best attained probability, ends the band. The upper cut never falls back
32
+ to the strongest cell merely because the target is unmet. Stronger cells remain
33
+ reachable through stronger-only widening. Price, retry cost, and accepted-result silent
34
+ risk belong to stage 2.
24
35
 
25
36
  The order assumes a useful scalar approximation to the demands of this task. Related
26
37
  tasks and noisy outcomes do not establish a universal ranking, causal explanation,
@@ -101,9 +112,13 @@ Neither independent call receives memory, execution evidence or learned tables.
101
112
  The inventory has no count limit. `max_forecast_cells` is a budget for fine forecasts,
102
113
  not an inventory cap. If the learned band exceeds it, `decide` returns one re-filter
103
114
  request with the full inventory. A second oversized band errors and asks for a tighter
104
- filter. The backend never slices a band to fit the budget. If the posterior puts every cell
105
- below the minimum clearing probability, it refuses routing and asks for a more capable
106
- inventory; it does not relabel a known underpowered strongest cell as fit.
115
+ filter. Because neither cut falls back to the strongest cell, an oversized band means
116
+ the posterior spreads material clearing-probability gains over more cells than the
117
+ budget; a sharper prior can narrow it. The backend never slices a band to fit the
118
+ budget, which would exclude cells that still add material clearing probability. If the
119
+ posterior puts every cell below the minimum clearing probability, it refuses routing
120
+ and asks for a more capable inventory; it does not relabel a known underpowered
121
+ strongest cell as fit.
107
122
 
108
123
  If no forecast cell passes the accepted-result silent cap, request the next stronger
109
124
  overpowered cell, one per widening round, in capability order. Each requires an actual
@@ -18,7 +18,8 @@ number may restart after the queue empties; the random ticket suffix distinguish
18
18
  | --- | --- |
19
19
  | First use | Validate evidence, establish project/store identity; initialize memory schema when needed |
20
20
  | Native inventories | Validate and merge historical identity metadata |
21
- | `context` / `retrieve` | Publish the immutable request artifact after checking evidence and memory again |
21
+ | `context` | Capture one consistent store snapshot; publish the immutable request even if writers ran during retrieval |
22
+ | `retrieve` / stage transitions | Recheck surfaced dependencies before publishing the next immutable request |
22
23
  | `decide` / `pick` | Commit the receipt after checking its forecast inputs again; audit events have separate turns |
23
24
  | `observe` / amendments | Read current evidence, validate IDs, provenance and corrections, then append/fsync |
24
25
  | `usage attach` | Collect the owned source outside admission; validate and append the correction inside admission |
@@ -102,14 +103,58 @@ crash/flush recovery rules still apply. Queueing does not make a multi-file flus
102
103
 
103
104
  ## Revalidation and retries
104
105
 
106
+ ### Prepared request dependencies
107
+
108
+ Preparation briefly takes shared data locks to capture evidence, native identities and
109
+ one SQLite memory snapshot consistently. Retrieval, capability relevance scoring and
110
+ model inference then run against those captured values outside the read lock and FIFO
111
+ write turn. Writers may continue while preparation runs; their commits cannot cause
112
+ preparation itself to fail as stale. A dependency changed during preparation is checked
113
+ when the resulting request is used.
114
+
115
+ New v5 requests persist the read snapshot and a dependency manifest. It contains exact
116
+ content/active versions of surfaced memories, effective-row digests of surfaced evidence
117
+ (including execution experts and capability inputs), and the bound configuration digest.
118
+ Dependencies accumulate across filtering, extra retrieval, forecasting and widening.
119
+ Additional memory/evidence retrieval reads the original snapshot. It cannot silently
120
+ replace old content with a newer version. Edits to unsurfaced memories, new observations
121
+ and unrelated learning commits leave the request valid. Amendments or usage corrections
122
+ to a surfaced execution invalidate it when its effective contents change.
123
+
124
+ The weight policy is **snapshot**. Both readers use the captured belief/expert scores,
125
+ evidence counts and capability observation/recency weights throughout the workflow.
126
+ They do not replay concurrent outcomes into an in-flight forecast. The receipt's optional
127
+ `request_snapshot` records this policy, the dependency manifest, the captured evidence
128
+ hash and memory revision. These are decision-time provenance; the global revision is
129
+ not a freshness condition. Previously prepared v5 requests without this metadata retain
130
+ their conservative whole-store validation. Existing v6 receipts remain readable.
131
+
132
+ At load and after write admission, howhard checks the dependencies again before a new
133
+ stage or receipt is committed. A genuine conflict raises Python `StaleRequest`, exported
134
+ from `howhard`. Its `as_dict()` returns `code: "stale_request"`, the original request ID,
135
+ `changes` and `refreshed_request`. Memory changes name the ID, old/new versions and active
136
+ states; evidence/configuration changes report old/new digests. `decide` and `retrieve`
137
+ with `--json` return this object under `error` on stderr with exit status 2.
138
+
139
+ The refreshed request restarts filtering because a changed precedent can affect the
140
+ fit band as well as its forecasts. It preserves the original task/project snapshot and
141
+ explicit inventory, or refreshes a named configured inventory. No old response is applied
142
+ automatically. `baseline_unchanged` says whether the failed request's independent baseline
143
+ is identical to the returned one; only an identical baseline permits reusing that isolated
144
+ answer. Re-evaluate affected memory/evidence reasoning. Refresh is attempted once; if
145
+ admission or configuration prevents it, `refresh_error` explains the failure and the
146
+ original conflict remains visible. There is no unbounded retry or writer-window protocol.
147
+ If recording the failed-decision audit also fails admission, `audit_error` carries its
148
+ typed diagnostic without replacing the original `stale_request` or changed dependencies.
149
+
105
150
  For example, an observation and a memory update from two worktrees register in one
106
151
  store queue. The memory update waits its turn, then checks the expected revision
107
152
  against current memory. A stale revision still returns the existing actionable
108
153
  conflict; howhard never silently rebases a patch. Learning also checks the effective
109
154
  evidence event after admission. A prepared request remains bound to its worktree,
110
- actual candidate inventory, evidence and memory revision. Evidence or memory changes
111
- during forecasting, retrieval or a queue wait require a new request. Adding an unrelated
112
- historical model identity alone does not invalidate a disjoint inventory.
155
+ actual candidate inventory and surfaced dependencies. A changed dependency during
156
+ forecasting, retrieval or a queue wait returns the structured conflict described above.
157
+ Unrelated writes and historical identity additions do not invalidate a disjoint request.
113
158
 
114
159
  A timeout does not execute later in the background. Resubmit a normal call if needed;
115
160
  no manual queue cleanup is required. Reuse the same stable observation/attachment ID
@@ -39,7 +39,11 @@ howhard observe DECISION_ID clean --tokens 12000 --seconds 45
39
39
  Every pick saves a content-addressed receipt under `decisions/` in the backend state
40
40
  root reported by `howhard paths` (local `.howhard` for plain folders). Its ID is
41
41
  printed in text and JSON output. The receipt includes the chosen cell, task description,
42
- project snapshot, seed and risk class. A later observation resolves the receipt and
42
+ project snapshot, seed and risk class. New receipts also retain `request_snapshot`:
43
+ the snapshot weight policy and exact surfaced dependencies used by the staged request.
44
+ Unrelated concurrent writes leave those prospective inputs unchanged; a changed
45
+ dependency returns a [structured conflict and refresh](concurrency.md).
46
+ A later observation resolves the receipt and
43
47
  copies that original context into the append-only row. It does not rescan the newer
44
48
  project. `--save-decision PATH` copies the receipt for another process; the short observe
45
49
  form also accepts that file path. Explicit four-argument observe supports `--decision ID`
@@ -6,8 +6,8 @@
6
6
  - [Task-specific capability filtering](capability.md) — learned fit bands, threshold evidence,
7
7
  bounded fine forecasts, widening and filter-quality reports.
8
8
  - [Upgrading to 3.0](upgrading-3.0.md) — two-stage requests and accepted-result selection.
9
- - [Concurrent clients](concurrency.md) — backend-owned FIFO write admission, bounded waits,
10
- cancellation, queue status and safe retries across worktrees.
9
+ - [Concurrent clients](concurrency.md) — backend-owned FIFO admission, snapshot/dependency
10
+ validity, structured refresh conflicts, bounded waits and safe retries across worktrees.
11
11
  - [Task text and changing project context](context.md) — original task/project text, immutable
12
12
  snapshots and decision receipts.
13
13
  - [LLM reasoning and writable semantic memory](semantic-memory.md) — reader/writer
@@ -264,8 +264,11 @@ Frozen-receipt observations and learning share the store across that project's w
264
264
 
265
265
  Validated LLM responses may be cached by complete request, adapter identity, settings,
266
266
  evidence and memory revision. Corrupt caches are replaced. Prepared requests bind the
267
- current worktree, native inventory, effective evidence and memory revision; stale requests
268
- must be prepared again. Calling-agent submissions are audited with unknown external
267
+ current worktree, native inventory and a consistent store snapshot. New requests validate
268
+ only surfaced memory/evidence dependencies and configuration, with belief and capability
269
+ weights frozen at preparation. Unrelated writes do not invalidate them. A real change
270
+ returns a typed conflict and refreshed request; see [concurrent clients](concurrency.md).
271
+ Calling-agent submissions are audited with unknown external
269
272
  inference costs and latency rather than being counted as free provider calls.
270
273
 
271
274
  Receipts use `howhard-decision-v6`, requests `howhard-agent-request-v5`, semantic state
@@ -215,8 +215,11 @@ request. Evaluate the baseline in a separate model context, then submit
215
215
  for calibrated rows over the fit band. Evaluate that clean baseline independently and
216
216
  submit `{forecasts, memory_forecasts, reason}`. Handle explicit re-filter or stronger-only
217
217
  widening requests until a decision ID is returned. The full inventory remains bound
218
- throughout; follow-up commands never replace it. Retrieval returns a new request ID including frozen results. Stale evidence or
219
- memory requires preparing again. This protocol never claims the calling agent's model
218
+ throughout; follow-up commands never replace it. Retrieval returns a new request ID including frozen results.
219
+ Unrelated writes do not invalidate an in-flight request: belief/expert weights and
220
+ capability inputs use the preparation snapshot. Changed surfaced dependencies return
221
+ `StaleRequest` with the changed IDs/versions and a refreshed request, as documented in
222
+ [concurrent clients](concurrency.md). This protocol never claims the calling agent's model
220
223
  calls are free: externally supplied forecasts and updates are audited separately, with
221
224
  unknown model cost and latency. The host can retain its own measured usage alongside
222
225
  these submissions; they are not included in the package's measured call count.
@@ -172,6 +172,10 @@ instructs agents to submit normal calls, inspect `writes --json` for contention
172
172
  retry with stable IDs after a timeout. Agents must not create a writer-window or
173
173
  acquire/release protocol in their conversation channels. Stale writer patches still
174
174
  require fresh context and a regenerated response.
175
+ Routing requests use snapshot weights and validate only surfaced dependencies. On
176
+ `stale_request`, inspect the named changes and use the returned `refreshed_request`;
177
+ reuse an independent answer only when its baseline is identical, then regenerate the
178
+ affected reasoning. Unrelated observations or memory additions require no restart.
175
179
 
176
180
  No project bridge, model mapping, statistical settings, lock feature or extra audit
177
181
  ledger is needed. Native manifests and the stateful Python backend remain separate.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "howhard",
4
- "version": "3.0.0",
4
+ "version": "3.0.2",
5
5
  "description": "Recommend model and reasoning effort from task context, then learn from actual feedback through writable semantic memory.",
6
6
  "author": {"name": "howhard contributors"},
7
7
  "repository": "https://github.com/xu-hao/howhard"
@@ -32,7 +32,10 @@ the host's actual tools execute the task.
32
32
  bounded waiting and crash release. Do not exchange writer-window/acquire/release
33
33
  messages or maintain an agent-channel mutex. Inspect `howhard writes --json` for
34
34
  contention; use `--write-timeout` when needed. After a timeout resubmit normally
35
- with the same stable IDs; refresh/regenerate stale requests or writer patches.
35
+ with the same stable IDs. Routing uses snapshot weights; unrelated writes do not
36
+ invalidate requests. For `stale_request`, inspect changed dependencies and use its
37
+ `refreshed_request`; reuse an independent answer only if the baseline is identical.
38
+ Regenerate affected reasoning. Writer patches still require current revisions.
36
39
  Honor the user/application's fixed retrieval configuration. Do not edit it or try
37
40
  to upgrade its reranker when results are weak; retrieval tools accept no tier,
38
41
  model or configuration override.
@@ -89,7 +89,14 @@ and a reason. Follow new request IDs through one explicit re-filter or bounded
89
89
  stronger-only widening until `decision_id` is returned; never truncate or invent rows. Copy opaque family/effort keys emitted by the
90
90
  backend; do not invent or rename them. An empty override list is valid. Generate honest
91
91
  prospective estimates; do not fabricate past forecasts, observations or independence.
92
- If an independent context is unavailable, report routing unavailable and stop selection. If evidence/memory is stale, prepare again once; report repeated failure.
92
+ If an independent context is unavailable, report routing unavailable and stop selection.
93
+ The backend freezes belief/capability weights and reads from the prepared snapshot;
94
+ unrelated writes do not invalidate the flow. A `stale_request` error names changed
95
+ surfaced dependencies and carries a `refreshed_request` restarting the filter. Use that
96
+ request and regenerate affected reasoning; reuse a prior independent answer only when
97
+ the baseline is identical (`baseline_unchanged`). If refresh fails, prepare again once
98
+ using the reported cause; report repeated failure. Never silently reuse stale reasoning
99
+ or invent a writer window. Explicit memory writer revisions remain strict.
93
100
 
94
101
  The decision includes the receipt `decision_id`, `chosen` native ID/control,
95
102
  `cost_policy`, and cap/review status. With any unpriced cell, `worker_money_included`
@@ -1,11 +1,12 @@
1
1
  """LLM model and effort selection, with a zero-configuration starting point."""
2
2
 
3
- __version__ = "3.0.0"
3
+ __version__ = "3.0.2"
4
4
 
5
5
  from .config import load_config
6
6
  from .engine import Engine
7
7
  from .retrieval import RetrievalPipeline
8
8
  from .writes import WriteError, WriteTimeout, WriteCancelled, WriteDependencyError
9
+ from .request_state import StaleRequest
9
10
 
10
11
  __all__ = ["Engine", "RetrievalPipeline", "load_config", "__version__",
11
- "WriteError", "WriteTimeout", "WriteCancelled", "WriteDependencyError"]
12
+ "WriteError", "WriteTimeout", "WriteCancelled", "WriteDependencyError", "StaleRequest"]
@@ -219,7 +219,7 @@ def _learn_order(order, cdf, obs, cells, policy):
219
219
  order, score = best, best_score
220
220
 
221
221
 
222
- def aggregate(engine, payload, response):
222
+ def aggregate(engine, payload, response, *, observed=None):
223
223
  from .semantic import normalize_support
224
224
  policy = payload["filter_policy"]
225
225
  baseline = response["filter"]
@@ -255,7 +255,7 @@ def aggregate(engine, payload, response):
255
255
  b, a = blocks.pop(), blocks.pop()
256
256
  blocks.append((a[0]+b[0], (len(a[0])*a[1]+len(b[0])*b[1])/(len(a[0])+len(b[0]))))
257
257
  cdf = {k: p for group, p in blocks for k in group}
258
- obs = observations(engine, payload)
258
+ obs = observations(engine, payload) if observed is None else deepcopy(observed)
259
259
  learned_order = _learn_order(order, cdf, obs, payload["cells"], policy) if obs else order
260
260
  cdf = dict(zip(learned_order, [cdf[k] for k in order]))
261
261
  probabilities, _ = _posterior(learned_order, cdf, obs, policy)
@@ -263,8 +263,15 @@ def aggregate(engine, payload, response):
263
263
  lo = next((i for i, k in enumerate(learned_order) if probabilities[k] >= policy["min_clear_probability"]), n)
264
264
  if lo == n:
265
265
  raise HowHardError("capability filter: no cell reaches the required capability probability; supply a more capable inventory")
266
- reliable = next((i for i, k in enumerate(learned_order) if i >= lo and probabilities[k] >= policy["reliability_probability"]), n-1)
267
- hi = next((i for i in range(reliable, n) if probabilities[learned_order[-1]]-probabilities[learned_order[i]] < policy["overpowered_gain_margin"]), n-1)
266
+ # P_clear is monotone along the order, so the strongest cell attains the best probability.
267
+ best = probabilities[learned_order[-1]]
268
+ reliable = next((i for i in range(lo, n) if probabilities[learned_order[i]] >= policy["reliability_probability"]), None)
269
+ # The band reaches the first reliable cell, then stops once the remaining gain is below
270
+ # the margin. With no reliable cell the target is unattainable in this inventory and
271
+ # cannot anchor the band; the gain cut against the best attained probability then
272
+ # applies from the lower cut instead of defaulting to the strongest cell.
273
+ anchor = lo if reliable is None else reliable
274
+ hi = next((i for i in range(anchor, n) if best-probabilities[learned_order[i]] < policy["overpowered_gain_margin"]), n-1)
268
275
  # The original LLM cuts are exact when no evidence or memory adjustment exists.
269
276
  if not obs and len(worlds) == 1:
270
277
  lo, hi = learned_order.index(baseline["lower"]), learned_order.index(baseline["upper"])
@@ -272,7 +272,8 @@ def main(argv=None):
272
272
  return 130
273
273
  except (HowHardError, OSError) as exc:
274
274
  from .writes import WriteError
275
- if args.json and isinstance(exc, WriteError):
275
+ from .request_state import StaleRequest
276
+ if args.json and isinstance(exc, (WriteError, StaleRequest)):
276
277
  print(json.dumps({"error": exc.as_dict()}), file=sys.stderr)
277
278
  return 2
278
279
  print(f"howhard: {exc}", file=sys.stderr)
@@ -22,6 +22,8 @@ def save(config, result):
22
22
  value["selection"] = result["selection"]
23
23
  value["cost_policy"] = result["cost_policy"]
24
24
  value["native_candidates"] = result["native_candidates"]
25
+ if "request_snapshot" in result:
26
+ value["request_snapshot"] = result["request_snapshot"]
25
27
  decision_id = digest(value)
26
28
  from .storage import locked
27
29
  with locked(config, operation="receipt commit"):
@@ -55,7 +57,10 @@ def load(config, source, *, for_scoring=False):
55
57
  return None # Preserve old evidence without replaying a removed predictor.
56
58
  if not isinstance(value, dict) or value.get("format") != DECISION_FORMAT:
57
59
  raise HowHardError("decision.format: unsupported version; prepare a new capability-filtered decision")
58
- keys(value, ["format", "project", "project_identity", "task_type", "risk_class", "chosen", "seed", "context", "cost_policy", "native_candidates", "semantic", "capability", "selection"], where="decision")
60
+ keys(value, ["format", "project", "project_identity", "task_type", "risk_class", "chosen", "seed", "context", "cost_policy", "native_candidates", "semantic", "capability", "selection"], ["request_snapshot"], where="decision")
61
+ if "request_snapshot" in value:
62
+ from .request_state import validate_provenance
63
+ validate_provenance(value["request_snapshot"])
59
64
  policy = value["cost_policy"]
60
65
  keys(policy, ["worker_money_included", "unknown_price_models", "comparison", "basis"], where="decision.cost_policy")
61
66
  if type(policy["worker_money_included"]) is not bool or not isinstance(policy["unknown_price_models"], list):
@@ -71,6 +76,8 @@ def load(config, source, *, for_scoring=False):
71
76
  return all(v is not None for v in c["rate_card"]["rates"].values()) if "rate_card" in c else c.get("usd_per_mtok") is not None
72
77
  from .semantic import validate_receipt as validate_semantic
73
78
  validate_semantic(value["semantic"])
79
+ if "request_snapshot" in value and value["request_snapshot"]["memory_revision"] != value["semantic"]["memory_revision"]:
80
+ raise HowHardError("request_snapshot: memory revision differs from frozen semantic inputs")
74
81
  forecast_pairs = {(c["family"], c["effort"]) for c in value["semantic"]["worlds"]["llm"]}
75
82
  priced_inventory = [c for c in inventory if (config.data["models"].get(c["model"], {}).get("family"), c["effort"]) in forecast_pairs]
76
83
  unknown = sorted({c["model"] for c in priced_inventory if not priced(c)})
@@ -105,8 +105,12 @@ class Engine:
105
105
  def summary(self, task_type, task_text="", *, project_context=None, risk=None, native_candidates=None, inventory=None):
106
106
  from .native import resolve
107
107
  candidates = resolve(self.config, native_candidates, inventory)
108
- return self._drive(task_type, task_text, project_context=project_context, risk=risk,
109
- native_candidates=candidates, select=False)
108
+ try:
109
+ return self._drive(task_type, task_text, project_context=project_context, risk=risk,
110
+ native_candidates=candidates, select=False)
111
+ except HowHardError as exc:
112
+ self._refresh_stale(exc)
113
+ raise
110
114
 
111
115
  def pick(self, task_type, task_text="", *, project_context=None, risk=None, seed=None, native_candidates=None, inventory=None):
112
116
  from .native import resolve
@@ -115,13 +119,24 @@ class Engine:
115
119
  try:
116
120
  result = self._pick(task_type, task_text, project_context=project_context, risk=risk, seed=seed, native_candidates=native_candidates)
117
121
  except Exception as exc:
118
- from .writes import WriteError
119
- if not isinstance(exc, WriteError):
120
- self._decision_event(None, task_type, started, error=type(exc).__name__)
122
+ self._refresh_stale(exc)
123
+ self._failed_decision_event(exc, task_type, started)
121
124
  raise
122
125
  self._decision_event(result, task_type, started)
123
126
  return result
124
127
 
128
+ def _failed_decision_event(self, error, task_type, started):
129
+ from .writes import WriteError
130
+ from .request_state import StaleRequest
131
+ if isinstance(error, WriteError):
132
+ return
133
+ try:
134
+ self._decision_event(None, task_type, started, error=type(error).__name__)
135
+ except WriteError as audit:
136
+ if not isinstance(error, StaleRequest):
137
+ raise
138
+ error.audit_error = audit.as_dict()
139
+
125
140
  def _decision_event(self, result, task_type, started, error=None):
126
141
  event = {"event_id": secrets.token_hex(12), "at_utc": datetime.now(timezone.utc).isoformat(),
127
142
  "task_type": task_type if isinstance(task_type, str) else type(task_type).__name__, "status": "failed" if error else "completed", "error": error,
@@ -145,10 +160,16 @@ class Engine:
145
160
  native_candidates=native_candidates)
146
161
  self._inference()
147
162
  while "request_id" in pending:
148
- bundle = self._load_request(pending["request_id"])
149
- response, payload, usage = semantic.complete(self, bundle["payload"], bundle["snapshot"])
150
- bundle["payload"] = payload
151
- pending = self._advance(bundle, response, seed=seed, usage=usage, select=select)
163
+ from .request_state import view, StaleRequest
164
+ try:
165
+ bundle = self._load_request(pending["request_id"])
166
+ reader = view(self, bundle["read_state"]) if "read_state" in bundle else self
167
+ response, payload, usage = semantic.complete(reader, bundle["payload"], bundle["snapshot"])
168
+ bundle["payload"] = payload
169
+ pending = self._advance(bundle, response, seed=seed, usage=usage, select=select)
170
+ except StaleRequest as exc:
171
+ exc.request_id = pending["request_id"]
172
+ raise
152
173
  return pending
153
174
 
154
175
  def _validate_state(self, evidence_key, revision):
@@ -167,23 +188,34 @@ class Engine:
167
188
 
168
189
  def prepare(self, task_type, task_text="", *, project_context=None, risk=None, native_candidates=None, inventory=None):
169
190
  from .native import resolve
191
+ from .request_state import capture, configuration
170
192
  candidates = self._register(resolve(self.config, native_candidates, inventory))
171
- prepared = self._prepared(task_type, risk, task_text, project_context, candidates)
172
- payload, snapshot = semantic.request(self, prepared)
173
- from .capability import request
174
- bundle = {"format": "howhard-agent-request-v5", "evidence_key": self.evidence_key,
193
+ reader, read_state = capture(self)
194
+ prepared = reader._prepared(task_type, risk, task_text, project_context, candidates)
195
+ payload, snapshot = semantic.request(reader, prepared)
196
+ payload["weights_policy"] = "snapshot"
197
+ self.last_retrieval_usage = reader.last_retrieval_usage
198
+ from .capability import request, observations
199
+ bundle = {"format": "howhard-agent-request-v5", "evidence_key": reader.evidence_key,
175
200
  "payload": request(payload, self.config.data["capability"]), "snapshot": snapshot,
176
201
  "stage": "filter", "capability": None, "refilter_round": 0,
177
202
  "forecast_template": payload, "forecast_state": None, "coarse_usage": None}
203
+ bundle["read_state"] = read_state
204
+ bundle["dependencies"] = {"configuration": configuration(reader.config), "memories": {}, "evidence": {}}
205
+ bundle["learned_state"] = {"weights_policy": "snapshot", "capability_observations": observations(reader, bundle["payload"])}
206
+ bundle["inventory_source"] = inventory
178
207
  bundle["native_candidates"] = candidates
179
208
  bundle["project_root"] = str(self.config.project_root)
180
- return self._save_request(bundle)
209
+ return self._save_request(bundle, validate=False)
181
210
 
182
- def _save_request(self, bundle):
211
+ def _save_request(self, bundle, *, validate=True):
183
212
  from .files import atomic_write
213
+ from .request_state import extend
214
+ extend(self, bundle)
184
215
  request_id = digest(bundle)
185
216
  with storage.locked(self.config, operation="request commit"):
186
- self._validate_state(bundle["evidence_key"], bundle["snapshot"]["revision"])
217
+ if validate:
218
+ self._check_request(bundle)
187
219
  atomic_write(self.config.state_root / "requests" / f"{request_id}.json", canonical(bundle) + b"\n")
188
220
  return {"request_id": request_id, "stage": bundle["stage"], "refilter_round": bundle["refilter_round"],
189
221
  "capability": bundle["capability"], "request": semantic.visible_request(bundle["payload"]),
@@ -200,23 +232,58 @@ class Engine:
200
232
  except (OSError, ValueError) as exc:
201
233
  raise HowHardError("request_id: unavailable or invalid agent request") from exc
202
234
  from .validation import keys
203
- keys(bundle, ["format", "evidence_key", "payload", "snapshot", "native_candidates", "project_root", "stage", "capability", "refilter_round", "forecast_template", "forecast_state", "coarse_usage"], where="request")
235
+ keys(bundle, ["format", "evidence_key", "payload", "snapshot", "native_candidates", "project_root", "stage", "capability", "refilter_round", "forecast_template", "forecast_state", "coarse_usage"],
236
+ ["read_state", "dependencies", "learned_state", "inventory_source"], where="request")
204
237
  if digest(bundle) != request_id or bundle["format"] != "howhard-agent-request-v5":
205
238
  raise HowHardError("request_id: request integrity or format mismatch")
206
239
  if bundle["project_root"] != str(self.config.project_root):
207
240
  raise HowHardError("request_id: belongs to another worktree; prepare in the current project")
208
- if bundle["evidence_key"] != self.evidence_key or bundle["snapshot"]["revision"] != self.memory.snapshot()["revision"]:
209
- raise HowHardError("request_id: stale evidence or memory; prepare a new decision")
241
+ with storage.reading(self.config):
242
+ self._check_request(bundle)
210
243
  return bundle
211
244
 
245
+ def _check_request(self, bundle):
246
+ from .request_state import changes, StaleRequest
247
+ self.refresh()
248
+ if "dependencies" not in bundle:
249
+ return self._validate_state(bundle["evidence_key"], bundle["snapshot"]["revision"])
250
+ changed = changes(self, bundle)
251
+ if changed:
252
+ raise StaleRequest(changed, bundle)
253
+
254
+ def _refresh_stale(self, error, request_id=None):
255
+ from .request_state import StaleRequest
256
+ if not isinstance(error, StaleRequest):
257
+ return
258
+ if request_id is not None:
259
+ error.request_id = request_id
260
+ bundle, payload = error.bundle, error.bundle["payload"]
261
+ try:
262
+ options = ({"inventory": bundle["inventory_source"]} if bundle.get("inventory_source")
263
+ else {"native_candidates": bundle["native_candidates"]})
264
+ error.refreshed_request = self.prepare(payload["task_type"], payload["context"]["task_text"],
265
+ project_context=payload["context"]["project_context"], risk=payload["risk_class"], **options)
266
+ error.baseline_unchanged = semantic.baseline_request(payload) == error.refreshed_request["baseline_request"]
267
+ except HowHardError as exc:
268
+ error.refresh_error = str(exc)
269
+
212
270
  def retrieve(self, request_id, queries):
271
+ try:
272
+ return self._retrieve(request_id, queries)
273
+ except HowHardError as exc:
274
+ self._refresh_stale(exc, request_id)
275
+ raise
276
+
277
+ def _retrieve(self, request_id, queries):
213
278
  if not isinstance(queries, list) or not 1 <= len(queries) <= 3:
214
279
  raise HowHardError("retrieval: provide between one and three tool requests")
215
280
  bundle = self._load_request(request_id)
281
+ from .request_state import view
282
+ reader = view(self, bundle["read_state"]) if "read_state" in bundle else self
216
283
  if len(bundle["payload"]["retrieval"]) + len(queries) > 3 * semantic.SETTINGS["retrieval_rounds"]:
217
284
  raise HowHardError("retrieval: request budget exceeded")
218
285
  for query in queries:
219
- result = semantic.tool(self, query, project_snapshot=bundle["payload"]["context"]["project_context"])
286
+ result = semantic.tool(reader, query, project_snapshot=bundle["payload"]["context"]["project_context"])
220
287
  bundle["payload"]["retrieval"].append({"request": query, "result": result})
221
288
  return self._save_request(bundle)
222
289
 
@@ -225,9 +292,8 @@ class Engine:
225
292
  try:
226
293
  result = self._decide(request_id, response, seed=seed)
227
294
  except Exception as exc:
228
- from .writes import WriteError
229
- if not isinstance(exc, WriteError):
230
- self._decision_event(None, "calling-agent", started, error=type(exc).__name__)
295
+ self._refresh_stale(exc, request_id)
296
+ self._failed_decision_event(exc, "calling-agent", started)
231
297
  raise
232
298
  if "decision_id" in result:
233
299
  self._decision_event(result, result["task_type"], started)
@@ -255,15 +321,18 @@ class Engine:
255
321
  from copy import deepcopy
256
322
  from . import capability
257
323
  payload, snapshot = bundle["payload"], bundle["snapshot"]
324
+ from .request_state import extend
325
+ extend(self, bundle)
258
326
  response = semantic.validate_response(response, payload, snapshot)
259
327
  if usage is None:
260
328
  semantic.external_submission(self, payload)
261
329
  usage = {"backend": "calling-agent", "seconds": 0., "cost_usd": None, "calls": [],
262
330
  "cached": False, "call_seconds": 0., "call_cost_usd": None}
263
331
  with storage.reading(self.config):
264
- self._validate_state(bundle["evidence_key"], snapshot["revision"])
332
+ self._check_request(bundle)
265
333
  if bundle["stage"] == "filter":
266
- state = capability.aggregate(self, payload, response)
334
+ state = capability.aggregate(self, payload, response,
335
+ observed=bundle.get("learned_state", {}).get("capability_observations"))
267
336
  bundle["coarse_usage"] = semantic.combine_usage(bundle["coarse_usage"], usage)
268
337
  state["reader_usage"] = {k: deepcopy(bundle["coarse_usage"][k]) for k in ("backend", "seconds", "cost_usd", "calls")}
269
338
  state["refilter_rounds"] = bundle["refilter_round"]
@@ -313,6 +382,9 @@ class Engine:
313
382
  return self._forecast_request(bundle, {next_cell})
314
383
  state["widening_stop"] = "cap-met" if admissible else "forecast-budget" if len(forecasted) >= state["policy"]["max_forecast_cells"] else "round-limit" if stronger else "exhausted"
315
384
  prepared[0]["capability"] = state
385
+ if "dependencies" in bundle:
386
+ prepared[0]["request_snapshot"] = {"weights_policy": "snapshot", "dependencies": deepcopy(bundle["dependencies"]),
387
+ "evidence_key": bundle["evidence_key"], "memory_revision": snapshot["revision"]}
316
388
  # Include both reader calls in routing overhead; no invented provider costs.
317
389
  coarse = bundle["coarse_usage"]
318
390
  prepared[0]["backend"]["inference_cached"] = prepared[0]["backend"]["inference_cached"] and coarse["cached"]
@@ -328,7 +400,7 @@ class Engine:
328
400
  chosen = next(c for c in state["cells"] if (c["model"], c["effort"]) == (result["chosen"]["model"], result["chosen"]["effort"]))
329
401
  result["capability"]["executed"] = {k: chosen[k] for k in ("key", "classification", "position", "P_clear")}
330
402
  with storage.locked(self.config, operation="decision commit"):
331
- self._validate_state(bundle["evidence_key"], snapshot["revision"])
403
+ self._check_request(bundle)
332
404
  result["decision_id"] = decisions.save(self.config, result)
333
405
  return result
334
406