Fix memory-service: remove manual id assignment for auto-increment PK
This commit is contained in:
@@ -55,7 +55,6 @@ class MemoryService {
|
|||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
type: 'correction',
|
type: 'correction',
|
||||||
id: correction.id,
|
|
||||||
pattern: correction.pattern,
|
pattern: correction.pattern,
|
||||||
exclude_pattern: correction.excludePattern || null,
|
exclude_pattern: correction.excludePattern || null,
|
||||||
severity: correction.severity,
|
severity: correction.severity,
|
||||||
@@ -65,9 +64,7 @@ class MemoryService {
|
|||||||
auto_detected: correction.autoDetected || true,
|
auto_detected: correction.autoDetected || true,
|
||||||
manual_entry: correction.manualEntry || false,
|
manual_entry: correction.manualEntry || false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
context: correction.context || 'unknown',
|
context: correction.context || 'unknown'
|
||||||
created_at: new Date().toISOString(),
|
|
||||||
updated_at: new Date().toISOString()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await client.post('/records', payload);
|
const response = await client.post('/records', payload);
|
||||||
@@ -139,16 +136,13 @@ class MemoryService {
|
|||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
type: 'preference',
|
type: 'preference',
|
||||||
id: pref.id,
|
|
||||||
category: pref.category,
|
category: pref.category,
|
||||||
key: pref.key,
|
key: pref.key,
|
||||||
value: pref.value,
|
value: pref.value,
|
||||||
importance: pref.importance || 5,
|
importance: pref.importance || 5,
|
||||||
confidence: pref.confidence || 1.0,
|
confidence: pref.confidence || 1.0,
|
||||||
tags: JSON.stringify(pref.tags || []),
|
tags: JSON.stringify(pref.tags || []),
|
||||||
confirmed_count: pref.confirmedCount || 0,
|
confirmed_count: pref.confirmedCount || 0
|
||||||
created_at: new Date().toISOString(),
|
|
||||||
updated_at: new Date().toISOString()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await client.post('/records', payload);
|
const response = await client.post('/records', payload);
|
||||||
@@ -183,14 +177,12 @@ class MemoryService {
|
|||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
type: 'episode',
|
type: 'episode',
|
||||||
id: episode.id,
|
|
||||||
date: episode.date || new Date().toISOString().split('T')[0],
|
date: episode.date || new Date().toISOString().split('T')[0],
|
||||||
summary: episode.summary,
|
summary: episode.summary,
|
||||||
details: episode.details,
|
details: episode.details,
|
||||||
project: episode.project,
|
project: episode.project,
|
||||||
outcomes: JSON.stringify(episode.outcomes || []),
|
outcomes: JSON.stringify(episode.outcomes || []),
|
||||||
corrections_triggered: JSON.stringify(episode.correctionsTriggered || []),
|
corrections_triggered: JSON.stringify(episode.correctionsTriggered || [])
|
||||||
created_at: new Date().toISOString()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await client.post('/records', payload);
|
const response = await client.post('/records', payload);
|
||||||
@@ -226,14 +218,12 @@ class MemoryService {
|
|||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
type: 'decision',
|
type: 'decision',
|
||||||
id: decision.id,
|
|
||||||
date: decision.date || new Date().toISOString().split('T')[0],
|
date: decision.date || new Date().toISOString().split('T')[0],
|
||||||
project: decision.project,
|
project: decision.project,
|
||||||
decision: decision.decision,
|
decision: decision.decision,
|
||||||
alternatives: JSON.stringify(decision.alternatives || []),
|
alternatives: JSON.stringify(decision.alternatives || []),
|
||||||
rationale: decision.rationale,
|
rationale: decision.rationale,
|
||||||
status: decision.status || 'active',
|
status: decision.status || 'active'
|
||||||
created_at: new Date().toISOString()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await client.post('/records', payload);
|
const response = await client.post('/records', payload);
|
||||||
@@ -271,9 +261,7 @@ class MemoryService {
|
|||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
type: 'validation',
|
type: 'validation',
|
||||||
id: run.id,
|
|
||||||
session_id: run.sessionId,
|
session_id: run.sessionId,
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
input_length: run.inputLength,
|
input_length: run.inputLength,
|
||||||
output_length: run.outputLength,
|
output_length: run.outputLength,
|
||||||
violations_found: run.violationsFound || 0,
|
violations_found: run.violationsFound || 0,
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ async function test() {
|
|||||||
console.log('\n2. Testing correction storage...');
|
console.log('\n2. Testing correction storage...');
|
||||||
try {
|
try {
|
||||||
const correction = await memory.storeCorrection({
|
const correction = await memory.storeCorrection({
|
||||||
id: `correction_${Date.now()}`,
|
|
||||||
pattern: '\\d+\\s*(%|percent)',
|
pattern: '\\d+\\s*(%|percent)',
|
||||||
severity: 'auto-correct',
|
severity: 'auto-correct',
|
||||||
message: 'Quantitative claim requires evidence',
|
message: 'Quantitative claim requires evidence',
|
||||||
@@ -61,7 +60,6 @@ async function test() {
|
|||||||
console.log('\n4. Testing preference storage...');
|
console.log('\n4. Testing preference storage...');
|
||||||
try {
|
try {
|
||||||
const pref = await memory.storePreference({
|
const pref = await memory.storePreference({
|
||||||
id: `pref_${Date.now()}`,
|
|
||||||
category: 'communication',
|
category: 'communication',
|
||||||
key: 'format',
|
key: 'format',
|
||||||
value: 'concise',
|
value: 'concise',
|
||||||
@@ -87,7 +85,6 @@ async function test() {
|
|||||||
console.log('\n6. Testing validation logging...');
|
console.log('\n6. Testing validation logging...');
|
||||||
try {
|
try {
|
||||||
await memory.logValidation({
|
await memory.logValidation({
|
||||||
id: `run_${Date.now()}`,
|
|
||||||
sessionId: 'test-session',
|
sessionId: 'test-session',
|
||||||
inputLength: 100,
|
inputLength: 100,
|
||||||
outputLength: 200,
|
outputLength: 200,
|
||||||
|
|||||||
@@ -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 '.'
|
||||||
@@ -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!"
|
||||||
@@ -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!"
|
||||||
@@ -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!"
|
||||||
@@ -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!"
|
||||||
@@ -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!"
|
||||||
@@ -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!"
|
||||||
@@ -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!"
|
||||||
Reference in New Issue
Block a user