Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Create things and things_facts tables for object/software/hardware tracking #56

@NOVA-Openclaw

Description

@NOVA-Openclaw

Summary

We have entities + entity_facts for people/agents and places + place_properties for locations, but no table for objects/things.

Things = catch-all for any noun that isn't an entity or a place.

Noun Categories

Entities (people, beings, organizations)

  • People: John, I)ruid, Satoshi
  • Agents: NOVA, Newhart, Coder
  • Organizations: corporations, companies, agencies
  • Beings: gods, spirits, ghosts, extraterrestrial beings, fictional characters

Places (physical/virtual locations)

  • Countries, states, territories
  • Cities, towns, villages
  • Buildings, facilities, addresses
  • Networks, servers, data centers

Things (everything else)

  • Software: OpenClaw, signal-cli, bird-x
  • Hardware: computers, servers, phones, Hue bridges
  • Vehicles: cars, boats, Camper de Verde
  • Documents: certificates, contracts, books
  • Objects: furniture, tools, rocks, anything physical

Proposed Schema

CREATE TABLE things (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL UNIQUE,
    type VARCHAR(50),  -- software, hardware, vehicle, document, etc.
    description TEXT,
    owner_entity_id INTEGER REFERENCES entities(id),
    location_place_id INTEGER REFERENCES places(id),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE things_facts (
    id SERIAL PRIMARY KEY,
    thing_id INTEGER REFERENCES things(id) ON DELETE CASCADE,
    key VARCHAR(255) NOT NULL,
    value TEXT NOT NULL,
    data JSONB,
    data_type VARCHAR(20) DEFAULT 'observation',
    source VARCHAR(255),
    learned_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

⚠️ Semantic Embedding Triggers (REQUIRED)

New tables MUST auto-queue for semantic embedding on INSERT, like entity_facts does:

-- Trigger for things table
CREATE OR REPLACE FUNCTION queue_thing_embedding() RETURNS TRIGGER AS $$
BEGIN
    INSERT INTO embedding_queue (source_type, source_id, content)
    VALUES ('thing', NEW.id, NEW.name || ': ' || COALESCE(NEW.description, ''));
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER trg_embed_thing
AFTER INSERT ON things
FOR EACH ROW EXECUTE FUNCTION queue_thing_embedding();

-- Trigger for things_facts table  
CREATE OR REPLACE FUNCTION queue_thing_fact_embedding() RETURNS TRIGGER AS $$
BEGIN
    INSERT INTO embedding_queue (source_type, source_id, content)
    VALUES ('thing_fact', NEW.id, NEW.key || ': ' || NEW.value);
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER trg_embed_thing_fact
AFTER INSERT ON things_facts
FOR EACH ROW EXECUTE FUNCTION queue_thing_fact_embedding();

Also add triggers for existing places table (currently missing):

CREATE TRIGGER trg_embed_place AFTER INSERT ON places ...
CREATE TRIGGER trg_embed_place_property AFTER INSERT ON place_properties ...

Memory Extractor Integration

Update grammar_parser/store_relations.py to route nouns to correct table.

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions