Skip to content

Commit 1de92ac

Browse files
Merge pull request #35 from dreamer-coding/main
2 parents f534b39 + ff87896 commit 1de92ac

File tree

10 files changed

+1535
-145
lines changed

10 files changed

+1535
-145
lines changed

README.md

Lines changed: 18 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,26 @@
11
# ***Jellyfish AI Library by Fossil Logic***
22

3-
Jellyfish is a lightweight, portable AI library written in pure C with no external dependencies, purpose-built for embedded environments and trust-critical systems. Its architecture centers around transparent AI principles, using blockchain-inspired techniques to make all learning, memory, and reasoning fully auditable. Every interaction—input, decision, or output—is recorded as a cryptographically hashed block, creating an immutable, traceable chain of logic that preserves the system’s decision lineage. This enables developers to inspect exactly how and why the system reached a conclusion, down to the model, token, and rule used. The engine supports memory-based reasoning, adaptive learning from prior inputs, and automatic pruning of obsolete or conflicting knowledge, ensuring the system evolves without accumulating contradiction or noise. These features make Jellyfish a foundation for AI systems where verifiability, traceability, and long-term ethical transparency are non-negotiable.
4-
5-
## 🧠 `.jellyfish` File Example
6-
7-
This file defines a **Jellyfish mindset**, mapping named personalities to model chains (`.fish` files):
8-
9-
```ini
10-
model('core_logic') {
11-
description: 'Fundamental AI reasoning and logic modules'
12-
tags: ['core', 'logic', 'reasoning']
13-
models: ['logic.fish', 'nlp.fish', 'ethics.fish']
14-
priority: 1
15-
confidence_threshold: 0.75
16-
activation_condition: 'always'
17-
source_uri: 'https://fossillogic.ai/models/core_logic'
18-
origin_device_id: '00:1A:7D:DA:71:13'
19-
version: '1.0.0'
20-
content_hash: 'a3f5c7d89b4e1f23a567b9d0c1e2f3456789abcdef0123456789abcdef012345'
21-
created_at: 1689004800
22-
updated_at: 1689091200
23-
trust_score: 0.98
24-
immutable: 1
25-
state_machine: 'logic_state_v1'
26-
}
27-
28-
model('persona_trump') {
29-
description: 'Personality model for Donald Trump simulation'
30-
tags: ['persona', 'politics', 'simulation']
31-
models: ['trump_brain.fish', 'debate_logic.fish']
32-
priority: 5
33-
confidence_threshold: 0.6
34-
activation_condition: 'user_request == "trump_mode"'
35-
source_uri: 'https://fossillogic.ai/models/persona_trump'
36-
origin_device_id: '00:1B:44:11:3A:B7'
37-
version: '2.1.4'
38-
content_hash: 'b1a2c3d4e5f60718293a4b5c6d7e8f90123456789abcdef0123456789abcdef0'
39-
created_at: 1689000000
40-
updated_at: 1689050000
41-
trust_score: 0.85
42-
immutable: 0
43-
state_machine: 'persona_v2'
44-
}
45-
```
3+
Jellyfish is the core engine of Truthful Intelligence, a lightweight AI library written in pure C with no external dependencies. Designed for embedded and trust-critical systems, it records every input, output, and decision as a cryptographically hashed block, forming a fully auditable chain of reasoning. With support for adaptive learning, memory-based inference, and automatic pruning, Jellyfish ensures transparent, verifiable AI behavior where every conclusion is traceable to its source.
464

