Commit Graph

4 Commits

Author SHA1 Message Date
Your Name
087de4e102 fix(audit): use uuid.New() for ticket workflow audit IDs
Fixes 'invalid input syntax for type uuid' error when writing ticket
workflow audit logs. The audit Event.ID field was using fmt.Sprintf
with nanoseconds ('wf-%d') which doesn't match PostgreSQL's uuid type.

Also adds uuid import to ticket_workflow.go.

Verified: full chain webhook→assign→resolve→close produces 3 audit
logs correctly, no more 'invalid uuid' errors in logs.
2026-05-04 13:44:39 +08:00
Your Name
142b991334 fix(config+app): production fail-fast + readiness收紧
1. config.go: AI_CS_ENV runtime mode with production restriction
   - New RuntimeConfig.Env field (AI_CS_ENV / AI_CS_RUNTIME_ENV)
   - production + Postgres.Enabled=false → Load() returns error
   - production + empty webhook secret → Load() returns error
   - normalizeRuntimeEnv: dev/dev/ → development, prod/production → production, test → test

2. app.go: probe.SetReady only when store is confirmed ready
   - Postgres.Enabled: probe.SetReady(true) after DB+migration OK
   - Memory mode: probe.SetReady(false) — not production-ready

3. health_handler_test.go: add probe live+ready state transition tests

4. config_test.go: add TestLoad_RejectsProdWhenPostgresDisabled,
   TestLoad_RejectsProdWhenWebhookSecretMissing

5. app_test.go: add TestNew_RejectsMemoryModeWithoutExplicitNonProdEnv,
   TestNew_AllowsMemoryModeInTestEnv, TestNew_WithPostgresEnabled_*
   for invalid DSN and migration-failure paths

Phase 1 (code gate) objectives met:
 prod cannot fall back to memory store
 readiness reflects actual store readiness
 both changes have test coverage
2026-05-04 07:38:10 +08:00
Your Name
55cfcd6503 test(P0-3): 补齐 router 测试覆盖
扩展 internal/http/router_test.go(+3 个测试):
- TestRouter_TicketsSubpaths: /assign、/resolve、/close 路由注册验证
- TestRouter_SessionsFeedbackHandoff: /feedback、/handoff 路由注册验证
- TestRouter_UnknownSessionsPath_Returns405: 未知 sessions 子路径返回 405
- TestRouter_UnknownTicketsPath_Returns405: 未知 tickets 子路径返回 405

使用 HEAD 方法避免触发 nil service panic(仅验证路由注册)

**覆盖率提升**:
- internal/http (router): 41.3% → **74.7%** (+33.4%)
- 整体覆盖率: 71.3% → **73.6%** (+2.3%)

Ref: test/PHASE2_TEST_PLAN.md P0-3
2026-05-01 09:53:59 +08:00
Your Name
a6b4e519fb test: add router and health handler tests for Phase 2 coverage
- TestRouter_HealthEndpoint: health/live/ready endpoints return 200
- TestRouter_UnknownPath: unknown paths return 404
- TestRouter_WebhookChannel_MissingChannel: empty channel returns 400
- TestRouter_WebhookPath_CanBeCalledWithGET: GET /webhook returns 405
- TestRouter_TicketsList_POST_Returns405: POST /tickets returns 405
- TestRouter_SessionsRoute_OnlyPOST: nil Sessions returns 404
- TestProbe defaults: IsLive=true, IsReady=false on NewProbe()
- TestProbe_SetLive/SetReady: atomic load/store correctness

Ref: PRODUCTION_PHASE1_STATUS.md §8.3 P1/P2 coverage gaps
2026-05-01 08:47:04 +08:00