본문으로 건너뛰기
cccskills
무료GitHub에 공개

actonos-testing

Skill for writing and running tests for ActonOS. Covers unit tests, integration tests, test patterns, mocking, and coverage.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Playwright
설치 방법 보기

포함된 파일(1)

  • SKILL.md10.6 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

ActonOS Testing Skill

Use this skill when writing or running tests for ActonOS.

Test Categories

CategoryLocationBuild TagCommand
Unit Testsinternal/**/*_test.go(none)make test-unit
Integration Tests*_os_test.go / *_integ_test.go under internal/integrationmake test-integ
Benchmark Eval Suiteevals/ (30+ tasks)(none)./evals/run.sh / .\evals\run.ps1
E2E / Smoke Testsweb/tests/*.spec.ts(none)cd web && npm run test:e2e
Frontend Unitweb/src/**/*.test.{ts,tsx}(none)cd web && npm test
Frontend Browserweb/tests/*.spec.ts(none)cd web && npm run test:e2e
Frontend Qualityweb/(none)cd web && npm run quality

Running Tests

# All tests
make test

# Unit tests only (fast, no external dependencies)
make test-unit
# Equivalent to: CGO_ENABLED=0 go test -count=1 -coverprofile=build/coverage.out ./internal/...
# then go run ./scripts/cover-gate.go build/coverage.out

# Cognition & Reliability Benchmark Suite (30 tasks, CI gate)
./evals/run.sh
# on Windows PowerShell:
.\evals\run.ps1

# Live model benchmark evaluation
go run ./evals/runner/main.go --mode=live --model=anthropic/claude-sonnet-4.5 --output=eval_report.md --fail-under=90.0

# Integration tests
make test-integ
# Equivalent to: CGO_ENABLED=0 go test -count=1 -tags=integration ./internal/...

# Specific package
go test -v ./internal/agent/...

# Specific test
go test -v -run TestDecayScore ./internal/memory/...

# With coverage
go test -coverprofile=build/coverage.out ./internal/...
go tool cover -html=build/coverage.out -o build/coverage.html

# Frontend lint, locale parity, strict visible-text audit, Vitest, build,
# bundle budget, Playwright smoke tests, and axe accessibility checks
cd web
npm run quality
npx tsc --noEmit

# Playwright smoke test (requires a running ActonOS server)
npm run test:e2e

Frontend mutation tests must cover 202 approval_required separately from successful completion. Realtime tests must verify malformed-frame handling, reconnect behavior, and shared snapshot consumption. Modal tests must assert dialog semantics and asynchronous close behavior.

npm run quality must execute the hardcoded text audit with --fail and the Playwright suite. Browser tests must use axe and reject serious or critical accessibility violations. Production frontend lint must reject explicit any and unused variables.

Test Patterns

Table-Driven Tests (Preferred)

func TestDecayScore(t *testing.T) {
    tests := []struct {
        name     string
        elapsed  time.Duration
        lambda   float64
        weight   float64
        expected float64
    }{
        {
            name:     "recent_memory_high_score",
            elapsed:  1 * time.Hour,
            lambda:   24.0,
            weight:   1.0,
            expected: 0.959,
        },
        {
            name:     "old_memory_decayed",
            elapsed:  72 * time.Hour,
            lambda:   24.0,
            weight:   1.0,
            expected: 0.049,
        },
        {
            name:     "zero_elapsed_full_score",
            elapsed:  0,
            lambda:   24.0,
            weight:   1.0,
            expected: 1.0,
        },
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            got := decay.Score(tt.elapsed, tt.lambda, tt.weight)
            if math.Abs(got-tt.expected) > 0.01 {
                t.Errorf("Score(%v, %v, %v) = %v, want %v",
                    tt.elapsed, tt.lambda, tt.weight, got, tt.expected)
            }
        })
    }
}

Mock Interfaces

Define interfaces in production code, implement mocks in tests:

// internal/llm/provider.go (production)
type LLMProvider interface {
    Complete(ctx context.Context, messages []Message, opts Options) (*Response, error)
    StreamComplete(ctx context.Context, messages []Message, opts Options) (<-chan Token, error)
}

// internal/llm/provider_test.go (test)
type MockLLMProvider struct {
    CompleteFunc       func(ctx context.Context, messages []Message, opts Options) (*Response, error)
    CompleteCalled     int
}

func (m *MockLLMProvider) Complete(ctx context.Context, messages []Message, opts Options) (*Response, error) {
    m.CompleteCalled++
    if m.CompleteFunc != nil {
        return m.CompleteFunc(ctx, messages, opts)
    }
    return &Response{Content: "mock response"}, nil
}

func NewMockLLM(response *Response) *MockLLMProvider {
    return &MockLLMProvider{
        CompleteFunc: func(_ context.Context, _ []Message, _ Options) (*Response, error) {
            return response, nil
        },
    }
}

Test Helpers

// internal/testutil/helpers.go
package testutil

func NewTestDB(t *testing.T) *memory.DB {
    t.Helper()
    dir := t.TempDir()
    db, err := memory.Open(filepath.Join(dir, "test.db"))
    if err != nil {
        t.Fatalf("failed to open test DB: %v", err)
    }
    t.Cleanup(func() { db.Close() })
    return db
}

func NewTestServer(t *testing.T) *server.Server {
    t.Helper()
    db := NewTestDB(t)
    mgr := agent.NewManager(db)
    return server.New(mgr, db)
}

Integration Test Example

//go:build integration

package integration_test

import (
    "context"
    "testing"
    "d:/Projects/ActonOS/internal/memory"
)

func TestHybridSearch_FTS5AndVector(t *testing.T) {
    db := testutil.NewTestDB(t)
    hybrid := memory.NewHybridSearch(db)

    // Seed test data
    ctx := context.Background()
    hybrid.Index(ctx, "doc1", "ActonOS is an AI agent operating system")
    hybrid.Index(ctx, "doc2", "Docker containers run on Alpine Linux")
    hybrid.Index(ctx, "doc3", "The agent engine uses ReAct loop for reasoning")

    // Search
    results, err := hybrid.Search(ctx, "AI agent reasoning", 2)
    if err != nil {
        t.Fatalf("Search() error: %v", err)
    }

    if len(results) != 2 {
        t.Fatalf("expected 2 results, got %d", len(results))
    }

    // First result should be the most relevant
    if results[0].DocID != "doc3" && results[0].DocID != "doc1" {
        t.Errorf("unexpected top result: %s", results[0].DocID)
    }
}

HTTP Handler Tests

func TestHandleListAgents(t *testing.T) {
    srv := testutil.NewTestServer(t)

    // Create test agent
    ctx := context.Background()
    srv.AgentManager.Create(ctx, agent.Manifest{Name: "Test Agent"})

    // Make request
    req := httptest.NewRequest("GET", "/api/agents", nil)
    req.Header.Set("Authorization", "Bearer test-token")
    w := httptest.NewRecorder()

    srv.ServeHTTP(w, req)

    if w.Code != 200 {
        t.Fatalf("expected 200, got %d", w.Code)
    }

    var resp struct {
        Data struct {
            Agents []agent.Manifest `json:"agents"`
        } `json:"data"`
    }
    json.NewDecoder(w.Body).Decode(&resp)

    if len(resp.Data.Agents) != 1 {
        t.Errorf("expected 1 agent, got %d", len(resp.Data.Agents))
    }
}

Coverage Targets

PackageTargetPriority
internal/memory/80%+Critical (data integrity)
internal/agent/70%+High (core logic)
internal/auth/80%+Critical (security)
internal/server/60%+Medium (handlers)
internal/plugin/70%+High (WASM sandbox)
internal/channels/70%+High (pairing/routing)
internal/tools/60%+Medium
internal/sandbox/70%+High (security)
internal/security/90%+Critical

Test File Naming

internal/
├── agent/
│   ├── engine.go
│   ├── engine_test.go            ← Unit tests
│   └── engine_integ_test.go      ← Integration tests (build tag)
├── memory/
│   ├── decay.go
│   └── decay_test.go             ← Unit tests

Mandatory Security Cases

Changes touching tools, agents, workspace APIs, MCP, or sandboxing must test:

  1. Unauthorized tools are rejected at execution time.
  2. Medium/High actions pause with a durable approval.
  3. Approval hashes reject modified arguments and expired/rejected decisions.
  4. Lexical and symlink path escapes are rejected.
  5. Loopback, private, link-local, metadata, and redirect SSRF targets are rejected.
  6. Destructive commands are denied before process startup.
  7. Non-zero command exits are classified as failures.
  8. Repeated observations/failures terminate rather than loop forever.
  9. Trace IDs correlate run, tool, approval, and audit records.
  10. Linux sandbox builds compile with cgroup v2 attachment enabled.
  11. Streaming tests cover token deltas and fragmented tool-call reconstruction.
  12. Audit tests validate hash-chain integrity and tamper detection.
  13. Durable resume tests prove the approved tool executes once and the original run continues from its saved state.
  14. MCP HTTP tests cover JSON and data: SSE JSON-RPC responses.
  15. Provider streaming tests cover OpenAI-compatible, Anthropic, and Gemini.
  16. Realtime WebSocket tests cover authenticated upgrade, snapshot shape and disconnect cleanup.
  17. MCP administration tests prove environment secrets never appear in list responses and enable/disable restores persisted configuration.

Security package target: internal/security/ must maintain at least 90% coverage.

The autonomous-kernel baseline established on 2026-08-18 is: agent 71.5%, server 60.6%, tools 60.3%, sandbox 87.8%, security 92.3%, and memory 83.3%. Changes must not reduce a package below its target.

Linux CI must run CGO_ENABLED=1 go test -race -count=1 ./internal/.... Provider-storage tests must prove secrets are absent from metadata files, legacy plaintext is migrated and removed, and Vault deletion works. Backup tests must query committed WAL data from the downloaded snapshot.

Reference Files

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Skill for developing AI agent engine components in internal/agent/. Covers the ReAct loop, swarm delegation, planning, verification, memory reflection, and cron automation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

actonos/actonos802026년 8월 31일 업데이트

Skill for developing REST API endpoints in internal/server/. Covers routing, request validation, WebSocket streaming, and API conventions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

actonos/actonos802026년 8월 31일 업데이트

Skill for building ActonOS: Web UI → Go binary → Docker image → ISO. Covers the entire build pipeline.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

actonos/actonos802026년 8월 31일 업데이트

Skill for developing messaging channel adapters via WASM Plugins and managing routing, session state, pairing codes, and accounts in internal/channels/.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

actonos/actonos802026년 8월 31일 업데이트

Skill for developing the ActonOS React 19 + Tailwind v4 frontend adhering to the official DESIGN.md specification. Covers design tokens, component decomposition, zero-hardcoded-text i18n, and go:embed delivery.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

actonos/actonos802026년 8월 31일 업데이트

Skill for creating ActonOS releases. Covers version bumping, changelog management, git tagging, Docker image publishing, and ISO creation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

actonos/actonos802026년 8월 31일 업데이트

actonos의 스킬 모두 보기

이 스킬의 문제 신고