Skip to content

fix(derived): discover composed session work from pending demand - #5540

Merged
Sinity merged 1 commit into
masterfrom
fix/profile-recurring-discovery
Sep 25, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/profile-recurring-discovery

Conversation

@Sinity

@Sinity Sinity commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Make periodic and scoped composed summary, usage, and profile discovery consume indexed session demand, while keeping exact input binding as the publication backstop.
  • Include ordered working-directory paths in the session input binding and invalidate demand for each path insert, update, and delete.
  • Make the HTTP profile panel use stored binding and pending demand for readiness, and compare the fetched profile row with the later status snapshot before reporting it current.

Problem

The composed daemon callback still scanned session partitions on unchanged periodic passes. A working-directory-only edit changed profile repo and cwd evidence without changing the input binding or scheduling demand. The HTTP profile panel could also report a retained stale row as ready using timestamp provenance alone. These gaps block polylogue-bp12n.1 before reindex.

Solution

The index owns a bounded session demand queue, seeded when a profile, summary, usage, or input recipe changes and invalidated by affected writers. The composed callback pages that queue; direct maintenance routes retain exact discovery. Working-directory rows are digested in stable position/path order. The HTTP route obtains the domain classifier through operations, reports pending or unbound output as degraded and q-partial, and requires the displayed row's binding and version to match the classifier's read frame. The archive record reader now returns the stored binding and version it declares.

The new profile_demand.py module enters the derived schema identity closure. Five marker modules leave that closure. The checked-in closure baseline records the measured 557 members. Land this before starting the required derived archive reconvergence.

Verification

  • devtools test tests/unit/daemon/test_insights_browser_endpoint.py tests/unit/daemon/test_raw_materialization_parse_stage_equivalence.py tests/unit/daemon/test_session_profile_composition.py — 33 passed on rebased commit 9e3f19dbc; receipt 20260925T180601Z-focused-test-2824203-f434b24e.
  • devtools test tests/unit/daemon/test_session_profile_composition.py tests/unit/storage/test_session_partition_convergence.py tests/unit/storage/test_session_input_digest_boundaries.py tests/unit/storage/test_session_profile_derivation.py — 101 passed before the final rebase; receipt 20260925T174124Z-focused-test-2667418-e28107bb.
  • devtools gate mypy — no issues in 3062 source files; devtools gate layering — zero new violations; devtools gate schema-closure — 557 observed and baselined, no additions or removals.
  • devtools schema closure polylogue/storage/derived/session/profile_demand.py and devtools schema closure polylogue/storage/sqlite/archive_tiers/archive.py — IN; devtools schema closure polylogue/operations/session_profile_convergence.py and devtools schema closure polylogue/daemon/http.py — out.

Residuals

The focused R1/R2 test exercises the ordinary accepted ingest writer and periodic composed consumer with synthetic parser output. It does not exercise provider detection or a live daemon process. The full corpus was not run. No live archive was touched or reindexed.

@Sinity
Sinity enabled auto-merge (squash) September 25, 2026 18:09
@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 17fac2d6-3e7a-4676-b9e9-6e7614a1f758

📥 Commits

Reviewing files that changed from the base of the PR and between 41c9782 and 9e3f19d.

📒 Files selected for processing (18)
  • docs/plans/schema-closure-baseline.json
  • polylogue/daemon/derivation.py
  • polylogue/daemon/http.py
  • polylogue/daemon/session_profile_composition.py
  • polylogue/operations/session_profile_convergence.py
  • polylogue/storage/derived/session/derivation.py
  • polylogue/storage/derived/session/input_binding.py
  • polylogue/storage/derived/session/profile_demand.py
  • polylogue/storage/derived/session/summary.py
  • polylogue/storage/derived/session/usage_rollup.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • polylogue/storage/sqlite/archive_tiers/index.py
  • tests/unit/daemon/test_insights_browser_endpoint.py
  • tests/unit/daemon/test_raw_materialization_parse_stage_equivalence.py
  • tests/unit/daemon/test_session_profile_composition.py
  • tests/unit/storage/test_session_partition_convergence.py
  • tests/unit/storage/test_session_profile_derivation.py
  • tests/unit/storage/test_session_usage_rollup_derivation.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T18:15:51.729117Z 9e3f19d PR opened
