Fix memory-service: remove manual id assignment for auto-increment PK

This commit is contained in:
JC Beasley
2026-07-04 17:05:27 -07:00
parent cb5e26b561
commit 93b21a8164
10 changed files with 186 additions and 19 deletions
+4 -16
View File
@@ -55,7 +55,6 @@ class MemoryService {
const payload = {
type: 'correction',
id: correction.id,
pattern: correction.pattern,
exclude_pattern: correction.excludePattern || null,
severity: correction.severity,
@@ -65,9 +64,7 @@ class MemoryService {
auto_detected: correction.autoDetected || true,
manual_entry: correction.manualEntry || false,
hit_count: 0,
context: correction.context || 'unknown',
created_at: new Date().toISOString(),
updated_at: new Date().toISOString()
context: correction.context || 'unknown'
};
const response = await client.post('/records', payload);
@@ -139,16 +136,13 @@ class MemoryService {
const payload = {
type: 'preference',
id: pref.id,
category: pref.category,
key: pref.key,
value: pref.value,
importance: pref.importance || 5,
confidence: pref.confidence || 1.0,
tags: JSON.stringify(pref.tags || []),
confirmed_count: pref.confirmedCount || 0,
created_at: new Date().toISOString(),
updated_at: new Date().toISOString()
confirmed_count: pref.confirmedCount || 0
};
const response = await client.post('/records', payload);
@@ -183,14 +177,12 @@ class MemoryService {
const payload = {
type: 'episode',
id: episode.id,
date: episode.date || new Date().toISOString().split('T')[0],
summary: episode.summary,
details: episode.details,
project: episode.project,
outcomes: JSON.stringify(episode.outcomes || []),
corrections_triggered: JSON.stringify(episode.correctionsTriggered || []),
created_at: new Date().toISOString()
corrections_triggered: JSON.stringify(episode.correctionsTriggered || [])
};
const response = await client.post('/records', payload);
@@ -226,14 +218,12 @@ class MemoryService {
const payload = {
type: 'decision',
id: decision.id,
date: decision.date || new Date().toISOString().split('T')[0],
project: decision.project,
decision: decision.decision,
alternatives: JSON.stringify(decision.alternatives || []),
rationale: decision.rationale,
status: decision.status || 'active',
created_at: new Date().toISOString()
status: decision.status || 'active'
};
const response = await client.post('/records', payload);
@@ -271,9 +261,7 @@ class MemoryService {
const payload = {
type: 'validation',
id: run.id,
session_id: run.sessionId,
timestamp: new Date().toISOString(),
input_length: run.inputLength,
output_length: run.outputLength,
violations_found: run.violationsFound || 0,
-3
View File
@@ -33,7 +33,6 @@ async function test() {
console.log('\n2. Testing correction storage...');
try {
const correction = await memory.storeCorrection({
id: `correction_${Date.now()}`,
pattern: '\\d+\\s*(%|percent)',
severity: 'auto-correct',
message: 'Quantitative claim requires evidence',
@@ -61,7 +60,6 @@ async function test() {
console.log('\n4. Testing preference storage...');
try {
const pref = await memory.storePreference({
id: `pref_${Date.now()}`,
category: 'communication',
key: 'format',
value: 'concise',
@@ -87,7 +85,6 @@ async function test() {
console.log('\n6. Testing validation logging...');
try {
await memory.logValidation({
id: `run_${Date.now()}`,
sessionId: 'test-session',
inputLength: 100,
outputLength: 200,
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
echo "Getting colOptions..."
curl -s "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc/colOptions" \
-H "xc-token: $NOCODB_TOKEN" | jq '.'
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
# Get tokens
VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
echo "Updating severity column..."
# Update severity column (ID: cv1al80v3ejvij0)
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cv1al80v3ejvij0" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dtxp": "error,warning,auto-correct",
"meta": {
"options": [
{"title": "error", "color": "#FF0000"},
{"title": "warning", "color": "#FFA500"},
{"title": "auto-correct", "color": "#FFFF00"}
]
}
}'
echo ""
echo "Updating status column..."
# Update status column (ID: cxbxnyh03nkvd0a)
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dtxp": "active,reversed,deprecated",
"meta": {
"options": [
{"title": "active", "color": "#00FF00"},
{"title": "reversed", "color": "#FFA500"},
{"title": "deprecated", "color": "#808080"}
]
}
}'
echo ""
echo "Done!"
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
echo "Updating status column..."
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{"dtxp":"active,reversed,deprecated","meta":{"options":[{"title":"active","color":"#00FF00"},{"title":"reversed","color":"#FFA500"},{"title":"deprecated","color":"#808080"}]}}'
echo ""
echo "Done!"
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
# Get tokens
VAULT_TOKEN=*** -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=*** -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
echo "Updating status column (ID: cxbxnyh03nkvd0a)..."
# Update status column with proper options
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dtxp": "active,reversed,deprecated",
"meta": {
"options": [
{"title": "active", "color": "#00FF00"},
{"title": "reversed", "color": "#FFA500"},
{"title": "deprecated", "color": "#808080"}
]
}
}' | jq -c '{id: .id, title: .title, meta: .meta}'
echo ""
echo "Done!"
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
echo "Fixing type column options (ID: ctkqqemeblx80cc)..."
# Update type column with proper dtxp format
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dtxp": "correction,preference,episode,decision,validation"
}'
echo ""
echo "Done!"
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
echo "Getting current column config..."
# Get current column
curl -s "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
-H "xc-token: $NOCODB_TOKEN" | jq '.colOptions'
echo ""
echo "Updating colOptions for type column..."
# Update colOptions via the options endpoint
curl -s -X POST "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc/colOptions/options" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"options": [
{"title": "correction", "color": "#FF0000"},
{"title": "preference", "color": "#00FF00"},
{"title": "episode", "color": "#0000FF"},
{"title": "decision", "color": "#FFFF00"},
{"title": "validation", "color": "#FF00FF"}
]
}'
echo ""
echo "Done!"
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
echo "Patching type column with dtxp..."
# Patch the column with proper enum values in dtxp
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dtxp": "'"'"'correction'"'"','"'"'preference'"'"','"'"'episode'"'"','"'"'decision'"'"','"'"'validation'"'"'"
}'
echo ""
echo "Done!"
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
echo "Deleting type column..."
# Delete the type column
curl -s -X DELETE "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
-H "xc-token: $NOCODB_TOKEN"
echo ""
echo "Recreating type column with options..."
# Create new SingleSelect column with options
curl -s -X POST "http://192.168.25.5:8080/api/v2/meta/tables/mx149yctebfwvys/columns" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"column_name": "type",
"title": "type",
"uidt": "SingleSelect",
"dtxp": "correction,preference,episode,decision,validation"
}'
echo ""
echo "Done!"