-
Notifications
You must be signed in to change notification settings - Fork 1
feat: wire file_edits/session_agent_policies/display_name to real surfaces #3442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
790cdbf
68de241
1d05160
2b43861
cfa2858
c7a7462
7c6c5a4
89da761
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1995,6 +1995,7 @@ def _archive_summary_to_domain(summary: ArchiveSessionSummary) -> SessionSummary | |
| git_branch=summary.git_branch, | ||
| git_repository_url=summary.git_repository_url, | ||
| provider_project_ref=summary.provider_project_ref, | ||
| display_name=summary.display_name, | ||
| message_count=summary.message_count, | ||
| tags_m2m=summary.tags, | ||
| ) | ||
|
|
@@ -5447,6 +5448,76 @@ async def get_session_events( | |
| for event in events | ||
| ] | ||
|
|
||
| async def get_file_edits(self, session_id: str) -> list[dict[str, object]] | None: | ||
| """Return file-edit tool-call evidence (structuredPatch/originalFile/...) for one session. | ||
|
|
||
| polylogue-nua7: the writer materializes ``ParsedFileEdit`` evidence | ||
| (Claude Code Edit/Write/MultiEdit tool calls -- structured unified | ||
| diffs, pre-edit file content, old/new string pairs) into the | ||
| dedicated ``file_edits`` index table on every ingest | ||
| (``storage/repository/archive/sessions.py::get_file_edits``), but | ||
| before this reader nothing above the storage layer could reach it. | ||
| This is the read surface: what a "what did this session change" | ||
| report needs instead of re-deriving edits from tool-call prose. | ||
|
|
||
| Returns ``None`` when the session does not exist (distinct from an | ||
| empty list, meaning the session exists but made no captured edits). | ||
| """ | ||
| resolved = await self.repository.resolve_id(session_id) | ||
| resolved_id = str(resolved) if resolved is not None else session_id | ||
| session = await self.repository.get(resolved_id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For a large session, each new evidence reader first calls Useful? React with 👍 / 👎. |
||
| if session is None: | ||
| return None | ||
| edits = await self.repository.get_file_edits(resolved_id) | ||
| return [ | ||
| { | ||
| "tool_use_block_id": edit.tool_use_block_id, | ||
| "message_id": str(edit.message_id), | ||
| "file_path": edit.file_path, | ||
| "structured_patch": edit.structured_patch, | ||
| "original_file": edit.original_file, | ||
| "old_string": edit.old_string, | ||
| "new_string": edit.new_string, | ||
| "replace_all": edit.replace_all, | ||
| "user_modified": edit.user_modified, | ||
| "observed_at_ms": edit.observed_at_ms, | ||
| } | ||
| for edit in edits | ||
| ] | ||
|
|
||
| async def get_agent_policies(self, session_id: str) -> list[dict[str, object]] | None: | ||
| """Return sandbox/approval/network policy facts recorded for one session. | ||
|
|
||
| polylogue-nua7: the writer diverts Codex ``agent_policy`` events out | ||
| of ``session_events`` into the dedicated ``session_agent_policies`` | ||
| table (fully re-derivable, zero evidence loss -- see | ||
| ``archive_tiers/write.py:_SESSION_EVENTS_REDUNDANT_TYPES``), but | ||
| before this reader nothing above the storage layer could reach it | ||
| back. This is the read surface. | ||
|
|
||
| Returns ``None`` when the session does not exist (distinct from an | ||
| empty list, meaning the session exists but reported no agent-policy | ||
| facts -- expected for non-Codex origins). | ||
| """ | ||
| resolved = await self.repository.resolve_id(session_id) | ||
| resolved_id = str(resolved) if resolved is not None else session_id | ||
| session = await self.repository.get(resolved_id) | ||
| if session is None: | ||
| return None | ||
| policies = await self.repository.get_agent_policies(resolved_id) | ||
| return [ | ||
| { | ||
| "policy_id": policy.policy_id, | ||
| "position": policy.position, | ||
| "approval_policy": policy.approval_policy, | ||
| "sandbox_policy": policy.sandbox_policy, | ||
| "network_policy": policy.network_policy, | ||
| "observed_at_ms": policy.observed_at_ms, | ||
| "source_message_id": policy.source_message_id, | ||
| } | ||
| for policy in policies | ||
| ] | ||
|
|
||
| async def query_sessions( | ||
| self, | ||
| *, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ class SessionRuntimeMixin: | |
| metadata: dict[str, object] | ||
| parent_id: SessionId | None | ||
| branch_type: BranchType | None | ||
| display_name: str | None | ||
|
|
||
| if TYPE_CHECKING: | ||
|
|
||
|
|
@@ -73,6 +74,12 @@ def display_title(self) -> str: | |
| return user_title | ||
| if self.title: | ||
| return self.title | ||
| # polylogue-cgfy: provider-assigned display name (e.g. Claude Code's | ||
| # slug, "greedy-squishing-hamming") beats the raw id truncation -- | ||
| # the fix for subagent rows showing "<uuid-prefix>" instead of a | ||
| # human-readable name when no title-worthy sidecar evidence exists. | ||
| if self.display_name: | ||
| return self.display_name | ||
|
Comment on lines
+81
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For existing sessions whose nonblank AGENTS.md reference: AGENTS.md:L354-L356 Useful? React with 👍 / 👎. |
||
| return self.id[:8] | ||
|
|
||
| @property | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wires
display_nameonly through the summary conversion. The publicPolylogue.get_session()path uses_archive_session_to_session(archive.read_session(...)), butArchiveSessionEnvelopeneither selects nor carriessessions.display_name, so full session reads still produceSession.display_name=Noneand fall back to the raw ID when no title exists. Add the column to both archive-envelope read variants and pass it through the full-session converter.AGENTS.md reference: AGENTS.md:L351-L353
Useful? React with 👍 / 👎.