Repository navigation
feat(insights): derive session objective posture from open obligations - #3226
Conversation
Problem: SessionInferencePayload.terminal_state describes how a session's process ended (structural tool/turn evidence), not whether its underlying objective was resolved. Since polylogue-ve9z deleted the prose-derived clean_finish heuristic (measured 50.5% agreement with structural truth), most well-behaved endings now collapse to terminal_state="unknown" -- silence, not a completion claim -- which resume ranking and blocker extraction still effectively read as "probably done". polylogue-37t.23 asks for a separate resumability projection over authority-bearing open obligations instead. Solution: new polylogue.insights.objective_posture module defines ObjectivePosture/ObjectivePostureAuthority and an explicit authority order (goal_graph > work_evidence > assertion > structural_inference > none). The top two tiers (polylogue-7yk5 goal graph, polylogue-1vpm.6 work-evidence graph) are not yet built, so this lands the two tiers that are: structural_objective_posture (bounded terminal_state mapping, index.db-only, never emits "completed") and derive_objective_posture (overlays durable decision/blocker/handoff assertions, which outrank structural inference). The assertion tier is a read-time overlay (resolve_session_objective_posture), not baked into the materialized profile row, so index.db stays independently rebuildable from source.db without a user.db dependency. Wired into the existing INSIGHT_REGISTRY session_profiles entry via a new enrichment.objective_posture field (reconciled onto the native terminal_state column the same way inference.terminal_state already is). Consumers: blocker-text extraction now gates on the shared posture mapping instead of a parallel _UNRESOLVED_BLOCKER_TERMINAL_STATES allowlist (which never covered "unknown" -- the exact false-negative case this bead targets); resume ranking adds a posture-weighted score component and replaces the dead terminal_state == "clean_finish" exclusion filter with objective_posture != "completed"; resume_brief overlays the full assertion tier for its single session; the context preamble surfaces posture per related session. Ref polylogue-37t.23
Ref polylogue-37t.23
… paths Adds focused unit tests for polylogue.insights.objective_posture (structural_objective_posture never emits "completed"; assertion tier outranks structural inference; multiple simultaneous obligations surface as contradictions rather than collapsing; self-reported assertion values cannot force "completed") plus the resolve_session_objective_posture async wrapper. Fixes a second reconciliation gap the tests caught: _session_profile_components_from_archive_row (storage/sqlite/archive_tiers/archive.py) is the live SQL-backed read path used by list_session_profile_insights/resume ranking -- distinct from insights.archive.SessionProfileInsight.from_record (used by daemon/http.py) -- and needed the same native-column reconciliation for objective_posture that from_record already got. Existing _UNRESOLVED_BLOCKER_TERMINAL_STATES / resume-ranking / context-preamble tests updated for the new field and behavior (blocker text is no longer silently suppressed for terminal_state="unknown"). Ref polylogue-37t.23
verify-degrade-loudly requires a log call or re-raise on any bare except Exception. build_resume_brief already surfaces the failure via ResumeUncertainty; add the matching logger.warning (same pattern as context/preamble.py's component-failure handling) so the fallback is never silent. Ref polylogue-37t.23
|
Warning Review limit reached
Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (16)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7f2e5ef90
ℹ️ 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".
|
Coordinator review stand-in (CodeRabbit rate-limited — no findings produced). Read the full diff. Assessment:
Quick-gate green. Merging. |
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
Problem: master gained #3226 (objective-posture insight, new module + topology regen) and #3227 (hermes_verification.py profile-qualified identity: verification:<id>[@PROfile-<key>], hermes_verification_session_id_for now PRESERVES the qualifier instead of stripping it) since this branch's last rebase. Rebasing surfaced one real conflict and one silent cross-file break the rebase's textual merge did not flag: - polylogue/sources/parsers/hermes_verification.py: conflicting docstring edits (both #3227 and this branch's earlier commit touched the same observer_session_provider_id/hermes_verification_session_id_for docstrings) -- resolved to describe the composed state: profile-qualified AND correctly referencing hermes_spans's renamed atif_session_provider_id/atof_session_provider_id (this branch) instead of the retired shared observer_session_provider_id. - tests/unit/sources/parsers/test_hermes_verification.py (added by #3227, never touched by this branch's commits, so the rebase reported no conflict): test_verification_family_prefix_stays_distinguishable_from_atif_atof_observer_family imported hermes_spans.observer_session_provider_id, a name this branch retired in favor of atif_session_provider_id/atof_session_provider_id -- an ImportError, not a merge conflict, so it only surfaced by actually running the suite. Fixed to import and assert against both renamed functions (verification: stays distinguishable from BOTH observer:atif: and observer:atof:, not just the old single observer: family). Semantic composition check (per coordinator request): hermes_topology_projection.py never hardcodes a session-id shape itself -- callers resolve each artifact's session_id (see HermesArtifactInput docstring) via hermes_spans.atif_session_provider_id/atof_session_provider_id or hermes_verification.hermes_verification_session_id_for -- so the module is scheme-agnostic by construction and needed no code change. Added test_composes_with_profile_qualified_verification_ids_like_atif_and_atof in tests/unit/insights/test_hermes_topology_projection.py, which drives the REAL hermes_verification_session_id_for/hermes_identity helpers (not a hand-typed "verification:<id>" string) from a profile-qualified conversational session id and proves: the resolved verification id preserves the qualifier (not stripped, matching #3227's fix), and two different profiles resolve to two distinct, non-colliding verification session ids for the same raw Hermes session id -- exactly the guarantee ATIF/ATOF already have. docs/hermes-operators.md: "Session identity" section and item 1 updated -- previously (written before #3227 merged) claimed hermes_verification's helper "still strips" the profile qualifier and was "explicitly left out of this fix's scope"; now correctly describes it as fixed separately (polylogue-y9zx, PR #3227) using the same shared hermes_identity.py scheme. docs/plans/topology-target.yaml, docs/topology-status.md: regenerated (devtools render topology-projection && render topology-status) to reflect #3226's new objective-posture insight module -- no textual conflict during rebase, but genuinely stale without regen. Verification: - devtools test tests/unit/insights/test_hermes_topology_projection.py tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_live_watcher.py tests/unit/sources/parsers/test_hermes_verification.py -- 151 passed. - devtools verify --quick -- exit 0. Ref polylogue-fs1.14 Co-Authored-By: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Adds a session-level objective-posture projection — whether a
session's underlying goal remains open — derived from authority-bearing
evidence instead of process-termination text. It is separate from
SessionInferencePayload.terminal_state(how the process ended) and iswired into the existing
INSIGHT_REGISTRYsession_profilesentry soprofiles, blocker extraction, resume ranking, and the context preamble
consume the same projection.
Problem
terminal_statedescribes structural tool/turn evidence at the end of asession, not whether its objective was resolved. Since polylogue-ve9z
(#2960, landed after this bead was filed) deleted the prose-derived
clean_finishheuristic — measured at 50.5% agreement (a coin flip) withstructural truth — most well-behaved endings now collapse to
terminal_state="unknown": silence, not a completion claim. Twodownstream consumers still effectively read that silence as "probably
done":
_UNRESOLVED_BLOCKER_TERMINAL_STATESallowlist that never included
"unknown", so a session ending on anormal reply with an earlier user-reported blocker had that blocker
text silently suppressed.
_terminal_weight("unknown") == 0.25(low), with adead
terminal_state == "clean_finish"exclusion filter that couldnever fire anymore.
Solution
New
polylogue.insights.objective_posturemodule definesObjectivePosture/ObjectivePostureAuthorityand an explicitauthority order:
goal_graph(polylogue-7yk5) >work_evidence(polylogue-1vpm.6) >
assertion>structural_inference>none. Thetop two tiers are not yet built (both are open epics), so this PR lands
the two that are:
structural_objective_posture— a boundedterminal_statemapping,index.db-only inputs, never emits"completed"(no structuralsignal available today observes a satisfied effect).
derive_objective_posture— overlays durabledecision/blocker/handoffAssertionKindrows (user.db), which outrank structuralinference. Multiple simultaneous assertion kinds are preserved as
contradictions, not silently collapsed.The assertion tier is a read-time overlay
(
resolve_session_objective_posture), not baked into the materializedsession_profilesrow, soindex.dbstays independently rebuildablefrom
source.dbwithout auser.dbdependency.Wiring:
enrichment.objective_posturefield onSessionProfileInsight(reconciled onto the native
terminal_statecolumn at read time —found and fixed in both existing reconciliation sites:
insights.archive.SessionProfileInsight.from_recordand the liveSQL-backed
_session_profile_components_from_archive_row).instead of the old parallel allowlist.
the dead
clean_finishexclusion withobjective_posture != "completed".resume_briefoverlays the full assertion tier for its single sessionand surfaces a durably-declared obligation as the first next-step.
INSIGHT_REGISTRYsession_profilesentry gainsposture/posture_authoritydisplay fields; FTS enrichment search textincludes the posture label.
Scope discrepancy vs. the bead text (honest disclosure)
The bead's AC1 example text ("terminal_state=clean_finish and
objective_posture=awaiting_operator simultaneously") references
clean_finish, which PR #2960 deleted the same day the bead was lastupdated — that exact literal state no longer exists. The underlying
intent (a session with no structural error/pending signal must not be
silently treated as resolved) is fully addressed via the
terminal_state="unknown"case instead, and is directly covered by anintegration test (
test_session_enrichment_payload_reuses_text_band_outputs).The
goal_graph(polylogue-7yk5) andwork_evidence(polylogue-1vpm.6)authority tiers are reserved slots only — both are open epics with no
storage substrate yet. Wiring them in is a bounded follow-on: the
precedence order and
ObjectivePosturePayloadshape do not need tochange.
AC matrix
terminal_state="unknown"(the honest post-refactor(insights): delete prose-keyword heuristics for terminal state and activity labels #2960 equivalent of the bead's
clean_finishexample)gets
objective_posture.posture="ambiguous", and an activedecision/handoffassertion on that session elevates it to"awaiting_operator"— both simultaneously present, and resume ranking includes it
(
objective_posture != "completed"filter, plus the posture-weightedscore term). Verified in
test_objective_posture.py::TestDeriveObjectivePosture::test_assertion_tier_outranks_structural_inference.evidence_refs,authority,as_of, andcontradictionsare all present onObjectivePosturePayloadand exercised by tests.completed,blocked,abandoned_inactive,awaiting_operator,awaiting_effect,ambiguous,unknownare all in theObjectivePosturevocabulary;only
abandoned_inactive/completedare not reachable from the twocurrently-wired tiers (deferred to goal_graph/work_evidence).
derive_objective_posturealways prefers the assertiontier over structural inference;
test_self_reported_assertion_value_cannot_force_completedproves a freeform assertion
valueclaiming resolution cannot force"completed".structural_objective_posturenever maps anyterminal_stateto"completed";test_never_emits_completedparametrizes every known state. Removing the authority-order check in
derive_objective_posture(returning structural whenever assertionsexist) would make
test_assertion_tier_outranks_structural_inferencefail — the anti-vacuity anchor for this AC.
resume ranking, context preamble) — one shared function, no parallel
terminal-state completion heuristic; the old
_UNRESOLVED_BLOCKER_TERMINAL_STATESallowlist is deleted.scope for a single-lane PR without live archive access in this
sandboxed worktree. Recorded as residual risk below.
Verification
devtools test tests/unit/insights/test_objective_posture.py tests/unit/storage/test_session_insight_profiles.py tests/unit/core/test_resume.py tests/unit/mcp/test_context_resume_intent.py tests/unit/cli/test_context_view.py tests/unit/api/test_facade_contracts.py tests/unit/insights/test_rigor_audit.py→ 381 passed.devtools testover a broader plausibly-affected set (CLI insights/check/query-exec-laws, core pricing/registry/readiness, cost contract suite, devtools rigor-honesty, daemon web reader, storage archive-tiers/user-state/session-profile-consistency/status-descriptors, insights registry/no-metadata-cost-reads) → 601 passed, 1 xfailed, 3 pre-existing failures (test_check_runtime_only_skips_archive_readiness,test_exact_session_action_count_bounds_pairing_before_global_ranking,test_operational_web_payloads_redact_configured_archive_paths) — reproduced identically on a pristineorigin/masterworktree with none of this PR's changes present, confirming they are unrelated pre-existing/environment failures, not regressions from this diff./realm/project/polylogue/.venv/bin/mypyon every touched source + test file → no issues./realm/project/polylogue/.venv/bin/ruff check/ruff format --checkon every touched file → clean.devtools render topology-projection && devtools render topology-status(new module) anddevtools render all --check→ sync OK, no drift.devtools verify --quick(format + lint + mypy + render-all-check + topology/layering/closure-matrix/schema-roundtrip/manifests/ci-workflows/doc-commands/docs-coverage/test-infra-currency/test-clock-hygiene/pytest-timeout-overrides/degrade-loudly) → exit 0, ran automatically via the pre-push hook too.devtools verify --all(full non-integration suite) — testmon was unseeded in this worktree; seeding was judged out of scope for a single-lane PR. Not run:devtools verify --seed-testmon.Ref polylogue-37t.23