Initial import — snapshot from admin host /srv/gosec/gsc-ops-api

This repo had no version control prior to this commit. The import is a
straight snapshot of the working tree at 2026-05-03; the deployed
binary on fihelvop01 was being rebuilt from this source via `make
build` + scp into place, with no upstream review path.

The snapshot already includes one in-flight fix made on 2026-05-03 to
internal/service/persona.go:GetSelfModel — the handler queried
`source` and `strength` columns plus an `is_active = true` filter on
persona.persona_commitments, none of which exist on that table (its
shape is session-bound commitments with `status`, `commitment_meta`,
etc.). The query returned a 500 every time SynapseHub bootstrapped a
persona's self-model, dropping the IdentityConstraints / Commitments /
ConscienceStandards layer from the assembled prompt. The patched
query reads existing columns only (commitment_text, commitment_type),
filters on `status='active'`, and synthesises Source="learned" /
Strength=1.0 to keep the SelfModel response shape stable for callers.

Verified live: `GET /api/v1/personas/70f7cfd9-.../self-model` now
returns 200 with `{identityConstraints:[],commitments:[],
conscienceStandards:[]}` instead of 500.

Future changes go through PRs against this repo — no more bin-only
deploys.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude (gsc-ops-api init)
2026-05-03 20:06:02 +02:00
commit 3847eb2036
68 changed files with 12982 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
; Asterisk func_odbc Configuration
; Custom ODBC functions for multi-tenant DID routing
; TENANT_BY_DID - Lookup tenant code by DID number
; Usage: ${ODBC_TENANT_BY_DID(+3726026553)}
[TENANT_BY_DID]
dsn=asterisk
readsql=SELECT tenant_code FROM did_tenant_lookup WHERE did_number='${SQL_ESC(${ARG1})}' LIMIT 1
synopsis=Lookup tenant code by DID number
; INBOUND_ROUTE - Lookup inbound destination by DID and tenant
; Usage: ${ODBC_INBOUND_ROUTE(+3726026553)}
; Returns: destination_type|destination_id|destination_data
[INBOUND_ROUTE]
dsn=asterisk
readsql=SELECT destination_type || '|' || COALESCE(destination_id::text, '') || '|' || COALESCE(destination_data, '') FROM inbound_route_lookup WHERE did_number='${SQL_ESC(${ARG1})}' ORDER BY priority LIMIT 1
synopsis=Lookup inbound route by DID number
; OUTBOUND_ROUTE - Lookup outbound trunk for dialing
; Usage: ${ODBC_OUTBOUND_ROUTE(tenant_code,dialed_number)}
; Returns: trunk_id|trunk_host|trunk_port
[OUTBOUND_ROUTE]
dsn=asterisk
readsql=SELECT trunk_id || '|' || trunk_host || '|' || trunk_port FROM outbound_route_lookup WHERE tenant_code='${SQL_ESC(${ARG1})}' AND '${SQL_ESC(${ARG2})}' ~ ANY(dial_patterns) ORDER BY route_priority, trunk_priority LIMIT 1
synopsis=Lookup outbound trunk by tenant and dial pattern