47-
* `mindset(name)` declares a named personality or capability.
48-
* `models` list refers to one or more `.fish` model files.
49-
* Optional attributes like `tags`, `priority`, and `activation_condition` allow selective and conditional loading.
50-
51-
---
52-
53-
## 🧠 `.fish` File Example
54-
55-
A `.fish` file stores learned associations (called *thought blocks*) in JSON format:
56-
57-
```json
58-
{
59-
"signature": "JFS1",
60-
"blocks": [
61-
{
62-
"input": "fire",
63-
"output": "hot",
64-
"hash": "b1946ac92492d2347c6235b4d2611184",
65-
"timestamp": 1620000000,
66-
"delta_ms": 0,
67-
"duration_ms": 12,
68-
"valid": 1,
69-
"confidence": 0.98,
70-
"usage_count": 5,
71-
"device_id": "a1b2c3d4e5f6a7b8",
72-
"signature": "00112233445566778899aabbccddeeff"
73-
},
74-
{
75-
"input": "ice",
76-
"output": "cold",
77-
"hash": "e4da3b7fbbce2345d7772b0674a318d5",
78-
"timestamp": 1620001000,
79-
"delta_ms": 1000,
80-
"duration_ms": 10,
81-
"valid": 1,
82-
"confidence": 0.95,
83-
"usage_count": 3,
84-
"device_id": "a1b2c3d4e5f6a7b8",
85-
"signature": "00112233445566778899aabbccddeeff"
86-
},
87-
{
88-
"input": "wind",
89-
"output": "fast",
90-
"hash": "1679091c5a880faf6fb5e6087eb1b2dc",
91-
"timestamp": 1620002000,
92-
"delta_ms": 1000,
93-
"duration_ms": 8,
94-
"valid": 1,
95-
"confidence": 0.92,
96-
"usage_count": 2,
97-
"device_id": "a1b2c3d4e5f6a7b8",
98-
"signature": "00112233445566778899aabbccddeeff"
99-
}
100-
]
101-
}
102-
```
5+
### Key Features
6+
7+
- **Cross-Platform**
8+
Runs reliably on Windows, macOS, Linux, and embedded systems.
9+
10+
- **Zero Dependencies**
11+
Written entirely in pure C for maximum portability, auditability, and minimal footprint.
12+
13+
- **Blockchain-Inspired Memory**
14+
Every input, output, and decision is stored as a cryptographically hashed block, creating a tamper-resistant, traceable chain of logic.
10315

104-
* `signature`: Identifies the file format version (`JFS1`).
105-
* Each `block` represents a learned input → output association, optionally timestamped for ordering or pruning.
16+
- **Self-Pruning Engine**
17+
Automatically removes obsolete or conflicting data, preserving clarity and consistency over time.
10618

107-
## Key Features
19+
- **Fully Auditable Reasoning**
20+
Supports forensic-level inspection of every decision, enabling ethical and transparent AI behavior.
10821

109-
- **Cross-Platform**: Runs consistently on Windows, macOS, and Linux.
110-
- **No External Dependencies**: Written in pure C for maximum portability and minimal footprint.
111-
- **Blockchain-Inspired Memory**: Stores each interaction as a cryptographically hashed block, forming a tamper-resistant chain for transparent and verifiable learning.
112-
- **Self-Pruning**: Automatically removes outdated or irrelevant data to maintain efficiency.
113-
- **Traceable Reasoning**: Every decision and memory is auditable, supporting trust-critical applications.
114-
- **Configurable and Modular**: Easily tailored for embedded, desktop, or custom AI projects.
22+
- **Modular and Configurable**
23+
Built to be embedded, extended, or customized for Truthful Intelligence applications across any platform.
11524

11625
## Prerequisites
11726

@@ -139,7 +48,7 @@ To get started with Jellyfish, ensure you have the following installed:
13948
# ======================
14049
[wrap-git]
14150
url = https://github.com/fossillogic/fossil-jellyfish.git
142-
revision = v0.1.1
51+
revision = v0.1.2
14352

14453
[provide]
14554
fossil-jellyfish = fossil_fish_dep

code/logic/fossil/ai/framework.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@
1515
#define FOSSIL_JELLYFISH_AI_FRAMEWORK_H
1616

1717
#include "jellyfish.h"
18+
#include "iochat.h"
19+
#include "language.h"
1820

1921
#endif /* FOSSIL_JELLYFISH_AI_FRAMEWORK_H */

