htm 0.0.32 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.architecture/decisions/adrs/005-rag-based-retrieval-with-hybrid-search.md +4 -0
- data/.architecture/decisions/adrs/017-bitemporal-event-time.md +78 -0
- data/.architecture/decisions/adrs/018-memory-timelines-and-node-links.md +64 -0
- data/.architecture/decisions/adrs/019-epistemic-status.md +66 -0
- data/.claude.json +11 -0
- data/.envrc +9 -7
- data/.irbrc +14 -14
- data/.reek.yml +104 -0
- data/.rubocop.yml +0 -11
- data/.ruby-version +1 -0
- data/CHANGELOG.md +160 -98
- data/README.md +22 -17
- data/SETUP.md +49 -46
- data/_typos.toml +17 -0
- data/bin/htm +18 -0
- data/db/migrate/00010_convert_embedding_to_sparsevec.rb +47 -0
- data/db/migrate/00011_strip_frontmatter_from_chunks.rb +66 -0
- data/db/migrate/00012_add_event_time_to_nodes.rb +110 -0
- data/db/migrate/00013_create_node_links.rb +158 -0
- data/db/migrate/00014_add_epistemic_status.rb +110 -0
- data/db/schema.sql +238 -7
- data/db/seed_data/README.md +11 -11
- data/db/seeds.rb +11 -11
- data/docs/api/database.md +8 -8
- data/docs/api/embedding-service.md +138 -262
- data/docs/api/htm.md +128 -12
- data/docs/api/index.md +8 -8
- data/docs/api/long-term-memory.md +8 -19
- data/docs/api/working-memory.md +34 -46
- data/docs/api/yard/HTM/Admin/Console.md +53 -0
- data/docs/api/yard/HTM/Admin/DatabaseCommands/Console.md +38 -0
- data/docs/api/yard/HTM/Admin/DatabaseCommands.md +127 -0
- data/docs/api/yard/HTM/Admin/EnrichCommands.md +85 -0
- data/docs/api/yard/HTM/Admin/Error.md +9 -0
- data/docs/api/yard/HTM/Admin/FileCommands/Console.md +50 -0
- data/docs/api/yard/HTM/Admin/FileCommands.md +83 -0
- data/docs/api/yard/HTM/Admin/MemoryCommands/Base.md +17 -0
- data/docs/api/yard/HTM/Admin/MemoryCommands/Edit.md +74 -0
- data/docs/api/yard/HTM/Admin/MemoryCommands/Search.md +77 -0
- data/docs/api/yard/HTM/Admin/MemoryCommands/TagSearch.md +46 -0
- data/docs/api/yard/HTM/Admin/MemoryCommands/WorkingMemory.md +36 -0
- data/docs/api/yard/HTM/Admin/MemoryCommands.md +67 -0
- data/docs/api/yard/HTM/Admin/TagCommands/Console.md +48 -0
- data/docs/api/yard/HTM/Admin/TagCommands.md +105 -0
- data/docs/api/yard/HTM/Admin/TagGraph.md +149 -0
- data/docs/api/yard/HTM/Admin/YardDocs.md +60 -0
- data/docs/api/yard/HTM/Admin.md +102 -0
- data/docs/api/yard/HTM/AuthorizationError.md +6 -6
- data/docs/api/yard/HTM/CLI/ConfigFile.md +40 -0
- data/docs/api/yard/HTM/CLI/Db.md +63 -0
- data/docs/api/yard/HTM/CLI/Enrich.md +39 -0
- data/docs/api/yard/HTM/CLI/ErrorSuggestion.md +56 -0
- data/docs/api/yard/HTM/CLI/Files.md +36 -0
- data/docs/api/yard/HTM/CLI/Group/ClassMethods.md +11 -0
- data/docs/api/yard/HTM/CLI/Group.md +13 -0
- data/docs/api/yard/HTM/CLI/MemoryCommand/ClassMethods.md +20 -0
- data/docs/api/yard/HTM/CLI/MemoryCommand.md +9 -0
- data/docs/api/yard/HTM/CLI/Robots.md +31 -0
- data/docs/api/yard/HTM/CLI/Support.md +9 -0
- data/docs/api/yard/HTM/CLI/Tags.md +57 -0
- data/docs/api/yard/HTM/CLI/WorkingMemory.md +24 -0
- data/docs/api/yard/HTM/CLI.md +84 -0
- data/docs/api/yard/HTM/CircuitBreaker/Guarded.md +29 -0
- data/docs/api/yard/HTM/CircuitBreaker/Settings.md +21 -0
- data/docs/api/yard/HTM/CircuitBreaker/Status.md +42 -0
- data/docs/api/yard/HTM/CircuitBreaker.md +54 -49
- data/docs/api/yard/HTM/CircuitBreakerOpenError.md +9 -9
- data/docs/api/yard/HTM/Config/Builder.md +87 -0
- data/docs/api/yard/HTM/Config/Coercion.md +59 -0
- data/docs/api/yard/HTM/Config/Database.md +102 -0
- data/docs/api/yard/HTM/Config/Readers.md +30 -0
- data/docs/api/yard/HTM/Config/RubyLlmSettings.md +32 -0
- data/docs/api/yard/HTM/Config/Validator.md +59 -0
- data/docs/api/yard/HTM/Config.md +224 -105
- data/docs/api/yard/HTM/ConfigurationError.md +20 -0
- data/docs/api/yard/HTM/Confirmation.md +22 -0
- data/docs/api/yard/HTM/Database/Connection.md +26 -0
- data/docs/api/yard/HTM/Database/Migrations.md +32 -0
- data/docs/api/yard/HTM/Database/Report.md +26 -0
- data/docs/api/yard/HTM/Database/SchemaFile.md +52 -0
- data/docs/api/yard/HTM/Database/Teardown.md +15 -0
- data/docs/api/yard/HTM/Database.md +58 -70
- data/docs/api/yard/HTM/DatabaseDocs.md +67 -0
- data/docs/api/yard/HTM/DatabaseError.md +6 -6
- data/docs/api/yard/HTM/Deletion.md +32 -0
- data/docs/api/yard/HTM/EmbeddingError.md +6 -6
- data/docs/api/yard/HTM/EmbeddingService.md +37 -38
- data/docs/api/yard/HTM/Epistemics.md +135 -0
- data/docs/api/yard/HTM/Error.md +6 -6
- data/docs/api/yard/HTM/EventTime.md +110 -0
- data/docs/api/yard/HTM/FileMemory.md +76 -0
- data/docs/api/yard/HTM/InputValidator.md +82 -0
- data/docs/api/yard/HTM/JobAdapter/Job.md +26 -0
- data/docs/api/yard/HTM/JobAdapter.md +35 -16
- data/docs/api/yard/HTM/Jobs/FailureLogging.md +14 -0
- data/docs/api/yard/HTM/Jobs/GenerateEmbeddingJob.md +16 -0
- data/docs/api/yard/HTM/Jobs/GeneratePropositionsJob.md +17 -0
- data/docs/api/yard/HTM/Jobs/GenerateRelationshipsJob.md +26 -0
- data/docs/api/yard/HTM/Jobs/GenerateTagsJob.md +17 -0
- data/docs/api/yard/HTM/Jobs/LlmCallTimer.md +58 -0
- data/docs/api/yard/HTM/Jobs/NodeLookup.md +14 -0
- data/docs/api/yard/HTM/Jobs.md +13 -0
- data/docs/api/yard/HTM/Loaders/ChunkSync/Chunk.md +22 -0
- data/docs/api/yard/HTM/Loaders/ChunkSync.md +50 -0
- data/docs/api/yard/HTM/Loaders/MarkdownChunker/Coalescer.md +24 -0
- data/docs/api/yard/HTM/Loaders/MarkdownChunker/Packer.md +20 -0
- data/docs/api/yard/HTM/Loaders/MarkdownChunker/Splitter.md +18 -0
- data/docs/api/yard/HTM/Loaders/MarkdownChunker.md +83 -0
- data/docs/api/yard/HTM/Loaders/MarkdownLoader/Document.md +43 -0
- data/docs/api/yard/HTM/Loaders/MarkdownLoader.md +62 -0
- data/docs/api/yard/HTM/Loaders.md +5 -0
- data/docs/api/yard/HTM/LongTermMemory/FulltextSearch.md +36 -0
- data/docs/api/yard/HTM/LongTermMemory/HybridSearch/RrfMerger.md +25 -0
- data/docs/api/yard/HTM/LongTermMemory/HybridSearch/RrfRows.md +30 -0
- data/docs/api/yard/HTM/LongTermMemory/HybridSearch/RrfSql/Query.md +79 -0
- data/docs/api/yard/HTM/LongTermMemory/HybridSearch/RrfSql/Source.md +45 -0
- data/docs/api/yard/HTM/LongTermMemory/HybridSearch/RrfSql.md +11 -0
- data/docs/api/yard/HTM/LongTermMemory/HybridSearch/TagDepth.md +52 -0
- data/docs/api/yard/HTM/LongTermMemory/HybridSearch.md +52 -0
- data/docs/api/yard/HTM/LongTermMemory/NodeOperations.md +95 -0
- data/docs/api/yard/HTM/LongTermMemory/RelevanceScorer/HierarchicalJaccard.md +58 -0
- data/docs/api/yard/HTM/LongTermMemory/RelevanceScorer/TagSearch.md +27 -0
- data/docs/api/yard/HTM/LongTermMemory/RelevanceScorer.md +81 -0
- data/docs/api/yard/HTM/LongTermMemory/RobotOperations.md +22 -0
- data/docs/api/yard/HTM/LongTermMemory/TagOperations/ExpiringValue.md +24 -0
- data/docs/api/yard/HTM/LongTermMemory/TagOperations/TagMatchSql.md +40 -0
- data/docs/api/yard/HTM/LongTermMemory/TagOperations.md +129 -0
- data/docs/api/yard/HTM/LongTermMemory/VectorSearch.md +30 -0
- data/docs/api/yard/HTM/LongTermMemory.md +279 -31
- data/docs/api/yard/HTM/MCP/AssembleContextTool.md +16 -0
- data/docs/api/yard/HTM/MCP/ClearGroupWorkingMemoryTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ClearWorkingMemoryTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ConfigResource.md +12 -0
- data/docs/api/yard/HTM/MCP/ConfirmTool.md +12 -0
- data/docs/api/yard/HTM/MCP/CreateGroupTool.md +12 -0
- data/docs/api/yard/HTM/MCP/EnrichPendingTool.md +16 -0
- data/docs/api/yard/HTM/MCP/ExtractPropositionsTool.md +12 -0
- data/docs/api/yard/HTM/MCP/FailoverTool.md +12 -0
- data/docs/api/yard/HTM/MCP/FileInfoTool.md +13 -0
- data/docs/api/yard/HTM/MCP/FileSourcesResource.md +12 -0
- data/docs/api/yard/HTM/MCP/FileSupport.md +7 -0
- data/docs/api/yard/HTM/MCP/FindByTopicTool.md +12 -0
- data/docs/api/yard/HTM/MCP/FirstMentionTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ForgetContentTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ForgetTool.md +12 -0
- data/docs/api/yard/HTM/MCP/GetGroupStatusTool.md +12 -0
- data/docs/api/yard/HTM/MCP/GetGroupWorkingMemoryTool.md +12 -0
- data/docs/api/yard/HTM/MCP/GetNodeTool.md +12 -0
- data/docs/api/yard/HTM/MCP/GetRobotTool.md +12 -0
- data/docs/api/yard/HTM/MCP/GetWorkingMemoryTool.md +12 -0
- data/docs/api/yard/HTM/MCP/GroupRecallTool.md +12 -0
- data/docs/api/yard/HTM/MCP/GroupRememberTool.md +12 -0
- data/docs/api/yard/HTM/MCP/GroupSession.md +23 -0
- data/docs/api/yard/HTM/MCP/JoinGroupTool.md +12 -0
- data/docs/api/yard/HTM/MCP/LeaveGroupTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ListDeletedTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ListFilesTool.md +13 -0
- data/docs/api/yard/HTM/MCP/ListGroupsTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ListRobotsTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ListTagsTool.md +12 -0
- data/docs/api/yard/HTM/MCP/LoadDirectoryTool.md +13 -0
- data/docs/api/yard/HTM/MCP/LoadFileTool.md +13 -0
- data/docs/api/yard/HTM/MCP/MemoryStatsResource.md +13 -0
- data/docs/api/yard/HTM/MCP/PopularTagsTool.md +12 -0
- data/docs/api/yard/HTM/MCP/PromoteRobotTool.md +12 -0
- data/docs/api/yard/HTM/MCP/PurgeDeletedTool.md +12 -0
- data/docs/api/yard/HTM/MCP/RecallTool.md +16 -0
- data/docs/api/yard/HTM/MCP/RecentMemoriesResource.md +13 -0
- data/docs/api/yard/HTM/MCP/RelatedNodesTool.md +12 -0
- data/docs/api/yard/HTM/MCP/RememberTool.md +12 -0
- data/docs/api/yard/HTM/MCP/RestoreTool.md +12 -0
- data/docs/api/yard/HTM/MCP/RobotGroupsResource.md +13 -0
- data/docs/api/yard/HTM/MCP/RobotTeamsStatusTool.md +13 -0
- data/docs/api/yard/HTM/MCP/RunRobotTeamsTool.md +13 -0
- data/docs/api/yard/HTM/MCP/SearchByTagsTool.md +16 -0
- data/docs/api/yard/HTM/MCP/SearchTagsTool.md +12 -0
- data/docs/api/yard/HTM/MCP/Server.md +37 -0
- data/docs/api/yard/HTM/MCP/Session.md +32 -0
- data/docs/api/yard/HTM/MCP/SetRobotTool.md +12 -0
- data/docs/api/yard/HTM/MCP/ShutdownGroupTool.md +12 -0
- data/docs/api/yard/HTM/MCP/StartupPromptResource.md +16 -0
- data/docs/api/yard/HTM/MCP/StatsTool.md +12 -0
- data/docs/api/yard/HTM/MCP/SyncFilesTool.md +13 -0
- data/docs/api/yard/HTM/MCP/SyncGroupTool.md +12 -0
- data/docs/api/yard/HTM/MCP/TagHierarchyResource.md +16 -0
- data/docs/api/yard/HTM/MCP/TagNodeTool.md +12 -0
- data/docs/api/yard/HTM/MCP/TagTreeTool.md +22 -0
- data/docs/api/yard/HTM/MCP/TeamNames.md +7 -0
- data/docs/api/yard/HTM/MCP/TimelineTool.md +12 -0
- data/docs/api/yard/HTM/MCP/Tool.md +24 -0
- data/docs/api/yard/HTM/MCP/ToolSupport.md +17 -0
- data/docs/api/yard/HTM/MCP/TopicRelationshipsTool.md +12 -0
- data/docs/api/yard/HTM/MCP/TransferWorkingMemoryTool.md +12 -0
- data/docs/api/yard/HTM/MCP/UnloadFileTool.md +13 -0
- data/docs/api/yard/HTM/MCP/UntagNodeTool.md +12 -0
- data/docs/api/yard/HTM/MCP.md +30 -0
- data/docs/api/yard/HTM/Migration.md +44 -0
- data/docs/api/yard/HTM/Models/FileSource.md +66 -0
- data/docs/api/yard/HTM/Models/Node/Scopes.md +74 -0
- data/docs/api/yard/HTM/Models/Node/SoftDeletion.md +22 -0
- data/docs/api/yard/HTM/Models/Node/VectorSimilarity.md +28 -0
- data/docs/api/yard/HTM/Models/Node.md +113 -0
- data/docs/api/yard/HTM/Models/NodeLink.md +65 -0
- data/docs/api/yard/HTM/Models/NodeRelationship.md +31 -0
- data/docs/api/yard/HTM/Models/NodeTag.md +38 -0
- data/docs/api/yard/HTM/Models/Robot.md +50 -0
- data/docs/api/yard/HTM/Models/RobotNode.md +35 -0
- data/docs/api/yard/HTM/Models/Tag/Scopes.md +32 -0
- data/docs/api/yard/HTM/Models/Tag.md +112 -0
- data/docs/api/yard/HTM/Models.md +5 -0
- data/docs/api/yard/HTM/NodeEnrichment.md +36 -0
- data/docs/api/yard/HTM/NodeView.md +113 -0
- data/docs/api/yard/HTM/NotFoundError.md +6 -5
- data/docs/api/yard/HTM/Observability.md +58 -40
- data/docs/api/yard/HTM/PropositionError.md +6 -6
- data/docs/api/yard/HTM/PropositionService.md +63 -29
- data/docs/api/yard/HTM/QueryCache/KeyNormalizer.md +25 -0
- data/docs/api/yard/HTM/QueryCache/NullStore.md +19 -0
- data/docs/api/yard/HTM/QueryCache/Store.md +43 -0
- data/docs/api/yard/HTM/QueryCache.md +41 -46
- data/docs/api/yard/HTM/QueryTimeoutError.md +9 -8
- data/docs/api/yard/HTM/Railtie.md +11 -7
- data/docs/api/yard/HTM/RecallQuery.md +111 -0
- data/docs/api/yard/HTM/ResourceExhaustedError.md +6 -6
- data/docs/api/yard/HTM/RobotGroup/CacheSync.md +35 -0
- data/docs/api/yard/HTM/RobotGroup/Membership.md +96 -0
- data/docs/api/yard/HTM/RobotGroup/TransferOptions.md +14 -0
- data/docs/api/yard/HTM/RobotGroup/WorkingMemoryLedger.md +65 -0
- data/docs/api/yard/HTM/RobotGroup.md +116 -360
- data/docs/api/yard/HTM/Robots/Actions/TagMove.md +31 -0
- data/docs/api/yard/HTM/Robots/Actions.md +153 -0
- data/docs/api/yard/HTM/Robots/Neighbors.md +20 -0
- data/docs/api/yard/HTM/Robots/Supervisor/Idler.md +26 -0
- data/docs/api/yard/HTM/Robots/Supervisor/Roster.md +26 -0
- data/docs/api/yard/HTM/Robots/Supervisor.md +42 -0
- data/docs/api/yard/HTM/Robots/Team.md +60 -0
- data/docs/api/yard/HTM/Robots/Teams/Archivist.md +43 -0
- data/docs/api/yard/HTM/Robots/Teams/Consolidator.md +29 -0
- data/docs/api/yard/HTM/Robots/Teams/ContradictionDetector.md +33 -0
- data/docs/api/yard/HTM/Robots/Teams/TagCurator.md +37 -0
- data/docs/api/yard/HTM/Robots/Teams.md +5 -0
- data/docs/api/yard/HTM/Robots/Tools/ArchiveNodes.md +12 -0
- data/docs/api/yard/HTM/Robots/Tools/Base.md +16 -0
- data/docs/api/yard/HTM/Robots/Tools/MergeNodes.md +12 -0
- data/docs/api/yard/HTM/Robots/Tools/MergeTags.md +12 -0
- data/docs/api/yard/HTM/Robots/Tools/Pass.md +12 -0
- data/docs/api/yard/HTM/Robots/Tools/RecordConflict.md +12 -0
- data/docs/api/yard/HTM/Robots/Tools/SupersedeNode.md +12 -0
- data/docs/api/yard/HTM/Robots/Tools.md +14 -0
- data/docs/api/yard/HTM/Robots.md +72 -0
- data/docs/api/yard/HTM/SearchFilters.md +82 -0
- data/docs/api/yard/HTM/SequelConfig.md +97 -0
- data/docs/api/yard/HTM/Settings.md +39 -0
- data/docs/api/yard/HTM/Sinatra/Helpers.md +37 -0
- data/docs/api/yard/HTM/Sinatra/Middleware.md +29 -0
- data/docs/api/yard/HTM/Sinatra.md +44 -0
- data/docs/api/yard/HTM/SqlBuilder/Sparsevec.md +69 -0
- data/docs/api/yard/HTM/SqlBuilder.md +62 -75
- data/docs/api/yard/HTM/StartupPrompt.md +45 -0
- data/docs/api/yard/HTM/TagError.md +6 -6
- data/docs/api/yard/HTM/TagService.md +100 -37
- data/docs/api/yard/HTM/TagTree/Branch.md +43 -0
- data/docs/api/yard/HTM/TagTree/SvgRenderer/Layout.md +51 -0
- data/docs/api/yard/HTM/TagTree/SvgRenderer.md +25 -0
- data/docs/api/yard/HTM/TagTree.md +65 -0
- data/docs/api/yard/HTM/Telemetry/NullInstrument.md +12 -9
- data/docs/api/yard/HTM/Telemetry/NullMeter.md +17 -9
- data/docs/api/yard/HTM/Telemetry.md +53 -50
- data/docs/api/yard/HTM/Timeframe/Result.md +13 -16
- data/docs/api/yard/HTM/Timeframe.md +17 -20
- data/docs/api/yard/HTM/TimeframeExtractor/Patterns.md +18 -0
- data/docs/api/yard/HTM/TimeframeExtractor/Result.md +13 -16
- data/docs/api/yard/HTM/TimeframeExtractor.md +27 -16
- data/docs/api/yard/HTM/Timeline.md +113 -0
- data/docs/api/yard/HTM/ValidationError.md +6 -5
- data/docs/api/yard/HTM/Workflows/RememberWorkflow/NodeState.md +73 -0
- data/docs/api/yard/HTM/Workflows/RememberWorkflow.md +80 -0
- data/docs/api/yard/HTM/Workflows.md +5 -0
- data/docs/api/yard/HTM/WorkingMemory/Entry.md +67 -0
- data/docs/api/yard/HTM/WorkingMemory/Store.md +54 -0
- data/docs/api/yard/HTM/WorkingMemory.md +113 -87
- data/docs/api/yard/HTM/WorkingMemoryChannel/Subscribers.md +28 -0
- data/docs/api/yard/HTM/WorkingMemoryChannel.md +108 -102
- data/docs/api/yard/HTM.md +483 -5
- data/docs/api/yard/README.md +211 -0
- data/docs/api/yard/Sinatra/Base.md +30 -0
- data/docs/api/yard/Sinatra.md +7 -0
- data/docs/api/yard/index.csv +1834 -181
- data/docs/api/yard-reference.md +228 -9
- data/docs/architecture/adrs/005-rag-retrieval.md +3 -0
- data/docs/architecture/adrs/index.md +1 -1
- data/docs/architecture/index.md +2 -2
- data/docs/architecture/overview.md +3 -3
- data/docs/assets/images/project-structure.svg +2 -2
- data/docs/database/INDEX.md +113 -0
- data/docs/database/README.md +60 -176
- data/docs/database/file_sources.md +51 -0
- data/docs/database/file_sources.svg +120 -0
- data/docs/database/naming-convention.md +12 -12
- data/docs/database/node_links.md +65 -0
- data/docs/database/node_links.svg +171 -0
- data/docs/database/node_relationships.md +62 -0
- data/docs/database/node_relationships.svg +124 -0
- data/docs/database/node_tags.md +50 -0
- data/docs/database/node_tags.svg +125 -0
- data/docs/database/nodes.md +120 -0
- data/docs/database/nodes.svg +394 -0
- data/docs/database/robot_nodes.md +57 -0
- data/docs/database/robot_nodes.svg +155 -0
- data/docs/database/robots.md +40 -0
- data/docs/database/robots.svg +131 -0
- data/docs/database/schema.svg +384 -275
- data/docs/database/schema_migrations.md +19 -0
- data/docs/database/schema_migrations.svg +31 -0
- data/docs/database/tags.md +47 -0
- data/docs/database/tags.svg +90 -0
- data/docs/development/asgard-tasks.md +114 -0
- data/docs/development/contributing.md +6 -6
- data/docs/development/index.md +15 -17
- data/docs/development/schema.md +43 -14
- data/docs/development/setup.md +60 -70
- data/docs/development/testing.md +57 -65
- data/docs/examples/basic-usage.md +9 -9
- data/docs/examples/config-files.md +8 -8
- data/docs/examples/file-loading.md +12 -12
- data/docs/examples/index.md +15 -8
- data/docs/examples/llm-configuration.md +13 -9
- data/docs/examples/mcp-client.md +61 -59
- data/docs/examples/rails-integration.md +5 -4
- data/docs/examples/sinatra-integration.md +5 -4
- data/docs/examples/standalone-app.md +17 -16
- data/docs/getting-started/index.md +3 -3
- data/docs/getting-started/installation.md +76 -83
- data/docs/getting-started/quick-start.md +24 -22
- data/docs/guides/adding-memories.md +14 -3
- data/docs/guides/cli.md +458 -0
- data/docs/guides/configuration.md +72 -37
- data/docs/guides/epistemic-status.md +138 -0
- data/docs/guides/event-time.md +106 -0
- data/docs/guides/file-loading.md +26 -22
- data/docs/guides/getting-started.md +21 -17
- data/docs/guides/long-term-memory.md +1 -1
- data/docs/guides/mcp-server.md +416 -173
- data/docs/guides/propositions.md +18 -29
- data/docs/guides/recalling-memories.md +22 -7
- data/docs/guides/robot-teams.md +96 -0
- data/docs/guides/search-strategies.md +10 -7
- data/docs/guides/tags.md +19 -19
- data/docs/guides/timeline.md +106 -0
- data/docs/index.md +7 -7
- data/docs/llms.txt +35 -0
- data/docs/multi_framework_support.md +13 -13
- data/docs/robots/robot-groups.md +9 -9
- data/docs/robots/two-tier-memory.md +13 -26
- data/docs/setup_local_database.md +33 -31
- data/examples/00_create_examples_db.rb +20 -7
- data/examples/01_basic_usage.rb +20 -18
- data/examples/02_config_file_example/README.md +13 -12
- data/examples/02_config_file_example/config/htm.local.yml +8 -8
- data/examples/02_config_file_example/show_config.rb +3 -4
- data/examples/03_custom_llm_configuration.rb +12 -12
- data/examples/04_file_loader_usage.rb +15 -21
- data/examples/05_timeframe_demo.rb +282 -234
- data/examples/06_example_app/.loki +36 -0
- data/examples/06_example_app/app.rb +21 -33
- data/examples/07_cli_app/README.md +18 -18
- data/examples/07_cli_app/htm_cli.rb +25 -19
- data/examples/08_sinatra_app/Gemfile +1 -0
- data/examples/08_sinatra_app/Gemfile.lock +101 -67
- data/examples/08_sinatra_app/app.rb +64 -62
- data/examples/09_mcp_client.rb +92 -119
- data/examples/10_telemetry/README.md +3 -3
- data/examples/10_telemetry/SETUP_README.md +2 -2
- data/examples/10_telemetry/demo.rb +5 -5
- data/examples/11_robot_groups/README.md +5 -4
- data/examples/11_robot_groups/lib/robot_worker.rb +0 -5
- data/examples/11_robot_groups/multi_process.rb +5 -4
- data/examples/11_robot_groups/same_process.rb +18 -17
- data/examples/12_rails_app/Gemfile +1 -1
- data/examples/12_rails_app/Gemfile.lock +146 -97
- data/examples/12_rails_app/README.md +21 -17
- data/examples/12_rails_app/app/controllers/chats_controller.rb +33 -63
- data/examples/12_rails_app/app/controllers/memories_controller.rb +7 -1
- data/examples/12_rails_app/app/controllers/messages_controller.rb +21 -58
- data/examples/12_rails_app/app/controllers/search_controller.rb +7 -2
- data/examples/12_rails_app/app/models/chat.rb +0 -33
- data/examples/12_rails_app/app/models/message.rb +0 -2
- data/examples/12_rails_app/app/views/chats/show.html.erb +2 -2
- data/examples/12_rails_app/app/views/files/new.html.erb +1 -1
- data/examples/12_rails_app/app/views/memories/_memory_card.html.erb +1 -1
- data/examples/12_rails_app/app/views/memories/new.html.erb +12 -0
- data/examples/12_rails_app/app/views/memories/show.html.erb +13 -0
- data/examples/12_rails_app/app/views/search/index.html.erb +18 -2
- data/examples/12_rails_app/config/initializers/ruby_llm.rb +11 -15
- data/examples/12_rails_app/db/migrate/20261205061932_create_ruby_llm_records.rb +160 -0
- data/examples/12_rails_app/db/migrate/20261205061933_create_chats.rb +13 -0
- data/examples/12_rails_app/db/migrate/20261205061934_create_messages.rb +23 -0
- data/examples/12_rails_app/db/schema.rb +163 -20
- data/examples/README.md +53 -44
- data/examples/examples_helper.rb +29 -5
- data/htm.gemspec +68 -0
- data/lib/htm/admin/database_commands.rb +454 -0
- data/lib/htm/admin/enrich_commands.rb +209 -0
- data/lib/htm/admin/file_commands.rb +323 -0
- data/lib/htm/admin/memory_commands/edit.rb +157 -0
- data/lib/htm/admin/memory_commands/search.rb +178 -0
- data/lib/htm/admin/memory_commands/tag_search.rb +98 -0
- data/lib/htm/admin/memory_commands/text.rb +164 -0
- data/lib/htm/admin/memory_commands/working_memory.rb +71 -0
- data/lib/htm/admin/memory_commands.rb +179 -0
- data/lib/htm/admin/tag_commands.rb +352 -0
- data/lib/htm/admin/tag_graph.rb +290 -0
- data/lib/htm/admin/templates/tag_graph.html +295 -0
- data/lib/htm/admin/yard_docs.rb +206 -0
- data/lib/htm/admin.rb +253 -0
- data/lib/htm/circuit_breaker.rb +142 -68
- data/lib/htm/class_methods.rb +136 -0
- data/lib/htm/cli/config_file.rb +86 -0
- data/lib/htm/cli/db.rb +77 -0
- data/lib/htm/cli/enrich.rb +44 -0
- data/lib/htm/cli/environment.rb +74 -0
- data/lib/htm/cli/error_suggestion.rb +97 -0
- data/lib/htm/cli/files.rb +41 -0
- data/lib/htm/cli/group.rb +32 -0
- data/lib/htm/cli/memory.rb +320 -0
- data/lib/htm/cli/memory_command.rb +71 -0
- data/lib/htm/cli/robots.rb +71 -0
- data/lib/htm/cli/support.rb +46 -0
- data/lib/htm/cli/tags.rb +103 -0
- data/lib/htm/cli/working_memory.rb +41 -0
- data/lib/htm/cli.rb +75 -0
- data/lib/htm/config/builder.rb +99 -68
- data/lib/htm/config/coercion.rb +91 -0
- data/lib/htm/config/database.rb +81 -52
- data/lib/htm/config/defaults.yml +52 -16
- data/lib/htm/config/readers.rb +85 -0
- data/lib/htm/config/ruby_llm_settings.rb +58 -0
- data/lib/htm/config/validator.rb +45 -26
- data/lib/htm/config.rb +112 -297
- data/lib/htm/database.rb +305 -396
- data/lib/htm/database_docs.rb +149 -0
- data/lib/htm/embedding_service.rb +26 -66
- data/lib/htm/epistemics.rb +254 -0
- data/lib/htm/errors.rb +4 -4
- data/lib/htm/event_time.rb +201 -0
- data/lib/htm/file_memory.rb +106 -0
- data/lib/htm/input_validator.rb +158 -0
- data/lib/htm/integrations/sinatra.rb +43 -31
- data/lib/htm/job_adapter.rb +78 -83
- data/lib/htm/jobs/failure_logging.rb +49 -0
- data/lib/htm/jobs/generate_embedding_job.rb +21 -28
- data/lib/htm/jobs/generate_propositions_job.rb +56 -28
- data/lib/htm/jobs/generate_relationships_job.rb +28 -24
- data/lib/htm/jobs/generate_tags_job.rb +32 -37
- data/lib/htm/jobs/llm_call_timer.rb +53 -0
- data/lib/htm/jobs/node_lookup.rb +27 -0
- data/lib/htm/knowledge_memory.rb +153 -0
- data/lib/htm/loaders/chunk_sync.rb +168 -0
- data/lib/htm/loaders/markdown_chunker.rb +207 -36
- data/lib/htm/loaders/markdown_loader.rb +76 -120
- data/lib/htm/long_term_memory/fulltext_search.rb +15 -36
- data/lib/htm/long_term_memory/hybrid_search.rb +471 -544
- data/lib/htm/long_term_memory/node_operations.rb +110 -81
- data/lib/htm/long_term_memory/relevance_scorer.rb +232 -237
- data/lib/htm/long_term_memory/tag_operations.rb +201 -130
- data/lib/htm/long_term_memory/vector_search.rb +33 -61
- data/lib/htm/long_term_memory.rb +5 -17
- data/lib/htm/mcp/file_tools.rb +190 -0
- data/lib/htm/mcp/group_tools.rb +223 -233
- data/lib/htm/mcp/node_tools.rb +350 -0
- data/lib/htm/mcp/resources.rb +102 -28
- data/lib/htm/mcp/robot_team_tools.rb +119 -0
- data/lib/htm/mcp/server.rb +26 -14
- data/lib/htm/mcp/tag_tools.rb +130 -0
- data/lib/htm/mcp/tool.rb +40 -0
- data/lib/htm/mcp/tool_support.rb +88 -0
- data/lib/htm/mcp/tools.rb +232 -283
- data/lib/htm/models/file_source.rb +35 -20
- data/lib/htm/models/node.rb +287 -193
- data/lib/htm/models/node_link.rb +97 -0
- data/lib/htm/models/node_relationship.rb +3 -2
- data/lib/htm/models/node_tag.rb +22 -2
- data/lib/htm/models/robot.rb +4 -8
- data/lib/htm/models/robot_node.rb +5 -2
- data/lib/htm/models/tag.rb +53 -207
- data/lib/htm/node_enrichment.rb +75 -0
- data/lib/htm/node_view.rb +295 -0
- data/lib/htm/observability.rb +114 -98
- data/lib/htm/proposition_service.rb +38 -74
- data/lib/htm/query_cache.rb +145 -91
- data/lib/htm/railtie.rb +3 -7
- data/lib/htm/request_options.rb +149 -0
- data/lib/htm/robot_group/cache_sync.rb +69 -0
- data/lib/htm/robot_group/membership.rb +147 -0
- data/lib/htm/robot_group/working_memory_ledger.rb +111 -0
- data/lib/htm/robot_group.rb +128 -521
- data/lib/htm/robots/actions.rb +371 -0
- data/lib/htm/robots/neighbors.rb +63 -0
- data/lib/htm/robots/node_brief.rb +49 -0
- data/lib/htm/robots/supervisor.rb +140 -0
- data/lib/htm/robots/team.rb +124 -0
- data/lib/htm/robots/teams/archivist.rb +88 -0
- data/lib/htm/robots/teams/consolidator.rb +52 -0
- data/lib/htm/robots/teams/contradiction_detector.rb +67 -0
- data/lib/htm/robots/teams/tag_curator.rb +75 -0
- data/lib/htm/robots/tools.rb +127 -0
- data/lib/htm/robots.rb +125 -0
- data/lib/htm/search_filters.rb +116 -0
- data/lib/htm/sequel_config.rb +95 -59
- data/lib/htm/sql_builder.rb +162 -53
- data/lib/htm/startup_prompt.rb +73 -0
- data/lib/htm/tag_service.rb +104 -109
- data/lib/htm/tag_tree.rb +206 -0
- data/lib/htm/telemetry.rb +15 -16
- data/lib/htm/timeframe.rb +27 -9
- data/lib/htm/timeframe_extractor.rb +77 -55
- data/lib/htm/timeline.rb +230 -0
- data/lib/htm/version.rb +1 -1
- data/lib/htm/workflows/remember_workflow.rb +145 -136
- data/lib/htm/working_memory/entry.rb +53 -0
- data/lib/htm/working_memory/store.rb +97 -0
- data/lib/htm/working_memory.rb +137 -139
- data/lib/htm/working_memory_channel.rb +90 -40
- data/lib/htm.rb +177 -501
- data/mkdocs.yml +100 -23
- data/scripts/install_local_database.sh +7 -6
- metadata +1032 -594
- data/.tbls.yml +0 -31
- data/Rakefile +0 -240
- data/bin/htm_mcp +0 -27
- data/docs/api/yard/HTM/ActiveRecordConfig.md +0 -29
- data/docs/api/yard/HTM/ConfigSection.md +0 -28
- data/docs/database/public.file_sources.md +0 -42
- data/docs/database/public.file_sources.svg +0 -219
- data/docs/database/public.node_stats.md +0 -48
- data/docs/database/public.node_stats.svg +0 -41
- data/docs/database/public.node_tags.md +0 -41
- data/docs/database/public.node_tags.svg +0 -251
- data/docs/database/public.nodes.md +0 -61
- data/docs/database/public.nodes.svg +0 -283
- data/docs/database/public.nodes_tags.md +0 -39
- data/docs/database/public.nodes_tags.svg +0 -112
- data/docs/database/public.ontology_structure.md +0 -48
- data/docs/database/public.ontology_structure.svg +0 -38
- data/docs/database/public.operations_log.md +0 -42
- data/docs/database/public.operations_log.svg +0 -130
- data/docs/database/public.relationships.md +0 -39
- data/docs/database/public.relationships.svg +0 -41
- data/docs/database/public.robot_activity.md +0 -46
- data/docs/database/public.robot_activity.svg +0 -35
- data/docs/database/public.robot_nodes.md +0 -48
- data/docs/database/public.robot_nodes.svg +0 -251
- data/docs/database/public.robots.md +0 -34
- data/docs/database/public.robots.svg +0 -165
- data/docs/database/public.schema_migrations.md +0 -29
- data/docs/database/public.schema_migrations.svg +0 -26
- data/docs/database/public.tags.md +0 -38
- data/docs/database/public.tags.svg +0 -147
- data/docs/database/public.topic_relationships.md +0 -45
- data/docs/database/public.topic_relationships.svg +0 -32
- data/docs/database/schema.json +0 -1814
- data/docs/database_rake_tasks.md +0 -345
- data/docs/development/rake-tasks.md +0 -1113
- data/docs/using_rake_tasks_in_your_app.md +0 -383
- data/examples/06_example_app/Rakefile +0 -71
- data/examples/12_rails_app/app/models/model.rb +0 -5
- data/examples/12_rails_app/app/models/tool_call.rb +0 -5
- data/examples/12_rails_app/db/migrate/20250124000001_create_ruby_llm_tables.rb +0 -34
- data/examples/12_rails_app/db/migrate/20250124000002_create_models_table.rb +0 -28
- data/lib/htm/mcp/cli.rb +0 -583
- data/lib/htm/tasks.rb +0 -79
- data/lib/tasks/db.rake +0 -15
- data/lib/tasks/doc.rake +0 -301
- data/lib/tasks/files.rake +0 -285
- data/lib/tasks/htm.rake +0 -703
- data/lib/tasks/jobs.rake +0 -429
- data/lib/tasks/tags.rake +0 -184
- data/scripts/backfill_parent_tags.rb +0 -376
- data/scripts/normalize_plural_tags.rb +0 -335
data/docs/api/yard/HTM.md
CHANGED
|
@@ -1,9 +1,487 @@
|
|
|
1
|
-
# Class
|
|
2
|
-
**Inherits:** Object
|
|
3
|
-
|
|
1
|
+
# Class HTM <a id="class-HTM"></a>
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
| | |
|
|
4
|
+
| --- | --- |
|
|
5
|
+
| **Inherits** | Object |
|
|
6
|
+
| **Includes** | [HTM::FileMemory](HTM/FileMemory.md) |
|
|
7
|
+
| **Defined in** | lib/htm.rb, lib/htm/cli.rb, lib/htm/admin.rb, lib/htm/cli/db.rb, lib/htm/config.rb, lib/htm/errors.rb, lib/htm/robots.rb, lib/htm/railtie.rb, lib/htm/version.rb, lib/htm/cli/tags.rb, lib/htm/database.rb, lib/htm/mcp/tool.rb, lib/htm/tag_tree.rb, lib/htm/timeline.rb, lib/htm/cli/files.rb, lib/htm/cli/group.rb, lib/htm/mcp/tools.rb, lib/htm/migration.rb, lib/htm/node_view.rb, lib/htm/telemetry.rb, lib/htm/timeframe.rb, lib/htm/cli/enrich.rb, lib/htm/cli/memory.rb, lib/htm/cli/robots.rb, lib/htm/epistemics.rb, lib/htm/event_time.rb, lib/htm/mcp/server.rb, lib/htm/models/tag.rb, lib/htm/cli/support.rb, lib/htm/file_memory.rb, lib/htm/job_adapter.rb, lib/htm/models/node.rb, lib/htm/query_cache.rb, lib/htm/robot_group.rb, lib/htm/robots/team.rb, lib/htm/sql_builder.rb, lib/htm/tag_service.rb, lib/htm/models/robot.rb, lib/htm/robots/tools.rb, lib/htm/class_methods.rb, lib/htm/database_docs.rb, lib/htm/mcp/resources.rb, lib/htm/mcp/tag_tools.rb, lib/htm/observability.rb, lib/htm/sequel_config.rb, lib/htm/config/builder.rb, lib/htm/config/readers.rb, lib/htm/mcp/file_tools.rb, lib/htm/mcp/node_tools.rb, lib/htm/robots/actions.rb, lib/htm/search_filters.rb, lib/htm/startup_prompt.rb, lib/htm/working_memory.rb, lib/htm/admin/tag_graph.rb, lib/htm/admin/yard_docs.rb, lib/htm/circuit_breaker.rb, lib/htm/cli/config_file.rb, lib/htm/cli/environment.rb, lib/htm/config/coercion.rb, lib/htm/config/database.rb, lib/htm/input_validator.rb, lib/htm/mcp/group_tools.rb, lib/htm/models/node_tag.rb, lib/htm/node_enrichment.rb, lib/htm/request_options.rb, lib/htm/config/validator.rb, lib/htm/jobs/node_lookup.rb, lib/htm/long_term_memory.rb, lib/htm/mcp/tool_support.rb, lib/htm/models/node_link.rb, lib/htm/robots/neighbors.rb, lib/htm/embedding_service.rb, lib/htm/models/robot_node.rb, lib/htm/robots/supervisor.rb, lib/htm/admin/tag_commands.rb, lib/htm/cli/memory_command.rb, lib/htm/cli/working_memory.rb, lib/htm/loaders/chunk_sync.rb, lib/htm/models/file_source.rb, lib/htm/admin/file_commands.rb, lib/htm/jobs/llm_call_timer.rb, lib/htm/proposition_service.rb, lib/htm/timeframe_extractor.rb, lib/htm/cli/error_suggestion.rb, lib/htm/integrations/sinatra.rb, lib/htm/jobs/failure_logging.rb, lib/htm/mcp/robot_team_tools.rb, lib/htm/working_memory/entry.rb, lib/htm/working_memory/store.rb, lib/htm/admin/enrich_commands.rb, lib/htm/admin/memory_commands.rb, lib/htm/jobs/generate_tags_job.rb, lib/htm/robot_group/cache_sync.rb, lib/htm/robot_group/membership.rb, lib/htm/robots/teams/archivist.rb, lib/htm/working_memory_channel.rb, lib/htm/admin/database_commands.rb, lib/htm/loaders/markdown_loader.rb, lib/htm/config/ruby_llm_settings.rb, lib/htm/loaders/markdown_chunker.rb, lib/htm/models/node_relationship.rb, lib/htm/robots/teams/tag_curator.rb, lib/htm/robots/teams/consolidator.rb, lib/htm/admin/memory_commands/edit.rb, lib/htm/jobs/generate_embedding_job.rb, lib/htm/workflows/remember_workflow.rb, lib/htm/admin/memory_commands/search.rb, lib/htm/jobs/generate_propositions_job.rb, lib/htm/long_term_memory/hybrid_search.rb, lib/htm/long_term_memory/vector_search.rb, lib/htm/jobs/generate_relationships_job.rb, lib/htm/long_term_memory/tag_operations.rb, lib/htm/admin/memory_commands/tag_search.rb, lib/htm/long_term_memory/fulltext_search.rb, lib/htm/long_term_memory/node_operations.rb, lib/htm/long_term_memory/relevance_scorer.rb, lib/htm/long_term_memory/robot_operations.rb, lib/htm/robot_group/working_memory_ledger.rb, lib/htm/robots/teams/contradiction_detector.rb, lib/htm/admin/memory_commands/working_memory.rb |
|
|
7
8
|
|
|
9
|
+
HTM (Hierarchical Temporal Memory): memory management for LLM robots (see
|
|
10
|
+
lib/htm.rb). This file adds its Sequel connection.
|
|
8
11
|
|
|
12
|
+
## Constants
|
|
13
|
+
### `MAX_ARRAY_SIZE` <a id="constant-MAX_ARRAY_SIZE"></a> <a id="MAX_ARRAY_SIZE-constant"></a>
|
|
14
|
+
Not documented.
|
|
9
15
|
|
|
16
|
+
### `MAX_KEY_LENGTH` <a id="constant-MAX_KEY_LENGTH"></a> <a id="MAX_KEY_LENGTH-constant"></a>
|
|
17
|
+
Validation constants
|
|
18
|
+
|
|
19
|
+
### `MAX_VALUE_LENGTH` <a id="constant-MAX_VALUE_LENGTH"></a> <a id="MAX_VALUE_LENGTH-constant"></a>
|
|
20
|
+
1MB
|
|
21
|
+
|
|
22
|
+
### `TRANSITIONS` <a id="constant-TRANSITIONS"></a> <a id="TRANSITIONS-constant"></a>
|
|
23
|
+
Kinds of change remember(supersedes:) and the contradiction detector record
|
|
24
|
+
|
|
25
|
+
### `VALID_RECALL_STRATEGIES` <a id="constant-VALID_RECALL_STRATEGIES"></a> <a id="VALID_RECALL_STRATEGIES-constant"></a>
|
|
26
|
+
Not documented.
|
|
27
|
+
|
|
28
|
+
### `VERSION` <a id="constant-VERSION"></a> <a id="VERSION-constant"></a>
|
|
29
|
+
Not documented.
|
|
30
|
+
|
|
31
|
+
## Attributes
|
|
32
|
+
### `long_term_memory` [R] <a id="attribute-i-long_term_memory"></a> <a id="long_term_memory-instance_method"></a>
|
|
33
|
+
Returns the value of attribute long_term_memory.
|
|
34
|
+
|
|
35
|
+
### `robot_id` [R] <a id="attribute-i-robot_id"></a> <a id="robot_id-instance_method"></a>
|
|
36
|
+
Returns the value of attribute robot_id.
|
|
37
|
+
|
|
38
|
+
### `robot_name` [R] <a id="attribute-i-robot_name"></a> <a id="robot_name-instance_method"></a>
|
|
39
|
+
Returns the value of attribute robot_name.
|
|
40
|
+
|
|
41
|
+
### `working_memory` [R] <a id="attribute-i-working_memory"></a> <a id="working_memory-instance_method"></a>
|
|
42
|
+
Returns the value of attribute working_memory.
|
|
43
|
+
|
|
44
|
+
## Public Class Methods
|
|
45
|
+
### `config()` <a id="method-c-config"></a> <a id="config-class_method"></a>
|
|
46
|
+
Get current configuration (singleton)
|
|
47
|
+
- **`@return`** [HTM::Config]
|
|
48
|
+
|
|
49
|
+
### `configure()` <a id="method-c-configure"></a> <a id="configure-class_method"></a>
|
|
50
|
+
Configure HTM
|
|
51
|
+
- **`@yield`** [config] Configuration object
|
|
52
|
+
- **`@yieldparam`** `config` [HTM::Config]
|
|
53
|
+
|
|
54
|
+
**@example Custom configuration**
|
|
55
|
+
```ruby
|
|
56
|
+
HTM.configure do |config|
|
|
57
|
+
config.embedding_generator = ->(text) { MyEmbedder.embed(text) }
|
|
58
|
+
config.tag_extractor = ->(text, ontology) { MyTagger.extract(text, ontology) }
|
|
59
|
+
end
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**@example Default configuration**
|
|
63
|
+
```ruby
|
|
64
|
+
HTM.configure # Uses RubyLLM defaults
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `count_tokens(text)` <a id="method-c-count_tokens"></a> <a id="count_tokens-class_method"></a>
|
|
68
|
+
Count tokens using configured counter
|
|
69
|
+
- **`@param`** `text` [String] Text to count tokens for
|
|
70
|
+
- **`@return`** [Integer] Token count
|
|
71
|
+
|
|
72
|
+
### `db()` <a id="method-c-db"></a> <a id="db-class_method"></a>
|
|
73
|
+
Convenience method to access the database connection
|
|
74
|
+
- **`@return`** [Sequel::Database]
|
|
75
|
+
|
|
76
|
+
### `development?()` <a id="method-c-development-3F"></a> <a id="development?-class_method"></a>
|
|
77
|
+
Check if running in development environment
|
|
78
|
+
- **`@return`** [Boolean]
|
|
79
|
+
|
|
80
|
+
### `embed(text)` <a id="method-c-embed"></a> <a id="embed-class_method"></a>
|
|
81
|
+
Generate embedding using EmbeddingService
|
|
82
|
+
- **`@param`** `text` [String] Text to embed
|
|
83
|
+
- **`@return`** [Array<Float>] Embedding vector as returned by the provider
|
|
84
|
+
|
|
85
|
+
### `env()` <a id="method-c-env"></a> <a id="env-class_method"></a>
|
|
86
|
+
Get current environment
|
|
87
|
+
- **`@return`** [String] Current environment name
|
|
88
|
+
|
|
89
|
+
### `extract_propositions(text)` <a id="method-c-extract_propositions"></a> <a id="extract_propositions-class_method"></a>
|
|
90
|
+
Extract propositions using PropositionService
|
|
91
|
+
- **`@param`** `text` [String] Text to analyze
|
|
92
|
+
- **`@return`** [Array<String>] Extracted atomic propositions
|
|
93
|
+
|
|
94
|
+
### `extract_tags(text, existing_ontology: [])` <a id="method-c-extract_tags"></a> <a id="extract_tags-class_method"></a>
|
|
95
|
+
Extract tags using TagService
|
|
96
|
+
- **`@param`** `text` [String] Text to analyze
|
|
97
|
+
- **`@param`** `existing_ontology` [Array<String>] Sample of existing tags for context
|
|
98
|
+
- **`@return`** [Array<String>] Extracted and validated tag names
|
|
99
|
+
|
|
100
|
+
### `logger()` <a id="method-c-logger"></a> <a id="logger-class_method"></a>
|
|
101
|
+
Get configured logger
|
|
102
|
+
- **`@return`** [Logger] Configured logger instance
|
|
103
|
+
|
|
104
|
+
### `production?()` <a id="method-c-production-3F"></a> <a id="production?-class_method"></a>
|
|
105
|
+
Check if running in production environment
|
|
106
|
+
- **`@return`** [Boolean]
|
|
107
|
+
|
|
108
|
+
### `reset_configuration!()` <a id="method-c-reset_configuration-21"></a> <a id="reset_configuration!-class_method"></a>
|
|
109
|
+
Reset configuration to defaults
|
|
110
|
+
|
|
111
|
+
### `startup_prompt(robot_name: nil, user: ENV.fetch('USER', nil), channel: :api)` <a id="method-c-startup_prompt"></a> <a id="startup_prompt-class_method"></a>
|
|
112
|
+
System prompt telling a robot how to use HTM as its long-term memory
|
|
113
|
+
- **`@param`** `robot_name` [String, nil] The robot's name
|
|
114
|
+
- **`@param`** `user` [String, nil] The person the robot works with (default: $USER)
|
|
115
|
+
- **`@param`** `channel` [Symbol] :api (Ruby) or :mcp (adds the MCP tool guidance)
|
|
116
|
+
- **`@return`** [String]
|
|
117
|
+
- **`@see`** `HTM::StartupPrompt`
|
|
118
|
+
|
|
119
|
+
### `test?()` <a id="method-c-test-3F"></a> <a id="test?-class_method"></a>
|
|
120
|
+
Check if running in test environment
|
|
121
|
+
- **`@return`** [Boolean]
|
|
122
|
+
|
|
123
|
+
## Public Instance Methods
|
|
124
|
+
### `clear_working_memory()` <a id="method-i-clear_working_memory"></a> <a id="clear_working_memory-instance_method"></a>
|
|
125
|
+
Clear all nodes from working memory
|
|
126
|
+
|
|
127
|
+
Marks all nodes as evicted from working memory (in database) and clears the
|
|
128
|
+
in-memory cache. Nodes remain in long-term memory.
|
|
129
|
+
- **`@return`** [Integer] Number of nodes cleared from working memory
|
|
130
|
+
|
|
131
|
+
**`@example`**
|
|
132
|
+
```ruby
|
|
133
|
+
htm.clear_working_memory # => 5
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### `confirm(node_id, evidence:, reason: nil, confidence: nil)` <a id="method-i-confirm"></a> <a id="confirm-instance_method"></a>
|
|
137
|
+
Confirm a memory: upgrade it to asserted on the strength of other memories.
|
|
138
|
+
Each evidence node gets a confirms link to it that keeps the status it had
|
|
139
|
+
before.
|
|
140
|
+
- **`@param`** `node_id` [Integer] the active node to confirm
|
|
141
|
+
- **`@param`** `evidence` [Integer, Array<Integer>] nodes that confirm it (at least one)
|
|
142
|
+
- **`@param`** `reason` [String, nil] why the evidence settles it
|
|
143
|
+
- **`@param`** `confidence` [Float, nil] the node's new confidence (unchanged when nil)
|
|
144
|
+
- **`@raise`** [ValidationError] without evidence, or for unknown evidence or a bad confidence
|
|
145
|
+
- **`@raise`** [NotFoundError] when the node is not active
|
|
146
|
+
- **`@return`** [Hash] { node_id:, epistemic_status:, prior_status:, confidence:, evidence: }
|
|
147
|
+
|
|
148
|
+
**`@example`**
|
|
149
|
+
```ruby
|
|
150
|
+
htm.confirm(88, evidence: 91, reason: "Alice said so herself")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `first_mention(topic, strategy: :fulltext, limit: 50, timeframe: nil)` <a id="method-i-first_mention"></a> <a id="first_mention-instance_method"></a>
|
|
154
|
+
When was something first mentioned, and can memory establish it?
|
|
155
|
+
|
|
156
|
+
Searches for `topic` and judges the matches: direct evidence is asserted or
|
|
157
|
+
extracted with a known event time, everything else is indirect. The first
|
|
158
|
+
mention is established only when no indirect evidence points earlier than the
|
|
159
|
+
earliest direct match.
|
|
160
|
+
- **`@param`** `topic` [String] what to look for
|
|
161
|
+
- **`@param`** `strategy` [Symbol] search strategy (:fulltext, :vector, :hybrid)
|
|
162
|
+
- **`@param`** `limit` [Integer] matches to judge at most
|
|
163
|
+
- **`@param`** `timeframe` [Object, nil] optional time filter (as for recall)
|
|
164
|
+
- **`@raise`** [ValidationError] for an empty topic or an invalid option
|
|
165
|
+
- **`@return`** [Hash] { topic:, established:, earliest_direct:, earlier_indirect:, earliest_known:, matches: }
|
|
166
|
+
(see HTM::Epistemics.first_mention)
|
|
167
|
+
|
|
168
|
+
**`@example`**
|
|
169
|
+
```ruby
|
|
170
|
+
answer = htm.first_mention("Alice moved to Berlin")
|
|
171
|
+
answer[:established] ? answer[:earliest_direct][:at] : answer[:earlier_indirect]
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### `forget(node_id, soft: true, confirm: nil)` <a id="method-i-forget"></a> <a id="forget-instance_method"></a>
|
|
175
|
+
Forget a memory node (soft delete by default, permanent delete requires
|
|
176
|
+
confirmation)
|
|
177
|
+
|
|
178
|
+
By default, performs a soft delete (sets deleted_at timestamp). The node
|
|
179
|
+
remains in the database but is excluded from queries. Use soft: false with
|
|
180
|
+
confirm: :confirmed for permanent deletion.
|
|
181
|
+
- **`@param`** `node_id` [Integer] ID of the node to delete
|
|
182
|
+
- **`@param`** `soft` [Boolean] If true (default), soft delete; if false, permanent delete
|
|
183
|
+
- **`@param`** `confirm` [Symbol] Must be :confirmed to proceed with permanent deletion
|
|
184
|
+
- **`@raise`** [HTM::ValidationError] if node_id is not a positive Integer
|
|
185
|
+
- **`@raise`** [ArgumentError] if permanent deletion requested without confirmation
|
|
186
|
+
- **`@raise`** [HTM::NotFoundError] if node doesn't exist
|
|
187
|
+
- **`@return`** [Boolean] true if deleted
|
|
188
|
+
|
|
189
|
+
**@example Soft delete (recoverable)**
|
|
190
|
+
```ruby
|
|
191
|
+
htm.forget(node_id)
|
|
192
|
+
htm.forget(node_id, soft: true)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**@example Permanent delete (requires confirmation)**
|
|
196
|
+
```ruby
|
|
197
|
+
htm.forget(node_id, soft: false, confirm: :confirmed)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### `forget_content(content_substring, soft: true, confirm: nil)` <a id="method-i-forget_content"></a> <a id="forget_content-instance_method"></a>
|
|
201
|
+
Forget all nodes whose content includes the given string
|
|
202
|
+
|
|
203
|
+
Performs a soft delete on all matching nodes. The nodes remain in the database
|
|
204
|
+
but are excluded from queries. Use case-insensitive LIKE matching.
|
|
205
|
+
- **`@param`** `content_substring` [String] Substring to search for in node content
|
|
206
|
+
- **`@param`** `soft` [Boolean] If true (default), soft delete; if false, permanent delete
|
|
207
|
+
- **`@param`** `confirm` [Symbol] Must be :confirmed to proceed with permanent deletion
|
|
208
|
+
- **`@raise`** [ArgumentError] if content_substring is blank
|
|
209
|
+
- **`@raise`** [ArgumentError] if permanent deletion requested without confirmation
|
|
210
|
+
- **`@return`** [Array<Integer>] Array of node IDs that were deleted
|
|
211
|
+
|
|
212
|
+
**@example Soft delete all nodes containing "deprecated"**
|
|
213
|
+
```ruby
|
|
214
|
+
htm.forget_content("deprecated")
|
|
215
|
+
# => [42, 56, 78] # IDs of deleted nodes
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**@example Permanent delete all nodes containing "test data"**
|
|
219
|
+
```ruby
|
|
220
|
+
htm.forget_content("test data", soft: false, confirm: :confirmed)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### `initialize(working_memory_size: 128_000, robot_name: nil, db_config: nil, db_cache_size: 1000, db_cache_ttl: 300)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
|
|
224
|
+
Initialize a new HTM instance
|
|
225
|
+
|
|
226
|
+
The connection pool and its session settings are shared by every HTM instance
|
|
227
|
+
in the process; set them with database.pool_size, database.timeout and
|
|
228
|
+
database.statement_timeout (HTM.configure or HTM_DATABASE__* env vars).
|
|
229
|
+
- **`@param`** `working_memory_size` [Integer] Maximum tokens for working memory
|
|
230
|
+
- **`@param`** `robot_name` [String, nil] Human-readable name for this robot (auto-generated if nil)
|
|
231
|
+
- **`@param`** `db_config` [Hash, nil] Database configuration (uses ENV['HTM_DATABASE__URL'] if nil)
|
|
232
|
+
- **`@param`** `db_cache_size` [Integer] Number of database query results to cache (0 disables)
|
|
233
|
+
- **`@param`** `db_cache_ttl` [Integer] Database cache TTL in seconds
|
|
234
|
+
- **`@return`** [HTM] a new instance of HTM
|
|
235
|
+
|
|
236
|
+
### `load_directory(path, pattern: '**/*.md', force: false)` <a id="method-i-load_directory"></a> <a id="load_directory-instance_method"></a>
|
|
237
|
+
Load all matching files from a directory into long-term memory
|
|
238
|
+
- **`@param`** `path` [String] Directory path
|
|
239
|
+
- **`@param`** `pattern` [String] Glob pattern
|
|
240
|
+
- **`@param`** `force` [Boolean] Force re-sync even if unchanged
|
|
241
|
+
- **`@return`** [Array<Hash>] Results for each file
|
|
242
|
+
|
|
243
|
+
**@example Load all markdown files recursively**
|
|
244
|
+
```ruby
|
|
245
|
+
results = htm.load_directory('/path/to/docs')
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**@example Load only top-level markdown files**
|
|
249
|
+
```ruby
|
|
250
|
+
results = htm.load_directory('/path/to/docs', pattern: '*.md')
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### `load_file(path, force: false)` <a id="method-i-load_file"></a> <a id="load_file-instance_method"></a>
|
|
254
|
+
Load a single file into long-term memory
|
|
255
|
+
|
|
256
|
+
Reads a text-based file (starting with markdown), chunks it by paragraph, and
|
|
257
|
+
stores each chunk as a node. YAML frontmatter is parsed and stored on the file
|
|
258
|
+
source (HTM::Models::FileSource#frontmatter), not in chunk text.
|
|
259
|
+
- **`@param`** `path` [String] Path to file
|
|
260
|
+
- **`@param`** `force` [Boolean] Force re-sync even if mtime unchanged
|
|
261
|
+
- **`@return`** [Hash] Result with keys:
|
|
262
|
+
- :file_path [String] Absolute path to file
|
|
263
|
+
- :chunks_created [Integer] Number of new chunks created
|
|
264
|
+
- :chunks_updated [Integer] Number of existing chunks updated
|
|
265
|
+
- :chunks_deleted [Integer] Number of chunks soft-deleted
|
|
266
|
+
- :skipped [Boolean] True if file was unchanged and skipped
|
|
267
|
+
|
|
268
|
+
**@example Load a markdown file**
|
|
269
|
+
```ruby
|
|
270
|
+
result = htm.load_file('/path/to/doc.md')
|
|
271
|
+
# => { file_path: '/path/to/doc.md', chunks_created: 5, ... }
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**@example Force re-sync even if unchanged**
|
|
275
|
+
```ruby
|
|
276
|
+
result = htm.load_file('/path/to/doc.md', force: true)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### `nodes_from_file(file_path)` <a id="method-i-nodes_from_file"></a> <a id="nodes_from_file-instance_method"></a>
|
|
280
|
+
Get all nodes loaded from a specific file
|
|
281
|
+
- **`@param`** `file_path` [String] Path to the source file
|
|
282
|
+
- **`@return`** [Array<HTM::Models::Node>] Nodes from this file, ordered by chunk_position
|
|
283
|
+
|
|
284
|
+
**`@example`**
|
|
285
|
+
```ruby
|
|
286
|
+
nodes = htm.nodes_from_file('/path/to/doc.md')
|
|
287
|
+
nodes.each { |node| puts node.content }
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### `purge_deleted(older_than:, confirm: nil)` <a id="method-i-purge_deleted"></a> <a id="purge_deleted-instance_method"></a>
|
|
291
|
+
Permanently delete all soft-deleted nodes older than specified time
|
|
292
|
+
- **`@param`** `older_than` [Time, ActiveSupport::Duration] Purge nodes soft-deleted before this time
|
|
293
|
+
- **`@param`** `confirm` [Symbol] Must be :confirmed to proceed
|
|
294
|
+
- **`@raise`** [ArgumentError] if confirmation not provided
|
|
295
|
+
- **`@return`** [Integer] Number of nodes permanently deleted
|
|
296
|
+
|
|
297
|
+
**@example Purge nodes deleted more than 30 days ago**
|
|
298
|
+
```ruby
|
|
299
|
+
htm.purge_deleted(older_than: 30.days.ago, confirm: :confirmed)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**@example Purge nodes deleted before a specific date**
|
|
303
|
+
```ruby
|
|
304
|
+
htm.purge_deleted(older_than: Time.new(2024, 1, 1), confirm: :confirmed)
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### `recall(topic, timeframe: nil, limit: 20, strategy: :fulltext, with_relevance: false, query_tags: [], raw: false, metadata: {}, time_axis: :event, as_of: nil, include_history: false, status: nil, min_confidence: nil)` <a id="method-i-recall"></a> <a id="recall-instance_method"></a>
|
|
308
|
+
Recall memories from a timeframe and topic
|
|
309
|
+
- **`@param`** `topic` [String] Topic to search for (required)
|
|
310
|
+
- **`@param`** `timeframe` [nil, Range, Array<Range>, Date, DateTime, Time, String, Symbol] Time filter
|
|
311
|
+
- nil: No time filter (search all memories)
|
|
312
|
+
- Range: Time range (e.g., 7.days.ago..Time.now)
|
|
313
|
+
- Array<Range>: Multiple time windows (OR'd together)
|
|
314
|
+
- Date: Entire day
|
|
315
|
+
- DateTime/Time: Entire day containing that moment
|
|
316
|
+
- String: Natural language (e.g., "last week", "few days ago")
|
|
317
|
+
- :auto: Extract timeframe from topic query automatically
|
|
318
|
+
- **`@param`** `limit` [Integer] Maximum number of nodes to retrieve (default: 20)
|
|
319
|
+
- **`@param`** `strategy` [Symbol] Search strategy (:vector, :fulltext, :hybrid) (default: :fulltext)
|
|
320
|
+
- **`@param`** `with_relevance` [Boolean] Include dynamic relevance scores (default: false)
|
|
321
|
+
- **`@param`** `query_tags` [Array<String>] Tags to boost relevance (default: [])
|
|
322
|
+
- **`@param`** `raw` [Boolean] Return full node hashes (true) or just content strings (false) (default: false)
|
|
323
|
+
- **`@param`** `metadata` [Hash] Filter by metadata fields using JSONB containment (default: {})
|
|
324
|
+
- **`@param`** `time_axis` [Symbol] Which time the timeframe reads: :event (default; when the
|
|
325
|
+
memory happened, matching any overlap with its span) or :recorded (when HTM stored it)
|
|
326
|
+
- **`@param`** `as_of` [Time, Date, String, nil] Only memories whose state was true at that moment
|
|
327
|
+
(valid_from/occurred_at at or before it, valid_until after it or unset)
|
|
328
|
+
- **`@param`** `include_history` [Boolean] Follow each match with the earlier states it replaced
|
|
329
|
+
- **`@param`** `status` [String, Symbol, Array, nil] Only memories with these epistemic statuses
|
|
330
|
+
(e.g. [:asserted, :extracted] for direct evidence only)
|
|
331
|
+
- **`@param`** `min_confidence` [Float, nil] Only memories at least this confident (unrated counts as 1.0)
|
|
332
|
+
- **`@raise`** [ValidationError] for an invalid option value
|
|
333
|
+
- **`@return`** [Array<String>, Array<Hash>] Content strings (raw: false) or full node hashes (raw: true);
|
|
334
|
+
raw hashes include 'epistemic_status', 'confidence', 'evidence' and 'conflicts'
|
|
335
|
+
|
|
336
|
+
**@example Basic usage - no time filter (returns content strings)**
|
|
337
|
+
```ruby
|
|
338
|
+
memories = htm.recall("PostgreSQL")
|
|
339
|
+
# => ["PostgreSQL is great for time-series data", "PostgreSQL with TimescaleDB..."]
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**@example With explicit timeframe**
|
|
343
|
+
```ruby
|
|
344
|
+
memories = htm.recall("PostgreSQL", timeframe: "last week")
|
|
345
|
+
memories = htm.recall("PostgreSQL", timeframe: Date.today)
|
|
346
|
+
memories = htm.recall("PostgreSQL", timeframe: 7.days.ago..Time.now)
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
**@example Auto-extract timeframe from query**
|
|
350
|
+
```ruby
|
|
351
|
+
memories = htm.recall("what did we discuss last week about PostgreSQL", timeframe: :auto)
|
|
352
|
+
# Extracts "last week" as timeframe, searches for "what did we discuss about PostgreSQL"
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**@example Multiple time windows**
|
|
356
|
+
```ruby
|
|
357
|
+
memories = htm.recall("meetings", timeframe: [last_monday, last_friday])
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**@example What was true at a moment**
|
|
361
|
+
```ruby
|
|
362
|
+
htm.recall("Alice lives in", as_of: "2025-01-01")
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
**@example When HTM recorded it, not when it happened**
|
|
366
|
+
```ruby
|
|
367
|
+
htm.recall("deploys", timeframe: "last week", time_axis: :recorded)
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**@example Filter by metadata**
|
|
371
|
+
```ruby
|
|
372
|
+
memories = htm.recall("preferences", metadata: { source: "user" })
|
|
373
|
+
memories = htm.recall("decisions", metadata: { type: "architectural" })
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**@example Direct evidence only**
|
|
377
|
+
```ruby
|
|
378
|
+
htm.recall("Alice", status: %i[asserted extracted], min_confidence: 0.8)
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### `remember(content, tags: [], metadata: {}, occurred_at: nil, occurred_until: nil, valid_from: nil, valid_until: nil, supersedes: nil, reason: nil, transition: nil, status: :asserted, confidence: nil, evidence: nil)` <a id="method-i-remember"></a> <a id="remember-instance_method"></a>
|
|
382
|
+
Remember new information
|
|
383
|
+
|
|
384
|
+
Stores content in long-term memory and adds it to working memory. Embeddings
|
|
385
|
+
and hierarchical tags are automatically extracted by LLM in the background.
|
|
386
|
+
- **`@param`** `content` [String] The information to remember (required, cannot be nil or empty)
|
|
387
|
+
- **`@param`** `tags` [Array<String>] Manual tags to assign (optional, in addition to auto-extracted tags)
|
|
388
|
+
- **`@param`** `metadata` [Hash] Arbitrary JSONB metadata
|
|
389
|
+
- **`@param`** `occurred_at` [Time, Date, String, nil] When the remembered event happened
|
|
390
|
+
(ISO8601 or natural language). Without it, HTM infers one from the content
|
|
391
|
+
("yesterday", "3 days ago", "March 3, 2025") when event_time.infer is on,
|
|
392
|
+
else uses the recording time.
|
|
393
|
+
- **`@param`** `occurred_until` [Time, Date, String, nil] End of the event, for a span
|
|
394
|
+
- **`@param`** `valid_from` [Time, Date, String, nil] When the stated state became true
|
|
395
|
+
(default: occurred_at)
|
|
396
|
+
- **`@param`** `valid_until` [Time, Date, String, nil] When the stated state stopped being true
|
|
397
|
+
- **`@param`** `supersedes` [Integer, Array<Integer>, nil] Active node(s) this memory replaces. Each
|
|
398
|
+
is retired (soft-deleted, its validity closed) and linked in the timeline, in the same
|
|
399
|
+
transaction as the new node.
|
|
400
|
+
- **`@param`** `reason` [String, nil] Why the superseded memories are wrong now
|
|
401
|
+
- **`@param`** `transition` [String, Symbol, nil] Kind of change: removed, restored or changed
|
|
402
|
+
- **`@param`** `status` [String, Symbol] How the content is known: asserted (default), extracted,
|
|
403
|
+
inferred or hypothesis. Applies to a new node only.
|
|
404
|
+
- **`@param`** `confidence` [Float, nil] Confidence in the content, 0.0 to 1.0. Applies to a new node only.
|
|
405
|
+
- **`@param`** `evidence` [Integer, Array<Integer>, nil] Node(s) the content rests on; each is linked
|
|
406
|
+
derived_from (also when the content was already stored)
|
|
407
|
+
- **`@raise`** [ValidationError] If content is nil, empty, or exceeds maximum size, a
|
|
408
|
+
superseded id is not an active node, an evidence id is unknown, or the status
|
|
409
|
+
or confidence is invalid
|
|
410
|
+
- **`@return`** [Integer] Database ID of the memory node
|
|
411
|
+
|
|
412
|
+
**@example Remember with source**
|
|
413
|
+
```ruby
|
|
414
|
+
node_id = htm.remember("PostgreSQL is great for HTM")
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**@example Remember with manual tags**
|
|
418
|
+
```ruby
|
|
419
|
+
node_id = htm.remember("Time-series data", tags: ["database:timescaledb"])
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**@example Remember with metadata**
|
|
423
|
+
```ruby
|
|
424
|
+
node_id = htm.remember("User prefers dark mode", metadata: { source: "user", confidence: 0.95 })
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
**@example Remember something that happened earlier**
|
|
428
|
+
```ruby
|
|
429
|
+
htm.remember("Deployed v2 to production", occurred_at: "2026-03-03")
|
|
430
|
+
htm.remember("Alice moved to Berlin", valid_from: "2025-06-01")
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**@example Replace an outdated memory, keeping it in the timeline**
|
|
434
|
+
```ruby
|
|
435
|
+
htm.remember("The API rate limit is 500 req/min", supersedes: 42,
|
|
436
|
+
reason: "limit lowered", transition: :changed)
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
**@example Record a conclusion and what it rests on**
|
|
440
|
+
```ruby
|
|
441
|
+
htm.remember("Alice probably moved to Berlin", status: :inferred, confidence: 0.6, evidence: [12, 15])
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### `restore(node_id)` <a id="method-i-restore"></a> <a id="restore-instance_method"></a>
|
|
445
|
+
Restore a soft-deleted memory node
|
|
446
|
+
- **`@param`** `node_id` [Integer] ID of the soft-deleted node to restore
|
|
447
|
+
- **`@raise`** [HTM::ValidationError] if node_id is not a positive Integer
|
|
448
|
+
- **`@raise`** [HTM::NotFoundError] if node doesn't exist or isn't deleted
|
|
449
|
+
- **`@return`** [Boolean] true if restored
|
|
450
|
+
|
|
451
|
+
**`@example`**
|
|
452
|
+
```ruby
|
|
453
|
+
htm.forget(node_id) # Soft delete
|
|
454
|
+
htm.restore(node_id) # Bring it back
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### `timeline(subject, strategy: :fulltext, limit: 5, max_depth: HTM::Timeline::MAX_DEPTH)` <a id="method-i-timeline"></a> <a id="timeline-instance_method"></a>
|
|
458
|
+
The history of a memory: the states it went through and the changes
|
|
459
|
+
(supersede, merge, archive) between them, oldest first
|
|
460
|
+
- **`@param`** `subject` [Integer, String] a node id (any node in the history,
|
|
461
|
+
retired or not) or a query whose top matches seed the histories
|
|
462
|
+
- **`@param`** `strategy` [Symbol] search strategy for a query (:fulltext, :vector, :hybrid)
|
|
463
|
+
- **`@param`** `limit` [Integer] matches to seed from for a query
|
|
464
|
+
- **`@param`** `max_depth` [Integer] links to follow at most from each seed
|
|
465
|
+
- **`@raise`** [ValidationError] for an empty subject or an invalid option
|
|
466
|
+
- **`@raise`** [NotFoundError] for an unknown node id
|
|
467
|
+
- **`@return`** [Array<Hash>] one { node_ids:, entries: } per distinct history;
|
|
468
|
+
entries are the states and transitions described in HTM::Timeline
|
|
469
|
+
|
|
470
|
+
**`@example`**
|
|
471
|
+
```ruby
|
|
472
|
+
htm.timeline("where does Alice live").first[:entries].each do |entry|
|
|
473
|
+
puts entry[:type] == 'state' ? entry[:content] : "-- #{entry[:transition]}: #{entry[:reason]}"
|
|
474
|
+
end
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### `unload_file(file_path)` <a id="method-i-unload_file"></a> <a id="unload_file-instance_method"></a>
|
|
478
|
+
Unload a file (soft-delete all its chunks and remove source record in one
|
|
479
|
+
transaction)
|
|
480
|
+
- **`@param`** `file_path` [String] Path to the source file
|
|
481
|
+
- **`@return`** [Integer] Number of nodes soft-deleted
|
|
482
|
+
|
|
483
|
+
**`@example`**
|
|
484
|
+
```ruby
|
|
485
|
+
count = htm.unload_file('/path/to/doc.md')
|
|
486
|
+
puts "Unloaded #{count} chunks"
|
|
487
|
+
```
|