🔒 Security Review ✅ Completed 2026-09-25T18:14:23.591916Z 9e3f19d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e3f19dbcf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/daemon/http.py Resolved
@Sinity
Sinity merged commit 315db76 into master Sep 25, 2026
3 checks passed
@Sinity
Sinity deleted the fix/profile-recurring-discovery branch September 25, 2026 18:22
Sinity added a commit that referenced this pull request Sep 28, 2026
## Summary

Fixes one product defect and realigns daemon and MCP tests that fail on
master because they encode superseded contracts.

## Problem

A per-directory run of `tests/unit/daemon` and `tests/unit/mcp` on clean
master (`03c543dfe`) failed 28 and 11 tests. This PR covers the clusters
below. Other failures belong to named owners or need a decision; see
Residuals.

- **Product defect: MCP hides daemon rejections.** When the resident
daemon refused a write before durable acceptance, MCP callers saw
`write: internal error (DaemonOperationRejectedError)`. The daemon's
typed code and detail were lost, for example why a saved view cannot be
watched.
- **MCP tests that write with no daemon.** Public archive writes are
daemon-owned since #5550. Nine MCP tests plus three standing-query tests
still wrote with no daemon and got `FacadeDaemonRequiredError`.
- **Stale daemon expectations:**
- Since #5621 a snapshot with no rich observation is `unavailable`, not
`stale`.
- #5664 passes `derivation_barrier` to the converger, which the test
double did not accept.
- The mark-delete route test compared against the raw payload rather
than the request model's normalized one.
- The chunk-cost test measured the first chunk after seeding. Since
#5657, that chunk also prunes the seeding's raw-existence journal, one
trigger firing per row, so its cost grew with archive size once.
- The insights failure injection patched the facade the route no longer
reads.

## Solution

- `_exception_to_error_json` relays `DaemonOperationRejectedError` with
the daemon's code and detail, as the CLI does.
- New `tests/infra/mcp.py::daemon_served_runtime_services` runs the real
operation stack on the archive's socket for MCP write tests. The
load-evidence test seeds its deliveries under the daemon and measures
reads without it.
- Each stale expectation is realigned; the chunk-cost test converges one
warm-up chunk and measures a steady-state chunk.

## Verification

`devtools test` over the affected daemon and MCP tests plus the MCP
error-translation tests: `165 passed, 1 failed` (receipt
`20260928T000820Z-focused-test-736375-35660df1`, pre-rebase). The one
failure is `test_working_dir_demand_withholds_profile_readiness`,
tracked in polylogue-6remh. The rebase kept master's own fix to
`test_convergence_debt_alert.py` and dropped this branch's change to
that file. No other conflicts.

Review follow-up (`f189af7`): `WatchDefinitionError` declares
`invalid_watch_definition`. MCP reports an undeclared (prose) rejection
code as `rejected`. `DaemonClient` keeps a pre-dispatch refusal's public
detail. `devtools test tests/unit/mcp/test_tool_error_isolation.py
…::test_skewed_write_refusal_is_pre_dispatch_not_an_indeterminate_mutation
tests/unit/daemon/test_standing_queries_default_evaluator.py` passed
(receipt `20260928T003051Z-focused-test-966381-9c978486`). `devtools
schema closure`: `archive/query/watch_definition.py` is IN, so this
lands before a rebuild.

## Residuals