code/logic/fossil/ai/iochat.h

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
* -----------------------------------------------------------------------------
3+
* Project: Fossil Logic
4+
*
5+
* This file is part of the Fossil Logic project, which aims to develop high-
6+
* performance, cross-platform applications and libraries. The code contained
7+
* herein is subject to the terms and conditions defined in the project license.
8+
*
9+
* Author: Michael Gene Brockus (Dreamer)
10+
*
11+
* Copyright (C) 2024 Fossil Logic. All rights reserved.
12+
* -----------------------------------------------------------------------------
13+
*/
14+
#ifndef FOSSIL_JELLYFISH_IOCHAT_H
15+
#define FOSSIL_JELLYFISH_IOCHAT_H
16+
17+
#include "jellyfish.h"
18+
19+
#ifdef __cplusplus
20+
extern "C"
21+
{
22+
#endif
23+
24+
// *****************************************************************************
25+
// Function prototypes
26+
// *****************************************************************************
27+
28+
/**
29+
* @brief Starts a new conversation session.
30+
*
31+
* Initializes a context for handling multi-turn dialogue.
32+
*
33+
* @param context_name Optional name for the context/session.
34+
* @return 0 on success, non-zero on failure.
35+
*/
36+
int fossil_io_chat_start(const char *context_name, fossil_jellyfish_chain *chain);
37+
38+
/**
39+
* @brief Processes a user input and generates a chatbot response.
40+
*
41+
* Leverages the Jellyfish memory chain to reason about the input.
42+
*
43+
* @param chain Pointer to Jellyfish chain.
44+
* @param input User input string.
45+
* @param output Output buffer to receive response.
46+
* @param size Size of output buffer.
47+
* @return 0 if response found, -1 if unknown.
48+
*/
49+
int fossil_io_chat_respond(fossil_jellyfish_chain *chain, const char *input, char *output, size_t size);
50+
51+
/**
52+
* @brief Ends the current conversation session and performs cleanup.
53+
*
54+
* Frees temporary memory, flushes session logs, or persists updates.
55+
*
56+
* @return 0 on success.
57+
*/
58+
int fossil_io_chat_end(fossil_jellyfish_chain *chain);
59+
60+
/**
61+
* @brief Injects a system message into the chain (e.g. "Hello", "System Ready").
62+
*
63+
* System messages are logged as immutable memory blocks with device signature.
64+
*
65+
* @param chain Jellyfish chain.
66+
* @param message System-level message.
67+
* @return 0 on success.
68+
*/
69+
int fossil_io_chat_inject_system_message(fossil_jellyfish_chain *chain, const char *message);
70+
71+
/**
72+
* @brief Appends a chatbot-generated response to the chain memory.
73+
*
74+
* Treats this as a new output associated with the latest user input.
75+
*
76+
* @param chain Chain to add memory to.
77+
* @param input Original user input.
78+
* @param output Chatbot response to learn.
79+
* @return 0 on success.
80+
*/
81+
int fossil_io_chat_learn_response(fossil_jellyfish_chain *chain, const char *input, const char *output);
82+
83+
/**
84+
* @brief Returns the number of conversational turns remembered.
85+
*
86+
* @param chain Jellyfish chain.
87+
* @return Number of user-input/output pairs.
88+
*/
89+
int fossil_io_chat_turn_count(const fossil_jellyfish_chain *chain);
90+
91+
/**
92+
* @brief Summarizes the session into a concise text form.
93+
*
94+
* This scans the chat blocks and returns a summary paragraph based on user turns.
95+
*
96+
* @param chain Jellyfish chain to summarize.
97+
* @param summary Output buffer to store summary.
98+
* @param size Size of the output buffer.
99+
* @return 0 on success, -1 if summary couldn't be generated.
100+
*/
101+
int fossil_io_chat_summarize_session(const fossil_jellyfish_chain *chain, char *summary, size_t size);
102+
103+
/**
104+
* @brief Filters the most recent N turns into a temporary sub-chain.
105+
*
106+
* Useful for generating context-limited decisions.
107+
*
108+
* @param chain Original chat chain.
109+
* @param out_chain Output chain filled with most recent turns.
110+
* @param turn_count Number of recent user turns to include.
111+
* @return 0 on success.
112+
*/
113+
int fossil_io_chat_filter_recent(const fossil_jellyfish_chain *chain, fossil_jellyfish_chain *out_chain, int turn_count);
114+
115+
/**
116+
* @brief Exports the current conversation history to a text file.
117+
*
118+
* @param chain Chain to serialize.
119+
* @param filepath Destination path for output.
120+
* @return 0 on success, -1 on error.
121+
*/
122+
int fossil_io_chat_export_history(const fossil_jellyfish_chain *chain, const char *filepath);
123+
124+
/**
125+
* @brief Imports a context file and loads it into the chain.
126+
*
127+
* Useful for bootstrapping or restoring previous sessions.
128+
*
129+
* @param chain Destination Jellyfish chain.
130+
* @param filepath Source path of saved context.
131+
* @return 0 on success, -1 if parsing fails.
132+
*/
133+
int fossil_io_chat_import_context(fossil_jellyfish_chain *chain, const char *filepath);
134+
135+
#ifdef __cplusplus
136+
}
137+
#include <stdexcept>
138+
#include <vector>
139+
#include <string>
140+
141+
namespace fossil {
142+
143+
namespace ai {
144+
145+
146+
147+
} // namespace ai
148+
149+
} // namespace fossil
150+
151+
#endif
152+
153+
#endif /* fossil_fish_FRAMEWORK_H */

0 commit comments

Comments
 (0)