---
id: 10620
title: Normalize AGENT_MEMORY nodes to use structured timestamp and sessionId columns
state: CLOSED
labels:
  - enhancement
  - ai
  - architecture
assignees:
  - neo-gemini-pro
createdAt: '2026-05-03T08:38:00Z'
updatedAt: '2026-06-07T17:23:20Z'
githubUrl: 'https://github.com/neomjs/neo/issues/10620'
author: neo-gemini-pro
commentsCount: 0
parentIssue: null
subIssues: []
subIssuesCompleted: 0
subIssuesTotal: 0
blockedBy: []
blocking:
  - '[x] 10625 All-agent-idle detection at heartbeat layer (substrate primitive for trio liveness)'
closedAt: '2026-05-03T10:56:59Z'
---
# Normalize AGENT_MEMORY nodes to use structured timestamp and sessionId columns

### Context
During the implementation of the fresh-session-spawn substrate corrective (PR #10619), a schema gap was identified in the Memory Core. `AGENT_MEMORY` nodes currently store crucial routing metadata (like `timestamp` and `sessionId`) as embedded string projections rather than structured first-class properties. 

### The Problem
The lack of structured fields forces downstream queries (like the Cycle 2 schema fix in PR #10619) to rely on brittle regex-based extraction from serialized JSON or unstructured property strings. This approach is computationally inefficient and introduces unnecessary schema coupling where the GraphLog parser must understand the internal string representation of the node properties. 

### The Architectural Reality
In the SQLite Database and GraphService operations, filtering `AGENT_MEMORY` by time or session requires mapping over full node properties or relying on regex parsing over the node's serialized data rather than leveraging indexable database columns or top-level structured JSON properties.

### The Fix
Promote `timestamp` and `sessionId` from embedded string projections to first-class structured properties on `AGENT_MEMORY` nodes. 
1. Update node creation logic to set these fields structurally within the `properties` map.
2. Provide a migration strategy or an update-on-read mechanism for existing `AGENT_MEMORY` nodes in the SQLite database to extract and elevate these fields.
3. Update downstream querying logic to query against the normalized properties and remove the legacy regex-based extraction added in PR #10619.

### Acceptance Criteria
- [ ] `timestamp` is a structured property on newly created `AGENT_MEMORY` nodes.
- [ ] `sessionId` is a structured property on newly created `AGENT_MEMORY` nodes.
- [ ] Existing `AGENT_MEMORY` nodes are migrated or gracefully handled without regex fallback.
- [ ] The regex fallback in the `AGENT_MEMORY` node lookup introduced in PR #10619 is removed.

### Out of Scope
- Changes to the underlying GraphLog schema itself (this is strictly about node property normalization, not altering the base tables).
- Refactoring `MESSAGE` or `TASK` node schemas.

### Related
- PR #10619
- PR #10618

Origin Session ID: ba7c6393-6378-4905-bf62-12eca4954583
Retrieval Hint: "Option B deferred, schema-normalization follow-up supported"

## Timeline

- 2026-05-03T08:38:01Z @neo-gemini-pro added the `enhancement` label
- 2026-05-03T08:38:01Z @neo-gemini-pro added the `ai` label
- 2026-05-03T08:38:01Z @neo-gemini-pro added the `architecture` label
- 2026-05-03T08:43:20Z @neo-gemini-pro cross-referenced by PR #10621
- 2026-05-03T09:24:33Z @neo-gemini-pro referenced in commit `1c40a97` - "chore(memory): align checkSunsetted with MemoryService schema changes (#10620)"
- 2026-05-03T09:24:34Z @neo-gemini-pro referenced in commit `b9d5dd1` - "test(memory): add schema validation spec and scratch pruner (#10620)"
- 2026-05-03T10:19:28Z @neo-gemini-pro referenced in commit `5de9408` - "refactor(memory-core): address Cycle 2 schema normalization feedback (#10620)"
- 2026-05-03T10:32:17Z @neo-gemini-pro referenced in commit `a428194` - "test(memory-core): fix checkSunsetted dynamic import and trailing whitespace (#10620)"
- 2026-05-03T10:35:00Z @neo-opus-ada cross-referenced by #10625
- 2026-05-03T10:38:01Z @neo-opus-ada marked this issue as blocking #10625
- 2026-05-03T10:41:51Z @neo-gemini-pro referenced in commit `cf44ab0` - "fix(memory-core): final trailing whitespace removal in checkSunsetted (#10620)"
- 2026-05-03T10:56:59Z @tobiu referenced in commit `309329e` - "fix(ai): normalize AGENT_MEMORY and fix heartbeat query (#10620) (#10621)

* chore(memory): align checkSunsetted with MemoryService schema changes (#10620)

* test(memory): add schema validation spec and scratch pruner (#10620)

* refactor(memory-core): address Cycle 2 schema normalization feedback (#10620)

* test(memory-core): fix checkSunsetted dynamic import and trailing whitespace (#10620)

* fix(memory-core): final trailing whitespace removal in checkSunsetted (#10620)

---------

Co-authored-by: tobiu <tobiasuhlig78@gmail.com>"
- 2026-05-03T10:56:59Z @tobiu closed this issue
- 2026-05-03T11:11:51Z @neo-opus-ada cross-referenced by PR #10628
- 2026-05-03T11:29:57Z @neo-opus-ada cross-referenced by PR #10631
- 2026-05-03T16:08:29Z @neo-opus-ada cross-referenced by #10601
- 2026-05-04T08:46:55Z @neo-opus-ada cross-referenced by #10671
- 2026-05-09T21:23:53Z @neo-gemini-pro assigned to @neo-gemini-pro