- polylogue-6remh (filed): since #5570, periodic profile ticks run the
startup audit before demanded work. This starves demand and contradicts
#5540's idle-tick contract. It leaves
`test_two_accepted_revisions_survive_one_periodic_profile_pass`,
`test_working_dir_demand_withholds_profile_readiness` and likely
`test_real_factory_defers_hot_target_without_losing_the_no_hint_cursor`
red.
- Not covered here:
- master-fix-owned clusters: the read-authorizer `not authorized`
regression, `selected_session_parts` and `raw_observation_derivation`;
- daemon failures still to diagnose: schema preflight behind the #5657
frontier gate, status baseline `ok`, evidence-summary lineage authority,
stale archive storage, Drive asserted-authority growth, the watcher-hint
timeout, and status component metadata.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 28, 2026
… per tick

A periodic profile tick ran the archive-wide startup audit, one domain
slice at a time, before any demanded session work (#5570). Demanded
profiles therefore waited for the whole sweep after every start, and an
idle tick kept inspecting. Decision (polylogue-6remh): #5540's contract
wins. Every tick runs the demand pass first. The startup/promotion audit
advances only in bounded slices through converge_backlog after demand,
and does not repeat once swept.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
Sinity added a commit that referenced this pull request Sep 28, 2026
## Summary

Periodic profile ticks now serve demanded session work before the
archive-wide audit, and never re-run the audit once it has swept
(polylogue-6remh). Phased Drive catch-up binds a grown document as an
asserted revision again instead of quarantining it. The halted-units
status test gets a genuinely green baseline.

## Problem

- **Demand starved behind the audit (6remh).** Two landed contracts
conflicted. #5540 says a periodic tick publishes demanded work and an
idle tick inspects nothing. #5570 made every unscoped tick run the
startup audit one domain slice at a time (summary, usage rollup,
profile; 128 keys each) before any demand pass. Take a one-session
archive with pending `session_profile_demand`: the first
`callback(None)` returned `outcomes=()`, and no profile was published.
On a large archive, demanded profiles waited for all three domains to
sweep after every daemon start.
`test_two_accepted_revisions_survive_one_periodic_profile_pass` and
`test_working_dir_demand_withholds_profile_readiness` were red on
master.
- **Drive scratch missed a relation.** Phased Drive preparation
classifies revision lineage against an in-memory snapshot of the cohort.
Since #5630, membership classification also reads
`source_item_raw_members`, and the scratch did not carry that table.
Every grown Drive document was therefore quarantined instead of being
bound to its predecessor
(`test_drive_phased_matches_ordinary_document_growth`).
- **Halted-units test baseline.** The healthy frontier fixture set only
`overall_status` over unknown sub-checks. That is not a proof, and it
refutes `ok`, so the test's "green before the halt" baseline was not
green.

## Solution

- Decision recorded on 6remh: #5540's contract wins. `callback(None)`
runs only the demand pass. The startup/promotion audit advances in
bounded slices through `ComposedSessionProfiles.converge_backlog` after
that demand pass, and it does not repeat once swept (only promotion
resets it). Tests that encoded the per-tick audit now drive `audit_pass`
/ `converge_backlog`. The insights race test now models the replacement
at the record the route actually compares.
- `_prepare_ingest_unit_sync` snapshots the cohort's
`source_item_raw_members` into the scratch alongside the other
relations, and revalidates it at publish in the same way.
- The halted-units test pins every collector to a measured healthy
value, keeping the archive's real raw-failure lifecycle, and the shared
frontier fixture proves each sub-check.

`devtools schema closure`: both source files are `out`, so the derived
identity does not move.

## Verification

- `devtools gate mypy`: `Success: no issues found in 3095 source files`
- `devtools test` on session profile composition, the periodic-pass
test, insights browser endpoint, convergence restart law,
raw-materialization fair intake, Drive catch-up execution, status
observations and status unmeasured: pending; this body is updated with
the receipt when it reports

## Residuals

- None known for these three changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):

Resolving every thread listed; confirmed defects are fixed under the named bead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant