Repository navigation
fix(memory): resolve MOI workspace authority and bound turn observation - #1212
loveRhythm1990 wants to merge 63 commits into
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
The MOI bridge needs a clear memory authorization contract and protection against slow or oversized identity responses before rollout. The companion MOI action and end-to-end acceptance are also outstanding.
72d5702 to
71608f2
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
The explicit access decision, response size bounds, and reusable client address the three previous inline comments, but the requested MOI memory journey is still not ready to merge. The companion authority contract is not implemented on the current MOI side, HMAC-owned sessions cannot reach finalization as documented, and the observer can drop work under both transient latency and concurrent load. The user-facing error paths also need to preserve useful, correct information.
Validation: the four memory_identity_ service tests and server_loop_observer_slow_authority_releases_all_slots_for_other_users passed. A review-only test against the real scheduler held the first four workers and dispatched a 1,000-session burst: 4 scheduled and 996 dropped; this is a controlled burst, not a production throughput benchmark. The real MOI → Astra → Memoria journey, account/workspace policy, and automatic prompt recall remain unverified. The PR's MOI fixture calls the new resolver directly rather than exercising that product journey. No CI reruns were requested.
| ) -> Result<ExternalMemoryIdentity, (StatusCode, Json<ErrorResponse>)> { | ||
| self.post_action_with_limits( | ||
| provider, | ||
| "resolve_memory_identity", |
There was a problem hiding this comment.
[P1] Implement and validate the companion MOI action before treating this as the fix. The configured MOI external-provider endpoint is the external-catalog handler, but current matrixflow dev requires provider_scope_id and only handles the two catalog actions. This request supplies neither a scope nor an implemented action, so the real callback returns 400 and MOI memory remains unavailable even when all Astra settings are present. The fixture invents the response and cannot establish the identity/permission contract. Complete the trusted MOI policy and mapping, resolve the account-versus-workspace scope, and exercise both sides through a real MOI → Astra → Memoria flow before merge; until then this PR's own stated acceptance gate remains open.
There was a problem hiding this comment.
Agreed: the current MOI handler cannot satisfy this action, and the identity-only prototype is not a delivered permission contract. This remains an explicit merge/deployment blocker. I am not deriving read/write permission from an active account or chat permission. The trusted permission source and account-versus-workspace scope need confirmation before completing the companion implementation. The PR description now separates this outstanding work and real MOI → Astra → Memoria acceptance from Astra's wire-fixture tests. The independent Astra fixes are in f13d5ca and 2ca3a62; I am not claiming real cross-project E2E success.
There was a problem hiding this comment.
Reopened this integration gate. The user has now confirmed workspace-isolated personal memory and independent workspace IAM memory.read / memory.write grants; Astra's Session-bound contract and the MOI companion implementation are available. However, matrixorigin/matrixflow#21532 is still an unmerged draft, and the real MOI → Astra → Memoria product journey has not been accepted. Component HTTP/database tests do not establish that journey. This thread and matrixflow#20337 remain open; the latest observer fixes do not remove this merge/deployment gate.
There was a problem hiding this comment.
The MOI callback and default workspace grants have merged in matrixorigin/matrixflow#21532. On 3b2bbed the signed Session lifecycle test passed against real MatrixOne, including read-only and revoked authority, using a controlled MOI callback. The dedicated local MOI environment has no candidate Astra service wired into its product path. I am leaving this thread open for a real MOI login and default-grant, read-only and revocation checks against candidate Astra and Memoria.
71608f2 to
f13d5ca
Compare
|
Fixed the SQL-budget CI failures in 6d50e87. All three failures came from the shared obsolete async/scheduled assertion after the observer moved to durable recovery. The Router fixture now drives the production recovery path and awaits its acknowledgement SQL, then verifies the persisted receipt. The explicitly documented durability allocation is 15 SQL statements (3 enqueue + 6 claim + 6 ack); all raw statements remain counted, and the readonly-round query-growth checks remain unchanged. Local verification passed: the three previously failing real-MatrixOne integration cases, four metric-validator tests, targeted clippy with warnings denied, and formatting. Updated-head CI is pending. The separate companion MOI authorization/product-scope acceptance items remain open. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes at 6d50e87ee0b9ff76fe3a487ed644c29858d27484.
The per-turn observation design does not satisfy the requested performance/complexity constraints. Recoverability is needed, and removing the lossy four-permit scheduler addresses the original dropped-work problem. That does not justify introducing a second per-turn transcript projection and enqueue/claim/acknowledgement cycle. The new path adds 15 SQL statements per observation: three synchronous statements inside canonical terminal settlement, plus six for claim and six for acknowledgement (two additional transactions). It runs even with Memoria unconfigured: enqueue does not check configuration, the default Server composition still installs DatabaseTurnObserverWorker::new(None), and only its eventual run() returns NotConfigured. The memory journal also becomes a prerequisite for committing the chat's canonical transcript. Increasing the ordinary budget from 20 to 35 and Auto from 31 to 46 documents the regression rather than meeting the user's constraint.
The first inline finding covers that design/resource/availability problem. The second covers an independent scheduling defect: each new terminal snapshot overwrites the failed active generation's backoff with NOW(6), although the claim still retries that old generation. Ordinary continued chat can therefore bypass the declared 5–960-second backoff during an outage.
Please consume existing canonical completion/context facts asynchronously, coalesce/batch derived memory work at the existing owner, and keep disabled/unconfigured observation out of the persistence path. This should preserve bounded recovery and current authorization without restoring silent drops or adding another queue/state machine. Validate the resulting default, memory-enabled and multi-session SQL costs instead of granting every turn another fixed 15 statements.
Earlier comments and the real product journey: Explicit memory access, bounded/reused callback HTTP, signed lifecycle/retained-scope checks, safe authority categories and read-only remediation are addressed in the current source. Saturation/timeout work is now retained rather than discarded, but the replacement has the costs and retry defect above. All old threads currently show resolved; the companion-contract item is still substantively open. I rechecked current MatrixFlow dev: agent_runtime_external_catalog.go still requires provider_scope_id and only supports list_catalog_by_scope and issue_runtime_context_by_scope; this branch sends resolve_memory_identity without that scope. The PR description and author's reply still explicitly acknowledge the missing trusted permission contract, unresolved account/workspace product scope and outstanding real MOI → Astra → Memoria acceptance. The existing companion thread remains a merge blocker; a fixture response is not evidence that the product integration exists. Automatic prompt recall remains explicitly outside this PR.
Increment and test quality: Git reports +1,929/-410, net +1,519 across 18 files. Separating Rust test modules/integration fixtures gives approximately +391 production, +1,038 test and +90 documentation lines (physical lines, including comments/blanks). The cancellation test's phase gates/positive control and the authority HTTP tests exercise useful boundaries. The 1,000-session fixture exercises journal correctness with a synthetic worker, not production authority/backend latency or throughput. The backoff unit/regression checks do not enqueue a newer turn while a failed active observation is waiting, and the SQL probes now accept the additional work. Code/test volume does not establish that this runtime cost is justified. The existing journal's reuse is preferable to a separate scheduler, but the per-turn writes and duplicate full-context payload still need to be removed or reduced.
Validation and limits:
- Local
cargo test -p astra-services --lib memory_identity_: 4 passed, covering endpoint reuse, bounded/chunked/error bodies, concurrent timeouts and identity/access/status contracts. - Local observation serialization/coalescing unit test: 1 passed.
- Independently traced the actual Server composition, canonical enqueue transaction, disabled worker, managed recovery, lease/release scheduling and public signed lifecycle path. The new SQL/backoff findings are source-level reachable interleavings; I am not claiming a newly measured live database workload or fault-injection run.
- Latest-head GitHub snapshot: 37 successful checks, three skipped, one neutral. The author's isolated-DB results remain author/CI evidence; I did not rerun the 1,000-session/database/CLI/full harness suites.
- Latest main is
77ab026883ebe2249d5e0cc1e7fcf10306105a88. Its terminal-settlement changes do not supply the missing memory integration or remove these new journal writes. Findings are anchored to this PR head; no untested merge build is claimed. git diff --checkpassed; review source remains clean. No subagents, implementation edits, commits, pushes or deployment changes.
6d50e87 to
4ae0577
Compare
|
Fixed the CI compilation failure in 29e9038. Both failing lanes hit the same E0599 errors before executing tests. The support module is available under Local checks passed for all runtime lib/bin/test targets with default features and with Confirmed on the new head:
The two previously failing jobs are now green. Other workflow jobs are still running; no full-workflow completion is claimed. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes at 29e90385c89c2881d8fc0ccbbc5f58acde7a64d9 for two verified query-selectivity regressions. The prior per-turn enqueue/backoff findings are addressed; these are new problems in the replacement design.
The direction has improved: canonical completion facts now own observation input, the extra per-chat job/transcript write is gone, an unconfigured worker creates no observation owner, and the observation retry clock is independent of extraction/finalization. The old 15-statement allowance has been removed and the original statement-count bounds restored. The one-use Auto absence snapshot is scoped to the exact Run/owner generation and cleared before publication. Those changes do not establish efficient database access: the new combined queries scan across retained Sessions instead of preserving keyed access.
1. Shared canonical materialization loses its point-read predicates. In an isolated MatrixOne 4.2.8 instance with the branch's actual table DDL and 100,000 synthetic manifest rows, the new derived-key/LEFT JOIN query scans 100,000 manifest rows and filters to one. The previous direct-predicate query for the exact same key scans one row. I repeated the comparison using real PREPARE/EXECUTE parameters; the result is the same. This is in the canonical coordinator, so it affects ordinary restore/resume/history/fork consumers, not just optional memory. Keep the validated materialization owner and preserve direct, selective storage predicates; reducing query count must not turn a Session lookup into catalog-wide content reading.
2. Background discovery is unbounded even when idle. With 100,000 retained Sessions already fully observed, the exact production discovery query returns zero rows but scans 100,000 rows from each of session_context_heads, agent_sessions and agent_session_memory_work, then evaluates the cross-table JSON predicates. The timer repeats this every two seconds, resetting the local cursor after no candidate. With only one pending Session and 100,000 manifest nodes, the query also scans all 100,000 manifest rows. LIMIT 1 bounds output, not work. Use bounded/indexable canonical-progress discovery and selected-Session materialization rather than repeatedly joining/filtering the whole retained catalog. The Session-scoped SQL-count fixture does not establish this production behavior.
The original MOI companion/permission/product-scope blocker remains open and explicitly acknowledged in the PR. This review does not convert wire fixtures into real MOI → Astra → Memoria acceptance or automatic recall. Its source contract is unchanged from the prior review; I have not duplicated that existing thread.
Complexity and validation:
- Git reports +2,655/-477, net +2,178 across 23 files. Separating test modules, test-only hooks and integration fixtures gives approximately +773 production, +1,309 tests, +96 documentation lines, including comments/blanks. The recovery/backoff/disabled-path tests have value, but neither added test volume nor restored statement counts excuse the measured scans. The shared decoder correctly reuses canonical hash/fork validation; that reuse should be retained while correcting access paths.
- Local
cargo test -p astra-services --lib memory_identity_: 4 passed on this head. - Real isolated-DB query-plan probes used the actual schema and exact source query shapes, plus prepared old/new materialization comparisons. Idle discovery returned zero rows at 1,000/10,000/100,000 Sessions; observed CLI round trips were about 12/26/160 ms. Those timings include CLI overhead and are synthetic lower-bound workload evidence, not production latency/throughput claims. Plan row counts are the basis of the findings. The fixtures contain metadata/dummy content and do not claim end-to-end canonical decoding or Memoria persistence validation.
- The serial global observation owner is bounded, but the 1,000-Session synthetic-worker test does not establish throughput under real MOI/UC/observe latency or horizontal scaling. Validate that separately after fixing query selectivity; no additional inline finding is asserted without a defined workload/SLO.
- Latest CI snapshot: 38 successful, three skipped, one neutral. I did not rerun the full database/CLI/runtime/harness suites or claim an independent full-workflow execution.
- Base and latest main are both
77ab026883ebe2249d5e0cc1e7fcf10306105a88.git diff --checkpassed and the review source remains clean. No subagents or implementation edits were used. The task-owned temporary MatrixOne was stopped/removed; query/schema/EXPLAIN evidence is retained outside Git.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of a496c93d88e034e8531d9d6362cc70de356790c1 against base 77ab026883ebe2249d5e0cc1e7fcf10306105a88, also checking main 027c84629. Direct review, no subagents or source edits. Request changes: one existing P1 integration blocker remains, plus one P2 observation-selectivity gap detailed inline.
- P1, existing thread: the MOI permission contract and real product journey remain undelivered, as already acknowledged in the original thread. I refreshed matrixflow dev to
63f8a9ccdf8b05a3233ecab6da9251a8d45c1ac7: the configured external-catalog handler still requires provider_scope_id and handles only the two catalog actions. Astra's new action supplies external_subject and is not implemented there. Account/workspace scope and real MOI → Astra → Memoria write/recall/isolation acceptance are still open. I am retaining the existing thread rather than duplicating it; wire fixtures do not establish delivery. - P2, current code: selected-Session observation still scans all retained compaction generations. Prepared plans show 100,000 input rows versus the canonical loader's 1,000 for the same current head. Correct row output and a lower statement count do not make that access path selective.
Earlier findings: the per-chat job/transcript write and enqueue-time backoff reset remain removed. Unconfigured observation stays out of settlement. The latest direct-key canonical loader and pre-paged eligibility fix the previously demonstrated cross-Session payload scans; the new 100,000-Session plan regression passed locally. The new finding concerns retained versions inside the chosen Session, not a claim that the old whole-catalog payload join remains unchanged. All 13 existing threads were fetched; the original external-contract thread remains open.
Design and increment: 23 files, +3029/-477, net +2552, split approximately into implementation +899, tests +1531, docs +122. The shared credential resolver, explicit grants, bounded callbacks, canonical completion input, independent retry clock and reuse of canonical hash/fork decoding have concrete value. There is no new table or per-turn observation enqueue, but background observation adds catalog traversal/attempt/checkpoint work: two queries per 64-key page, then selective attempts, authority checks and checkpoints. This cost must stay separate from the scoped 20/31 SQL budgets. Reusing decoding while maintaining a second payload query has already allowed its generation bounds to diverge; consolidate that ownership. Current main merges cleanly via a non-mutating merge-tree check; the merged tree was not built.
Tests are useful real-boundary checks, but the plan matrix needs both catalog breadth and retained-history depth. I do not reject the change solely for test growth, and I do not infer multi-server throughput from a synthetic serial worker. Remaining narrow-key sorting/catalog cost, global serial observation and real authority/backend latency still need workload evidence before a capacity claim.
Independent current-head validation: 7 targeted tests passed: the 100,000-Session real-schema prepared-plan test; four identity/grant/timeout/body-bound HTTP tests; the 1,000-Session cancellation/restart/fairness test; and new-turn/backoff preservation. Integration fixtures used explicit ephemeral test secrets and isolated catalogs, without insecure-default bypass or real credentials. Extra prepared current-generation comparisons used a separate synthetic database and the exact source query templates. These plans prove storage input rows, not application hash/lineage validity of the synthetic bodies. The task-owned MatrixOne 4.2.8 container is stopped/removed; source is clean and git diff --check passes. No live MOI/Memoria acceptance, paid model harness, full budget matrix rerun or production throughput benchmark is claimed.
CI: 37 successful, three skipped, one neutral, one failed. The failure is Check PR title → Validate capability assessment (PR-body first-line format), not a runtime/test failure. The current first line passes that rule locally, but a fresh successful remote check is not present. This remains a required-check status issue, separately from the two findings.
a496c93 to
92bf5fc
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
The existing MOI integration blocker remains open: the current matrixorigin/matrixflow dev handler at bb6aa3f5 still requires provider_scope_id and only implements the two catalog actions, not resolve_memory_identity. Product authorization/scope and real MOI → Astra → Memoria acceptance are also still outstanding (existing thread). The other historical threads are marked resolved, but the following new counterexamples show that bounded discovery, scalable recovery, and reliable checkpointing are not yet established.
I exercised the exact prepared key-page SQL against the production session_context_heads schema with 100,000 synthetic heads on an isolated MatrixOne v4.2.6 database: the first, middle, and last pages each scanned 100,000 input rows while returning 64. I also exercised the exact checkpoint SQL for an expired lease and a stale revision: both statements succeeded without persisting the proposed checkpoint. The temporary databases were deleted. The scheduling numbers below are derived from the production loop, not a claimed benchmark. No live MOI cross-project acceptance was run.
The current 1,000-Session regression manually calls drive_one with an immediate fake observer, so it validates eventual traversal but bypasses the real 2-second/16-step cadence and a slow provider. The 100,000-Session plan regression checks eligibility and payload operators but does not assert the key-page storage input. These omissions explain why the observed defects can coexist with passing CI.
The full diff is +3,173/-481; the three dedicated runtime test files add 800/remove 62 lines, and documentation adds 152/removes 16 lines, with additional tests embedded in source. The move to canonical materialization removes a duplicate payload loader, but the global poller, checkpoint path and tests need to demonstrate that their added cost and state give scalable, recoverable behavior. Please consolidate ownership where possible rather than adding another parallel queue or status machine. Current CI reports 37 successful checks, 3 skipped and 1 neutral; those results do not close the MOI integration gate.
|
Review follow-up and retrospective The five findings in the latest review were valid. The previous head passed Test Suite and Static Checks, but that did not validate the missing scenarios. My earlier validation was too local:
This follow-up checks the whole sequence: physical discovery plans, early admission, canonical captured-head loading, fresh dispatch authority, exact durable receipts, lease expiry/revision conflicts, managed multi-owner scheduling, and no-database terminal/cleanup/cancellation. During validation, the physical-key change exposed an eligibility-plan regression; that query now also has physical interval bounds rather than a relaxed scan threshold. The PR still has explicit merge/deployment gates: the trusted MOI permission callback and product scope decision, real MOI → Astra → Memoria acceptance, and the v122 database cutover/migration plan. These are not satisfied by Astra fixtures or green CI. Fixes are pushed in 6844698. Local validation passed 34 targeted tests, runtime/services clippy, default-feature runtime test-target compilation, formatting and repository metadata validation. The managed scheduler regression was rerun after the final shared sweep-cooldown change and passed. OCR delegate review covered all 28 changed files without skips. Updated-head CI is pending; the five implementation threads are addressed, while the companion MOI blocker remains open. |
|
Fixed the CI schema-contract failure in 0cef0e7. The online core-services shard ran 497 tests: 496 passed and only The follow-up asserts both contracts independently: Validation: all 10 tests in This was my omission in the preceding schema change: I ran the bootstrap/catalog regression but missed the separate phase-1 contract assertion. The whole schema integration target has now been checked. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes. The MOI identity mapping belongs in the existing authority resolver, but the actual companion callback and permission/scope contract are still missing: the existing unresolved MOI integration thread remains a merge blocker. The design document currently describes account-wide cross-workspace memory as established even though the PR lists that product decision as pending; resolve that decision and validate the real MOI → Astra → Memoria flow.
The new observation recovery also needs a simpler deployment-wide cost model and fair progress between Sessions, as detailed inline. The raw chat SQL budget exercises a scoped testing route and must not be presented as accounting for the production catalog sweeper. The 1,000-Session probe uses one synthetic owner and two in-process Server owners; it does not establish the requested distributed multi-user capacity or idle SQL budget.
Independent validation at this head: on an isolated MatrixOne, deleting 4,096 of 4,097 allocated heads left one row and AUTO_INCREMENT=4,098. A separate production-scheduler probe held sequence 1, confirmed sequence 2,048 in a different shard completed, and found sequence 2,049 in the held shard still pending after 8 seconds; it completed after releasing sequence 1. SQL totals in the inline comment are calculated from the production queries, not a distributed throughput benchmark. The temporary test database was removed.
Diff: +4,055/-482 across 29 files. Approximately +1,410/-215 implementation (including test helpers outside test modules), +2,440/-251 tests, and +205/-16 documentation. The extra tests include useful boundaries, but their volume does not replace production-scheduler cost and fairness coverage. Current main is bebb535ce, and current-head CI reports success for its executed checks; neither proves the missing real MOI integration.
Adapt the phase-gated deadline test from b18994f in PR matrixorigin#1212 and cover settlement and timeout races without relying on short wall-clock intervals.
* perf(edge): remove per-connection dispatch polling * fix(edge): settle unsent dispatches without requeue * fix(edge): recover dispatch and observation failures * fix(edge): isolate dispatch recovery and preserve delivery outcomes * test(cli): stabilize cancellation deadline coverage Adapt the phase-gated deadline test from b18994f in PR #1212 and cover settlement and timeout races without relying on short wall-clock intervals.
0cef0e7 to
4cb2d6d
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
The existing MOI integration blocker is still open: matrixflow dev 48f5f26e64c96617dd59eb35f4b5933857a38d10 requires provider_scope_id and implements neither this action nor its permission contract. Wire fixtures cannot establish the real MOI → Astra → Memoria behavior.
The current recovery path also re-reads and resends a growing context, and the SQL regression gate has been relaxed; see the inline findings. The 1,000-session fixture is useful for fairness and recovery, but its sessions each have one turn and it does not establish the database/byte cost of long-running sessions. Please validate both server-only and distributed CLI/Edge sessions with long histories and the actual production owner, as well as the companion MOI contract.
The direct-key materialization and bounded due-index changes do address the earlier catalog-scan findings. The remaining concerns above prevent approval.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed cc01114 against its base and current main. The existing findings on the MOI/Edge memory proxy, cross-Run confirmation context, new reserved Session metadata, and default Memoria image remain unresolved. There is also a newly identified scalability regression inline.
Scope clarification for the Session access thread: generic cross-workspace Session reads/deletes predate this PR and are not an independent blocker here. The new workspace-memory integration does, however, make the existing unchecked PUT /sessions/{id} with status=closed able to enqueue A-scoped memory maintenance using a same-subject workspace B Edge token: the recovery path resolves the retained A Session and its current grant without checking the requesting token's workspace. Please close that newly enabled memory-control path through the existing Session authority owner. This is a traced production path, not a claimed live-MOI exploit reproduction.
Validation: the existing Static Checks and Test Suite passed for this head against base ab4d448; main has advanced since that run. A local three-way merge with current main 1efbd43 produced no textual conflicts and passed diff whitespace checks, but I did not compile the resulting tree. I re-ran the previously built 57 memory gateway tests successfully. The cache measurements in the inline comment use a standalone Rust reproduction of the same HashMap/Weak retention loop, not a production throughput test. Real MOI-to-Astra-to-Memoria acceptance remains unverified and is not a standalone blocker merely for lack of a test.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed ff099f01 against main@dba2582a. The three-way merge has no textual conflicts, but the merged runtime fails to compile. Two P2 findings cover the extra session read and confirmation context. The existing default-deployment issue also remains open. The pinned Memoria 0.5.2 image lacks the new observe routes, even though the candidate service has been validated. Default-backend thread
| session_id, | ||
| Some(owner), | ||
| Some(&state.fernet_encryptor), | ||
| astra_services::session_fork_coordinator::ProviderSessionScopeRequirement::ForkSource, |
There was a problem hiding this comment.
[P1] Use the scope variant that exists on main
main renamed ForkSource to BoundConversation. Git merges this new call without a textual conflict, but cargo check reports E0599 for this reference in the merged runtime. Replacing the variant in the isolated merge tree of main@dba2582a and this head passes cargo check -p astra-runtime --lib.
| // Exact ownership is checked for every mechanism, before provider scope. | ||
| state | ||
| .session_service | ||
| .get_session(session_id.to_owned(), user.user_id.clone()) |
There was a problem hiding this comment.
[P2] Reuse the session row on close
The database-backed close route now fetches this session, then update_session immediately reads the same owner/session row again. The signed path also reads the row when checking retained scope. Use the existing lifecycle read and validate scope there before updating the session. That keeps the ownership check on the canonical path and avoids an extra database round trip.
| let Some(question) = prior_assistant["content"].as_str().map(str::trim) else { | ||
| return Ok(None); | ||
| }; | ||
| if prior_assistant["role"] != "assistant" || !question.ends_with(['?', '?']) { |
There was a problem hiding this comment.
[P2] Keep confirmation context when the question is followed by instructions
I ran the production request builder and the baseline filter with the same four public messages. With “Use Go instead?” the latest head emits the full exchange. With “Use Go instead?” followed by “Reply yes or no.” it emits only “Yes.” and “Okay.”, while main retains the referent in both cases. The adjacent exchange already fits the byte budget. Use the existing bounded public-message checks for that exchange and let the extractor interpret the reply. Prior confirmation thread
XuPeng-SH
left a comment
There was a problem hiding this comment.
Incremental review of 1c1ce122 against main@5268e8e3. The Session close path reuses its authority lookup, the scoped cache removes its own weak entry on drop, the proxy validates the MOI Session binding, and the response filters all reserved scope keys. The deployment defaults now pin Memoria 0.5.3. The observation regression below still blocks this head.
I compiled and compared the current and main observer request builders using the same public messages and synthetic tool outputs. Both retain the explicit next user message after a memory-tool turn. Only main retains it after an ordinary tool turn or a prior answer that exceeds the extraction window. The new adjacent confirmation case with a trailing instruction passes. The merge tree is clean and CI, including the MOI gate, passed.
The owner-only access in the existing Session list/read routes also exists on main, so I am recording it as a separate baseline concern.
| let mut exchange_bytes = "[user]: \n[assistant]: \n".len() + content.len() + answer.len(); | ||
| if applied.is_empty() | ||
| && let Some((opening, reply)) = | ||
| observer_preceding_exchange(state, session_id, user_message).ok()? |
There was a problem hiding this comment.
[P2] Keep standalone current input eligible when the previous exchange is unusable
observer_preceding_exchange(...).ok()? drops the whole observation when the preceding assistant reply follows an ordinary tool result. The special case above fixes this only for the memory tool. The size branch below has the same effect when a long preceding answer cannot fit the 6 KB exchange budget. I reproduced both with a fresh, independently meaningful user preference in the next Run. Main sends the current user turn; this code sends no observation.
Keep the current turn eligible when it supplies independent evidence. Preserve the bounded context requirement for dependent confirmations, and keep tool results and rewritten context outside the extraction request. Cover an ordinary tool and a long preceding answer alongside the existing memory and confirmation cases.
XuPeng-SH
left a comment
There was a problem hiding this comment.
The new observer fallback keeps independently meaningful input eligible when prior evidence is unusable. The remaining blocker is the SQL added to ordinary MOI Edge chat admission. I compared the shared scope helper with main@ae8615a7 and traced an existing-Session, fresh-Run request through both HTTP admission and Run insertion. The prior scope helper bypassed its lookup for legacy MOI bearer identities. Both callers now execute a Session/fork query, including for ordinary Edge Sessions without a memory binding.
Please reuse the existing Session admission data for the scope check and keep fresh IAM validation at the actual memory operation. Cover the normal legacy Edge chat path with memory disabled or no memory tool call in the SQL-budget test. The new memory status and finalize routes also read the same Session twice during authorization, as noted inline.
|
|
||
| fn provider_session_namespace(user_id: &str) -> bool { | ||
| user_id.starts_with("provider_authorized:") | ||
| user_id.starts_with("provider_authorized:") || user_id.starts_with("external_authorized:moi:") |
There was a problem hiding this comment.
[P2] Keep legacy MOI chat admission within its existing SQL budget. Adding external_authorized:moi: to this predicate and moving the old fast return after the query makes an ordinary legacy chat in an existing Session pay for this same Session/fork lookup at HTTP preflight and again inside the Run insertion transaction. On main, both calls return before SQL. This happens before memory execution and even on a legacy Session with no memory scope proof. Reuse the Session read already owned by admission and validate any retained scope there.
| // Exact ownership is checked for every mechanism, before provider scope. | ||
| state | ||
| .session_service | ||
| .get_session(session_id.to_owned(), user.user_id.clone()) |
There was a problem hiding this comment.
[P2] Reuse the Session ownership read on memory status and finalize. For provider-scoped requests get_session fetches the owner/Session row, then the scope helper immediately reads the same row again. The close flow already uses one lookup for ownership and scope. Use the same approach here while preserving the error contract for a missing or out-of-scope Session.
XuPeng-SH
left a comment
There was a problem hiding this comment.
The existing-session fresh root Run now checks workspace scope through the two Session reads it already owns. Memory status and finalize also combine ownership and scope in one lookup. I traced the same calls on main@1f112444 and on this head. Two legacy MOI paths still add standalone Session/fork SQL, as detailed inline. The new MatrixOne fixture exercises a fresh ordinary root Run, so it misses both paths.
Reuse the locked Session facts for child/retry admission and the exact request-owned Session proof for a replay of that same Session. Preserve scope validation for the durable Session on other replay paths and fresh IAM checks at the memory boundary. Please cover child admission and same-Session task_ref replay in the existing SQL-budget fixture.
The three-way merge is clean and the MOI compatibility check passed. The live harness failure is at model-load (model_probe_timeout), before the scenarios ran.
…61109 # Conflicts: # crates/runtime/src/server/session/session_handlers.rs
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed 8c4bd56c against main@3959117b. The settled Run is the right owner for optional observation. This version removes the observation scheduler and its schema, reuses locked Session facts for child and retry admission, and reuses the verified identity for an exact same-Session replay. The scope proof and the fresh workspace grant serve distinct purposes.
Four remaining cases are inline. Preserve an adjacent confirmation through Memoria's raw fallback, keep accepted correction receipts intact through the Edge proxy, reuse the Session binding during finalize admission, and restore the pre-mutation snapshot contract for the newly enabled MOI Edge tools.
The GitHub checks are green on this head. Formatting and diff checks passed locally, along with 25 targeted runtime tests. I exercised the current receipt function with the same body and HTTP 202 and 200, which returned accepted and completed respectively. The three-way merge with current main conflicts in deployment/all-in-one/.env.example. Reconcile the Astra and Memoria image pins and run the all-in-one smoke against that combination. The MOI callback and default policy merged, and the controlled callback covers scoped behavior. The real MOI → candidate Astra → Memoria acceptance for default grants, read-only and revocation remains open. MOI default grant changes Acceptance thread
The earlier close and memory-status SQL issues are addressed. The finalize denial test now demonstrates one scope read, while the admitted path still has a second binding lookup. The adjacent-question and standalone-delivery cases have coverage at the request boundary. The missing extraction fallback case is about the stored result. The newly introduced PUT status=closed effect now checks scope, and the broader legacy Session access remains tracked separately. Session access thread
| evidence_bytes += "[user]: \n[assistant]: \n".len() + opening.len() + reply.len(); | ||
| if evidence_bytes <= OBSERVER_EXCHANGE_BYTES { | ||
| messages.push(message("user", opening.to_owned())); | ||
| messages.push(message("assistant", reply.to_owned())); |
There was a problem hiding this comment.
[P2] Keep a cross-Run confirmation and its referent together through raw fallback
This appends the prior question and the current reply as separate messages. Memoria 0.5.3's Recent and Complete modes both fall back to one semantic memory per message when the extractor is unavailable or fails. A two-Run exchange such as “Use Go for schema migrations?” followed by “Yes.” can therefore persist “Yes.” as a standalone verified memory, with the original question in a separate record. The current test checks the request, so it passes even when the persisted result loses the relationship.
Reuse the same bounded dialogue representation already used for guided input, or require extraction when observations carry contextual evidence. Please cover a two-Run exchange and assert the stored memories with extraction disabled or failing. This projection can stay downstream of model input and requires no new state. Memoria fallback implementation
| ); | ||
| map_memoria_forward_error(MemoriaForwardError::Backend(error)) | ||
| })?; | ||
| if let Some(args) = receipt_args.as_ref() { |
There was a problem hiding this comment.
[P2] Preserve a pending correction receipt through the Server proxy
Only the WriteOnly branch uses the captured upstream status. On a ReadWrite scoped request, an upstream 202 {"memory_id":"pending-correction"} returns Json(response), which makes the proxy reply HTTP 200. The Edge tool then projects that body as completed. An empty 202 becomes a missing-receipt error. The direct path has regression tests for both response shapes and correctly returns accepted.
The Server boundary should preserve the pending outcome through the existing receipt projection or the HTTP status. Add a proxy-path fixture that asserts what the Edge tool receives with read/write authority. An accepted update must stay distinguishable from a completed one.
| user.user_id.clone(), | ||
| ); | ||
| ) | ||
| .with_session(&session_id); |
There was a problem hiding this comment.
[P2] Resolve the finalize Session binding once and admit the requested operation
An admitted MOI finalize first runs authorize_existing_provider_session inside session_lifecycle_user, then admits_operation rereads the same Session and fork through retained_provider_session_owner. Both reads happen before enqueue. The SQL assertion at forks.rs:2274 uses a mismatched workspace, so it stops before the second read. Also, WriteOnly passes this enqueue check, while preparing the finalization plan requires Read. A write-only caller can receive accepted for work that repeatedly fails recovery until its grants change.
Use the same owned Session lookup to verify the applicable proofs, then perform one fresh compound grant check for explicit finalization. Keep fresh checks when the worker actually performs the work. Cover successful MOI admission and the write-only outcome, including the authorization-query count before enqueue.
| ) -> Result<serde_json::Value, MemoriaForwardError> { | ||
| let authority = resolve_memoria_user_authority(state, user_id, requires_write).await?; | ||
| let authority = | ||
| resolve_memoria_user_authority(state, user_id, None, !requires_write, requires_write) |
There was a problem hiding this comment.
[P2] Carry verified MOI scope into the safety snapshot for Edge mutations
The Edge gateway calls POST /memory/snapshots before update or forget. That route resolves authority with no principal or Session, so the MOI resolver always denies it. The gateway warns and proceeds, and the newly allowed workspace-scoped mutation can succeed with no recovery snapshot. Server-owned tools use the Session-bound transport for that same step.
Use the existing authenticated workspace authority for this pre-mutation step and keep the fresh grant check on the mutation itself. If the product intentionally omits snapshots for this path, make that an explicit tool contract and drop the always-failing request. Please exercise the Edge snapshot-to-mutation sequence in the existing proxy fixture.
…61109 # Conflicts: # deployment/all-in-one/.env.example
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed 30775ba. The four previous code findings are addressed. The cross-Run dialogue stays in one record through raw fallback. The proxy preserves accepted correction receipts with and without an ID. Explicit MOI finalization verifies both Session proofs in one binding read, requires current read/write access, and leaves the worker's fresh check in place. Edge snapshots and mutations use the same workspace owner and independently check current grants.
The settled Run remains the right owner for optional observation. The change reuses the existing worker and bounded delivery, with no observation polling SQL, schema or durable delivery state. The SQL regression checks the admitted finalize path as well as denial. GitHub's MOI compatibility lane passed 21 tests, including the expanded public route fixture. I also read back same-record confirmations from the published Memoria 0.5.3 image with extraction disabled, using both its short and complete observation routes, and verified owner-scoped snapshot creation. Locally, 29 distinct targeted runtime tests passed, including observer saturation, timeout and Session evidence tests. Formatting and diff checks passed. The three-way merge with current main is clean.
The remaining merge blocker is the PR's existing product acceptance gate. The callback and default grant change have merged, and the controlled callback fixture passes. Please attach results from a real MOI login through this Astra candidate and Memoria for default read/write, read-only and revocation. The PR still lists that acceptance as pending. Acceptance thread · MOI compatibility CI.
Capability assessment: Unchanged: Memory remains Beta. This change connects MOI workspace IAM to existing Server memory consumers and keeps automatic observation best effort.
Summary
MOI requests identify an IAM user. Astra verifies the workspace bound to the Session, calls MOI for that user's mapped UC identity and independent workspace grants, checks the UC account, and derives a personal Memoria owner for that user and workspace. Tools, observer dispatch, compaction and session-end governance share the same authority. Failures never fall back to an unrestricted deployment credential.
Related issue
Related to matrixflow#20337. The companion callback and default IAM grants shipped in matrixflow#21532. Keep the issue open pending real-product acceptance.
Change type
User and compatibility impact
Architecture and complexity delta
The Run owner that completes terminal settlement hands the bounded request to the Server's existing observation worker. Four process-local slots bound the work. No task waits for a free slot. Each task resolves fresh authority before sending. Timed-out tasks release their own slot and report an error. Observation has no shared storage circuit to reopen.
Removed the candidate's continuous observation scanner, database-clock reads, due index, claim leases, checkpoints and manifest materialization. A retained Session does no observation work merely by existing. Dispatch does not issue scheduler SQL or maintain an index. Request authorization can still query Astra, MOI and UC. The pre-existing session-end maintenance driver continues separately.
Verification
The official Memoria 0.5.3 image was exercised over HTTP with owner-scoped authentication and disposable MatrixOne. A scripted extractor saw the correction beyond character 500 and stored a standalone preference while rejecting an ambiguous reply. Without a configured model, the complete route stored and read back the full raw message, oversized input returned 422, and standalone returned 503. This checks the released backend directly.
Public chat and Run guidance tests exercise individually long inputs, explicit preferences after a tool, and indirect confirmations. The standalone request excludes the earlier user goal, tool output and assistant wording. Write-tool HTTP tests check that an oversized submitted value yields actionable size guidance and a denied write does not expose stored text. Correction receipts require a valid memory ID before reporting completion. The gateway regression covers missing or empty receipts, accepted and queued writes, and a valid corrected record with private backend content.
On MatrixOne 4.2.8, four local public Run journeys used the candidate Memoria HTTP service and read stored rows back as the same owner. A controlled extractor stored a correction beyond character 500 and a self-contained Rust preference after tool use. An indirect confirmation produced no stored memory. With extraction disabled, the complete route stored the long uninterrupted exchange in full. These runs used local account authority.
Runtime regressions cover unrelated history compaction before and after acknowledgement, replacement at the same position, and removal of the question.
The public chat and Run-guidance endpoints were exercised against MatrixOne 4.2.8. Exact observer payloads were checked for a 501-character answer, additive steering, a correction without tools, and a correction following a memory call. A scripted model received a prior private recall result, then answered the corrected preference. The current standalone request carries only acknowledged user text. The Server-to-gateway exact purge test checked the public receipt and remaining local identities for zero, partial and full matches.
MatrixOne 4.2.8 with 100,000 pre-existing Session heads. The real public chat path with a loopback model and authenticated Memoria HTTP fixture completed all nine cold, warm and held scenarios. The final run counted 159 SQL statements in total. Cold ordinary chat used 17 statements, including one after the response. Warm ordinary chat used 19 and held ordinary chat used 18. All nine delivered their current turn and stayed within the existing raw limit of 20. These totals are for local-account authority.
The configured Auto and skill SQL tests passed. The signed Session workspace lifecycle test passed against real MatrixOne with a controlled identity callback. All 13 observer authority tests passed.
A stalled local observer allowed a second Session to finish, then timed out and released its slot. Its error and the healthy Session's success were recorded separately. The burst test exercised saturation and shutdown. Six Web/CLI/Edge product-entry regressions passed, directly checking model tool history and the separate public observation.
Formatting and diff checks passed. The dedicated local MOI environment includes MOI and Memoria but has no candidate Astra deployment. Real cross-project acceptance remains open.
Final checklist