Skip to content

Commit bd8e43b

Browse files
authored
Merge pull request #356 from AreevAI/fix/ci-green-followups
CI green on main: broker releases its lent store on drop; Windows decide test budget; doc follow-ups
2 parents e5255e8 + bc338a6 commit bd8e43b

17 files changed

Lines changed: 111 additions & 29 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
120120
least-privilege role granted on both schemas (and refused once revoked on
121121
either), and the layout-mismatch refusals.
122122

123+
### Fixed
124+
125+
- **The egress broker gives back the memory it was lent when it is dropped,
126+
not when its thread exits.** `Broker::drop` signals its detached accept
127+
thread and returns; the thread noticed the flag on its next 5 ms poll and
128+
only then dropped its clone of the store bound by `bind_artifact_store`.
129+
An embedded memory's file lock is process-wide and lives as long as any
130+
handle does, so a host that closed its handle and immediately handed the
131+
file to another process — the Node binding's `close()` followed by a CLI
132+
run on the same file — could find it still locked (`STO-E001`, "locked by
133+
another process"), which is how the binding's egress parity test failed on
134+
a slow macOS runner. The drop now takes the store out of the shared slot
135+
itself; an upload in flight keeps its own clone until it lands. Pinned by
136+
`dropping_the_broker_releases_the_bound_store_synchronously`.
137+
123138
## [1.9.5] — 2026-09-24
124139

125140
### Fixed

‎crates/areev-bench/src/selfimprove/memory.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ impl Memory {
609609
/// ledger rows this pass added and the hashes it applied.
610610
///
611611
/// The review policy of the PUBLISHED runs: LLM findings stay advisory
612-
/// (`llm_lessons = false`). The `loop+LLM` arm opts in via [`learn_with`].
612+
/// (`llm_lessons = false`). The `loop+LLM` arm opts in via [`Memory::learn_with`].
613613
///
614614
/// `triggering_actor` stays `None` deliberately: with it set, LLM-origin
615615
/// recommendations would carry a co-creator, and this bench's review is
@@ -635,7 +635,7 @@ impl Memory {
635635
self.learn_with(llm, ground, LearnConfig::default(), now_ms)
636636
}
637637

638-
/// [`learn`] with pre-built loop backends and an explicit [`LessonArms`]
638+
/// [`Memory::learn`] with pre-built loop backends and an explicit [`LessonArms`]
639639
/// — which lesson ORIGINS this run may apply. The analyzers always run;
640640
/// only the review gate changes, so the 2x2 (analyzer on/off x llm
641641
/// on/off) varies one thing per axis. Advisory `Proposal::Data` findings

‎crates/areev-bench/src/selfimprove/mod.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@
6666
//! Lessons enter the prompt as a system-prompt section assembled from LIVE
6767
//! memory by `memory::lessons_markdown` — never from a harness flag:
6868
//!
69-
//! ## LESSONS (from prior experience)
70-
//! - <rendered lesson>
69+
//! ```text
70+
//! ## LESSONS (from prior experience)
71+
//! - <rendered lesson>
72+
//! ```
7173
//!
7274
//! The mock agent keys its "learned" behaviors on the error codes appearing
7375
//! anywhere in that section, which is exactly how a rendered tool-failure

‎crates/areev-cal/src/areev_facade.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ impl AreevFacade {
421421
/// journal writes to a run's triggering principal — or a second approver
422422
/// answering a HITL ask while the run's own writes continue — needs
423423
/// concurrent per-principal rights, which a shared slot cannot express
424-
/// without racing. A session resolves its fail-closed [`AuthzSet`] ONCE
424+
/// without racing. A session resolves its fail-closed [`AuthzSet`](areev_core::authz::AuthzSet) ONCE
425425
/// here (grants written later need a new session, same rule as rebind)
426426
/// and never touches the shared slot; any number of sessions run
427427
/// concurrently over the same store handle.
@@ -461,7 +461,7 @@ impl AreevFacade {
461461
/// outlive the facade it authorizes against.
462462
///
463463
/// Takes a RESTRICTED set only in practice: `resolve_rights` never returns
464-
/// an owner set, and handing this an [`AuthzSet::owner`] would silently
464+
/// an owner set, and handing this an [`AuthzSet::owner`](areev_core::authz::AuthzSet::owner) would silently
465465
/// promote a caller to the implicit superuser. It is not refused here
466466
/// because an owner-equivalent host legitimately builds one, but a host
467467
/// that accepts a principal name from a request must go through
@@ -1555,7 +1555,7 @@ impl PrincipalSession<'_> {
15551555
}
15561556

15571557
/// The attributed twin of [`AreevFacade::record_tool_call`] — one
1558-
/// field-builder ([`build_tool_call_fields`]), two authorization roots.
1558+
/// field-builder (`build_tool_call_fields`), two authorization roots.
15591559
#[allow(clippy::too_many_arguments)]
15601560
pub fn record_tool_call(
15611561
&self,

‎crates/areev-cal/src/executor.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7542,7 +7542,7 @@ pub fn grain_matches_condition(
75427542
/// by conditions after pipeline stages like SELECT have been applied.
75437543
///
75447544
/// **Totality is preserved and UNKNOWN never escapes**: internally the walk
7545-
/// is three-valued ([`grain_condition_truth`]), but a leaf whose field the
7545+
/// is three-valued (`grain_condition_truth`), but a leaf whose field the
75467546
/// grain does not carry resolves to UNKNOWN and UNKNOWN does not match. See
75477547
/// that function for why the negations need it.
75487548
pub fn grain_matches_condition_tree(grain: &CalGrainResult, condition: &Condition) -> bool {

‎crates/areev-cli/tests/decide_smoke.rs‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,24 +400,34 @@ fn decide_cmd_answers_every_shorthand_and_is_the_last_chain_entry() {
400400
let script = dir.path().join("decider.py");
401401
std::fs::write(&script, DECIDER_PY).unwrap();
402402
let cmd = format!("{py} {}", script.display());
403+
// What this test measures is the ANSWERS, not the interpreter's start-up
404+
// time: under the default 2 s decision deadline a cold Python on a shared
405+
// Windows runner was killed before it printed anything (DEC-E004), and
406+
// the failure read as a backend bug. The default's tightness is pinned by
407+
// the deadline tests above; here the budget is generous on purpose.
408+
const SLOW_RUNNER_MS: &str = "30000";
403409

404-
let (ok, out, err) = areev(&home, &["decide", "--decide-cmd", &cmd, "--state", "x", "--noul", "is it?"], &[]);
410+
let (ok, out, err) = areev(
411+
&home,
412+
&["decide", "--decide-cmd", &cmd, "--decide-timeout-ms", SLOW_RUNNER_MS, "--state", "x", "--noul", "is it?"],
413+
&[],
414+
);
405415
assert!(ok, "{err}");
406416
assert_provenance(&out, "cmd", true);
407417
assert_eq!(out["model"], "toy-decider");
408418
assert!((out["answers"]["q"]["noul"].as_f64().unwrap() - 0.25).abs() < 1e-6, "{out}");
409419

410420
let (ok, out, err) = areev(
411421
&home,
412-
&["decide", "--decide-cmd", &cmd, "--state", "x", "--choice", "pick", "--option", "a=first", "--option", "b=second"],
422+
&["decide", "--decide-cmd", &cmd, "--decide-timeout-ms", SLOW_RUNNER_MS, "--state", "x", "--choice", "pick", "--option", "a=first", "--option", "b=second"],
413423
&[],
414424
);
415425
assert!(ok, "{err}");
416426
assert_eq!(out["answers"]["q"]["choice"], "b", "{out}");
417427

418428
let (ok, out, err) = areev(
419429
&home,
420-
&["decide", "--decide-cmd", &cmd, "--state", "x", "--score", "how much", "--level", "low", "--level", "high"],
430+
&["decide", "--decide-cmd", &cmd, "--decide-timeout-ms", SLOW_RUNNER_MS, "--state", "x", "--score", "how much", "--level", "low", "--level", "high"],
421431
&[],
422432
);
423433
assert!(ok, "{err}");
@@ -428,7 +438,7 @@ fn decide_cmd_answers_every_shorthand_and_is_the_last_chain_entry() {
428438
let (ok, out, err) = areev(
429439
&home,
430440
&["decide", "--decide", &spec(&down), "--state", "x", "--noul", "is it?"],
431-
&[("AREEV_DECIDE_CMD", &cmd)],
441+
&[("AREEV_DECIDE_CMD", &cmd), ("AREEV_DECIDE_TIMEOUT_MS", SLOW_RUNNER_MS)],
432442
);
433443
assert!(ok, "{err}");
434444
assert_eq!(down.requests().len(), 1);

‎crates/areev-conformance/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl Drop for PgBackend {
256256
/// anywhere else does not compile. Each runner passes its own
257257
/// test-generating macro:
258258
///
259-
/// ```ignore
259+
/// ```text
260260
/// macro_rules! my_case { ($name:ident) => { #[test] fn $name() { … } }; }
261261
/// areev_conformance::for_each_conformance_case!(my_case);
262262
/// ```

‎crates/areev-js/src/lib.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,10 @@ impl Areev {
10561056
//
10571057
// A postgres://…?schema=<name> DSN selects the server-tier backend —
10581058
// same API, the memory lives in a Postgres schema (stateless-host
1059-
// deployments; multiple concurrent writers per memory). The page
1060-
// cipher is file-backend-only, so a passphrase with a DSN is an error.
1059+
// deployments; multiple concurrent writers per memory); adding
1060+
// `&meta_schema=<name>` selects the paired layout (#353), which the
1061+
// store reads off the URL itself. The page cipher is
1062+
// file-backend-only, so a passphrase with a DSN is an error.
10611063
// `index_text` follows the CLI's `--index-text` and Python's
10621064
// `index_text=`: left unset, the file's own declaration wins; passed
10631065
// explicitly it is a deliberate re-stamp, reported via

‎crates/areev-py/src/lib.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ fn status_from_str(s: &str) -> Option<RecStatus> {
150150

151151
/// Open on the server-tier postgres backend from a
152152
/// `postgres://…?schema=<name>` DSN, mirroring the file branches (explicit
153-
/// `index_text` re-stamps; telemetry rides the memory's schema). A
153+
/// `index_text` re-stamps; telemetry rides the memory's schema — or, with
154+
/// `&meta_schema=<name>` on the DSN, the paired layout's metadata schema,
155+
/// #353; the store reads that off the URL, so nothing here changes). A
154156
/// passphrase never applies here — the page cipher and `.kdf` sidecar are
155157
/// file-backend capabilities.
156158
#[cfg(feature = "postgres")]

‎crates/areev-run/src/broker.rs‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub enum CredentialSource {
223223
ttl: std::time::Duration,
224224
/// Variables passed through to the resolver, and ONLY to it — the
225225
/// resolver's own auth (`VAULT_TOKEN`, `AWS_PROFILE`, …). See
226-
/// [`CredentialSource::spawn_policy`] for why this list exists at all.
226+
/// `CredentialSource::spawn_policy` for why this list exists at all.
227227
pass_env: Vec<String>,
228228
},
229229
/// Read from HashiCorp Vault or OpenBao's KV API over its HTTP interface.
@@ -1150,6 +1150,20 @@ impl Drop for Broker {
11501150
// exits at the next loop check, so the port is released promptly
11511151
// without anyone waiting for it.
11521152
self.stop.store(true, Ordering::Relaxed);
1153+
// The store lent by `bind_artifact_store` is given back HERE, not
1154+
// whenever the detached thread gets around to exiting (its accept
1155+
// loop polls the stop flag every 5 ms). An embedded memory's file
1156+
// lock is process-wide and lives as long as any handle does, so a
1157+
// host that closed its handle and immediately handed the file to
1158+
// another process — the Node binding's `close()` followed by a CLI
1159+
// run against the same file — found it still locked by the clone
1160+
// this thread was holding. `serve_one` clones the store out of the
1161+
// slot for the length of one upload, so an in-flight artifact keeps
1162+
// its own reference until it lands; taking the slot never blocks on
1163+
// it and never cuts it short.
1164+
if let Ok(mut slot) = self.artifact_store.lock() {
1165+
slot.take();
1166+
}
11531167
drop(self.handle.take());
11541168
}
11551169
}
@@ -3012,6 +3026,29 @@ mod tests {
30123026
(dir, store)
30133027
}
30143028

3029+
/// Dropping the broker gives back the store it was lent the moment
3030+
/// `drop` returns — not when its detached accept thread next polls the
3031+
/// stop flag. An embedded memory's file lock is process-wide and lives
3032+
/// as long as any handle does, so the few milliseconds the thread used to
3033+
/// keep its clone alive were exactly long enough for a host that closed
3034+
/// its handle and immediately handed the file to another process (the
3035+
/// Node binding's egress parity test, `close()` then a CLI run) to find
3036+
/// it still locked. No sleep and no join here: the count must be back to
3037+
/// one synchronously.
3038+
#[test]
3039+
fn dropping_the_broker_releases_the_bound_store_synchronously() {
3040+
let (_dir, store) = kept_store();
3041+
let broker = Broker::start(policy(&["http://127.0.0.1:1"]), BTreeMap::new(), grants(&[]), "RUN-E022").unwrap();
3042+
broker.bind_artifact_store(Arc::clone(&store));
3043+
assert_eq!(Arc::strong_count(&store), 2, "the broker holds the store while it serves");
3044+
drop(broker);
3045+
assert_eq!(
3046+
Arc::strong_count(&store),
3047+
1,
3048+
"the store must be released by drop itself, not by the detached thread's exit"
3049+
);
3050+
}
3051+
30153052
/// An upstream that reads one request (headers + Content-Length body),
30163053
/// hands the stream to `answer`, and returns the body it received.
30173054
fn upstream<F>(answer: F) -> (String, std::thread::JoinHandle<Vec<u8>>)

0 commit comments

Comments
 (0)