@a5c-ai/krate 5.0.1-staging.f672fe79b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +29 -0
- package/README.md +183 -0
- package/bin/krate-demo.mjs +23 -0
- package/bin/krate-server.mjs +14 -0
- package/dist/krate-controller-ui.json +2407 -0
- package/dist/krate-lifecycle.json +201 -0
- package/dist/krate-runtime-snapshot.json +2955 -0
- package/dist/krate-summary.json +687 -0
- package/docs/README.md +61 -0
- package/docs/agents/README.md +83 -0
- package/docs/agents/acceptance-test-matrix.md +193 -0
- package/docs/agents/agent-mux-adapter-contract.md +167 -0
- package/docs/agents/agent-mux-source-map.md +310 -0
- package/docs/agents/agent-run-memory-import-spec.md +256 -0
- package/docs/agents/agent-stack-management-spec.md +421 -0
- package/docs/agents/api-contract-spec.md +309 -0
- package/docs/agents/artifacts-writeback-spec.md +145 -0
- package/docs/agents/chart-packaging-spec.md +128 -0
- package/docs/agents/ci-orchestration-spec.md +140 -0
- package/docs/agents/context-assembly-spec.md +219 -0
- package/docs/agents/controller-reconciliation-spec.md +255 -0
- package/docs/agents/crd-schema-spec.md +315 -0
- package/docs/agents/decision-log-open-questions.md +169 -0
- package/docs/agents/developer-implementation-checklist.md +329 -0
- package/docs/agents/dispatching-design.md +262 -0
- package/docs/agents/glossary.md +66 -0
- package/docs/agents/implementation-blueprint.md +324 -0
- package/docs/agents/implementation-rollout-slices.md +251 -0
- package/docs/agents/memory-context-integration-spec.md +194 -0
- package/docs/agents/memory-ontology-schema-spec.md +253 -0
- package/docs/agents/memory-operations-runbook.md +121 -0
- package/docs/agents/mvp-vertical-slice-spec.md +146 -0
- package/docs/agents/observability-audit-spec.md +265 -0
- package/docs/agents/operator-runbook.md +174 -0
- package/docs/agents/org-memory-api-payload-examples.md +333 -0
- package/docs/agents/org-memory-controller-sequence-spec.md +181 -0
- package/docs/agents/org-memory-e2e-fixture-plan.md +161 -0
- package/docs/agents/org-memory-ui-implementation-map.md +114 -0
- package/docs/agents/org-memory-vertical-slice-spec.md +168 -0
- package/docs/agents/org-resource-model-delta-spec.md +111 -0
- package/docs/agents/org-route-resource-model-spec.md +183 -0
- package/docs/agents/org-scoping-namespace-spec.md +114 -0
- package/docs/agents/rbac-secrets-management-spec.md +406 -0
- package/docs/agents/repository-page-integration-spec.md +255 -0
- package/docs/agents/resource-contract-examples.md +808 -0
- package/docs/agents/resource-relationship-map.md +190 -0
- package/docs/agents/security-threat-model.md +188 -0
- package/docs/agents/shared-memory-company-brain-spec.md +358 -0
- package/docs/agents/storage-migration-spec.md +168 -0
- package/docs/agents/subagent-orchestration-spec.md +152 -0
- package/docs/agents/system-overview.md +88 -0
- package/docs/agents/tools-mcp-skills-spec.md +189 -0
- package/docs/agents/traceability-matrix.md +79 -0
- package/docs/agents/ui-flow-spec.md +211 -0
- package/docs/agents/ui-ux-system-spec.md +426 -0
- package/docs/agents/workspace-lifecycle-spec.md +166 -0
- package/docs/architecture-spec.md +78 -0
- package/docs/components/control-plane.md +78 -0
- package/docs/components/data-plane.md +69 -0
- package/docs/components/hooks-events.md +67 -0
- package/docs/components/identity-rbac-policy.md +73 -0
- package/docs/components/kubevela-oam.md +70 -0
- package/docs/components/operations-publishing.md +81 -0
- package/docs/components/runners-ci.md +66 -0
- package/docs/components/web-ui.md +94 -0
- package/docs/external/README.md +47 -0
- package/docs/external/bidirectional-sync-design.md +134 -0
- package/docs/external/cicd-interface.md +64 -0
- package/docs/external/external-backend-controllers.md +170 -0
- package/docs/external/external-backend-crds.md +234 -0
- package/docs/external/external-backend-ui-spec.md +151 -0
- package/docs/external/external-backend-ux-flows.md +115 -0
- package/docs/external/external-object-mapping.md +125 -0
- package/docs/external/git-forge-interface.md +68 -0
- package/docs/external/github-integration-design.md +151 -0
- package/docs/external/issue-tracking-interface.md +66 -0
- package/docs/external/provider-capability-manifests.md +204 -0
- package/docs/external/provider-catalog.md +139 -0
- package/docs/external/provider-rollout-testing.md +78 -0
- package/docs/external/research-results.md +48 -0
- package/docs/external/security-auth-permissions.md +81 -0
- package/docs/external/sync-state-machines.md +108 -0
- package/docs/external/unified-external-backend-model.md +107 -0
- package/docs/external/user-facing-changes.md +67 -0
- package/docs/gaps.md +161 -0
- package/docs/install.md +94 -0
- package/docs/krate-design.md +334 -0
- package/docs/local-minikube.md +55 -0
- package/docs/ontology/README.md +32 -0
- package/docs/ontology/bounded-contexts.md +29 -0
- package/docs/ontology/events-and-hooks.md +32 -0
- package/docs/ontology/oam-kubevela.md +32 -0
- package/docs/ontology/operations-and-release.md +25 -0
- package/docs/ontology/personas-and-actors.md +32 -0
- package/docs/ontology/policies-and-invariants.md +33 -0
- package/docs/ontology/problem-space.md +30 -0
- package/docs/ontology/resource-contracts.md +40 -0
- package/docs/ontology/resource-taxonomy.md +42 -0
- package/docs/ontology/runners-and-ci.md +29 -0
- package/docs/ontology/solution-space.md +24 -0
- package/docs/ontology/storage-and-data-boundaries.md +29 -0
- package/docs/ontology/validation-matrix.md +24 -0
- package/docs/ontology/web-ui-excellent-flows.md +32 -0
- package/docs/ontology/workflows.md +39 -0
- package/docs/ontology/world.md +35 -0
- package/docs/product-requirements.md +62 -0
- package/docs/roadmap-mvp.md +87 -0
- package/docs/system-requirements.md +90 -0
- package/docs/tests/README.md +53 -0
- package/docs/tests/agent-qa-plan.md +63 -0
- package/docs/tests/browser-ui-tests.md +62 -0
- package/docs/tests/ci-quality-gates.md +48 -0
- package/docs/tests/coverage-model.md +64 -0
- package/docs/tests/e2e-scenario-tests.md +53 -0
- package/docs/tests/fixtures-test-data.md +63 -0
- package/docs/tests/observability-reliability-tests.md +54 -0
- package/docs/tests/product-test-matrix.md +145 -0
- package/docs/tests/qa-adoption-roadmap.md +130 -0
- package/docs/tests/qa-automation-plan.md +101 -0
- package/docs/tests/security-compliance-tests.md +57 -0
- package/docs/tests/test-framework-tools.md +88 -0
- package/docs/tests/test-suite-layout.md +121 -0
- package/docs/tests/unit-integration-tests.md +48 -0
- package/docs/todo-kyverno +714 -0
- package/docs/user-stories.md +78 -0
- package/examples/minikube-demo.yaml +190 -0
- package/examples/oam-application.yaml +23 -0
- package/examples/policy-kyverno-pr-title.yaml +18 -0
- package/package.json +63 -0
- package/scripts/build.mjs +29 -0
- package/scripts/setup-minikube.mjs +65 -0
- package/scripts/smoke.mjs +37 -0
- package/scripts/validate-doc-coverage.mjs +152 -0
- package/scripts/validate-package.mjs +93 -0
- package/scripts/validate-ui.mjs +207 -0
- package/src/agent-approval-controller.js +123 -0
- package/src/agent-context-bundles.js +242 -0
- package/src/agent-dispatch-controller.js +86 -0
- package/src/agent-mux-client.js +280 -0
- package/src/agent-permission-review.js +162 -0
- package/src/agent-stack-controller.js +296 -0
- package/src/agent-trigger-controller.js +108 -0
- package/src/api-controller.js +206 -0
- package/src/argocd-gitops.js +43 -0
- package/src/auth.js +265 -0
- package/src/component-catalog.js +41 -0
- package/src/control-plane.js +136 -0
- package/src/controller-client.js +38 -0
- package/src/controller-ui.js +538 -0
- package/src/data-plane.js +178 -0
- package/src/gitea-backend.js +95 -0
- package/src/handoff.js +98 -0
- package/src/hooks-events.js +63 -0
- package/src/http-server.js +151 -0
- package/src/identity-policy.js +86 -0
- package/src/index.js +30 -0
- package/src/kubernetes-controller.js +812 -0
- package/src/kubernetes-resource-gateway.js +48 -0
- package/src/operations.js +112 -0
- package/src/resource-model.js +203 -0
- package/src/runners-ci.js +48 -0
- package/src/runtime.js +196 -0
- package/src/web-ui.js +40 -0
- package/tests/agent-approval-controller.test.js +173 -0
- package/tests/agent-context-bundles.test.js +278 -0
- package/tests/agent-dispatch-controller.test.js +176 -0
- package/tests/agent-mux-client.test.js +204 -0
- package/tests/agent-permission-review.test.js +209 -0
- package/tests/agent-resources.test.js +212 -0
- package/tests/agent-stack-controller.test.js +221 -0
- package/tests/agent-trigger-controller.test.js +211 -0
- package/tests/deployment.test.js +395 -0
- package/tests/e2e/lifecycle.test.js +117 -0
- package/tests/krate.test.js +727 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# QA automation plan
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
The QA plan covers:
|
|
6
|
+
|
|
7
|
+
- core resource model and CRDs;
|
|
8
|
+
- aggregated API and Postgres-backed resources;
|
|
9
|
+
- Kubernetes controller and gateway behavior;
|
|
10
|
+
- Gitea-backed repository data plane;
|
|
11
|
+
- web UI and route flows;
|
|
12
|
+
- CI/runners and pipeline/job lifecycle;
|
|
13
|
+
- hooks and webhook delivery;
|
|
14
|
+
- identity, RBAC, secrets, config, and policy;
|
|
15
|
+
- deployments and KubeVela/OAM integration;
|
|
16
|
+
- packaging, Helm chart, Docker image, install, smoke, and upgrade;
|
|
17
|
+
- future agents, Agent Mux integration, company brain memory, `.a5c` run imports, triggers, tools, skills, subagents, and orchestration.
|
|
18
|
+
|
|
19
|
+
## Test pyramid
|
|
20
|
+
|
|
21
|
+
| Layer | Goal | Examples | Required speed |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| Static checks | catch broken contracts before execution | docs coverage, package validation, schema lint, import checks | seconds. |
|
|
24
|
+
| Unit tests | verify pure functions and module contracts | resource schema, route helpers, auth helpers, redaction, ref resolution | seconds. |
|
|
25
|
+
| Integration tests | verify module boundaries with fakes | API controller, Kubernetes gateway, UI model, memory import normalizer | seconds to minutes. |
|
|
26
|
+
| Component/UI tests | verify rendered components and interactions | org switcher, repo tabs, dispatch composer, memory import panel | minutes. |
|
|
27
|
+
| Browser E2E | verify critical user journeys | create repo, run CI, dispatch agent, import memory | minutes. |
|
|
28
|
+
| Package/install tests | verify release artifact shape | Helm template, CRD coverage, minikube dry-run, Docker build | minutes. |
|
|
29
|
+
| Live cluster tests | verify real integrations | Gitea, NATS, ARC, Argo CD, KubeVela, webhooks | longer/nightly. |
|
|
30
|
+
| Chaos/reliability tests | verify failure behavior | watch reconnect, controller retry, Git outage, redaction failure | nightly/staging. |
|
|
31
|
+
|
|
32
|
+
## Definition of done
|
|
33
|
+
|
|
34
|
+
A feature is not done until:
|
|
35
|
+
|
|
36
|
+
- resource/API/schema docs are updated;
|
|
37
|
+
- unit or integration tests cover the core logic;
|
|
38
|
+
- at least one acceptance or E2E path covers the user-visible behavior;
|
|
39
|
+
- cross-org/RBAC/secret negative tests exist where relevant;
|
|
40
|
+
- docs validation and package validation pass;
|
|
41
|
+
- UI changes pass browser or component checks where relevant;
|
|
42
|
+
- release-impacting changes update chart/package tests;
|
|
43
|
+
- future agent/memory changes update the fixture plan and acceptance matrix.
|
|
44
|
+
|
|
45
|
+
## Rollout phases
|
|
46
|
+
|
|
47
|
+
### Phase 1: codify current gates
|
|
48
|
+
|
|
49
|
+
- Keep `npm run check` as the local all-up gate.
|
|
50
|
+
- Make `npm run validate:docs`, `npm test`, `npm run e2e`, `npm run package:check`, `npm run smoke`, `npm run ui:validate`, and `npm run ui:build` visible in CI docs.
|
|
51
|
+
- Add test ownership labels by subsystem.
|
|
52
|
+
|
|
53
|
+
### Phase 2: add browser automation
|
|
54
|
+
|
|
55
|
+
- Add Playwright for route-level browser tests.
|
|
56
|
+
- Cover org navigation, repository code/issues/runs/settings, deployments, and advanced plans.
|
|
57
|
+
- Add accessibility checks for primary routes.
|
|
58
|
+
|
|
59
|
+
### Phase 3: add API/controller contract tests
|
|
60
|
+
|
|
61
|
+
- Add table-driven tests for org-scoped API routes, resource apply/list/delete, watch, and errors.
|
|
62
|
+
- Add fake Kubernetes/Gitea/NATS/Agent Mux adapters.
|
|
63
|
+
- Add no-secret response tests.
|
|
64
|
+
|
|
65
|
+
### Phase 4: add agent/company-brain tests
|
|
66
|
+
|
|
67
|
+
- Add fixtures for org memory, `.a5c` run imports, historical memory refs, and Agent Mux session binding.
|
|
68
|
+
- Add cross-org denial and redaction tests.
|
|
69
|
+
- Add browser E2E for dispatch with memory and import review.
|
|
70
|
+
|
|
71
|
+
### Phase 5: staging and live integration
|
|
72
|
+
|
|
73
|
+
- Add nightly cluster tests for Gitea, Argo CD, KubeVela, ARC, NATS, webhooks, and object storage.
|
|
74
|
+
- Add upgrade/rollback tests.
|
|
75
|
+
- Add reliability and failure injection scenarios.
|
|
76
|
+
|
|
77
|
+
## Ownership model
|
|
78
|
+
|
|
79
|
+
| Area | Owner role | Required evidence |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| Resource/API contracts | platform/backend | schema tests, API tests, docs coverage. |
|
|
82
|
+
| Controllers | platform/backend | reconciliation tests, idempotency tests, events/audit. |
|
|
83
|
+
| UI/UX | frontend/product | browser/component tests, accessibility, route guards. |
|
|
84
|
+
| CI/runners | platform/runtime | lifecycle E2E, isolation, ServiceAccount/RBAC tests. |
|
|
85
|
+
| Security | security/platform | auth/RBAC/secret/no-leak tests. |
|
|
86
|
+
| Packaging | release/platform | package/chart/install/smoke tests. |
|
|
87
|
+
| Agents/memory | agents/platform | dispatch, context, memory, Agent Mux, import, trigger tests. |
|
|
88
|
+
|
|
89
|
+
## Reporting
|
|
90
|
+
|
|
91
|
+
Every CI run should publish:
|
|
92
|
+
|
|
93
|
+
- command summary;
|
|
94
|
+
- pass/fail by suite;
|
|
95
|
+
- coverage by subsystem;
|
|
96
|
+
- flaky test list;
|
|
97
|
+
- failed test artifacts;
|
|
98
|
+
- browser traces/screenshots for UI failures;
|
|
99
|
+
- package/chart validation summary;
|
|
100
|
+
- security/secret-scan findings;
|
|
101
|
+
- links to run logs and relevant resources.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Security and compliance tests
|
|
2
|
+
|
|
3
|
+
## Authentication and authorization
|
|
4
|
+
|
|
5
|
+
Required tests:
|
|
6
|
+
|
|
7
|
+
- OIDC/delegated identity config parsing;
|
|
8
|
+
- unauthenticated request rejection;
|
|
9
|
+
- user/group mapping;
|
|
10
|
+
- Kubernetes SubjectAccessReview invocation;
|
|
11
|
+
- org namespace authorization;
|
|
12
|
+
- route guard denies resource with wrong org label;
|
|
13
|
+
- admin-only actions require admin/RBAC.
|
|
14
|
+
|
|
15
|
+
## RBAC and policy
|
|
16
|
+
|
|
17
|
+
Required tests:
|
|
18
|
+
|
|
19
|
+
- runner ServiceAccount scoped to repo/ref/trust tier;
|
|
20
|
+
- agent ServiceAccount cannot mount another org Secret/ConfigMap;
|
|
21
|
+
- untrusted fork has no secrets and no cluster write access;
|
|
22
|
+
- missing `AgentSecretGrant` or `AgentConfigGrant` blocks stack readiness;
|
|
23
|
+
- policy/audit mode surfaces warnings without mutating resources;
|
|
24
|
+
- cross-org refs require `OrgSharingPolicy`.
|
|
25
|
+
|
|
26
|
+
## Secret and data leakage
|
|
27
|
+
|
|
28
|
+
No secret-like values may appear in:
|
|
29
|
+
|
|
30
|
+
- API responses;
|
|
31
|
+
- UI rendered text;
|
|
32
|
+
- context bundles;
|
|
33
|
+
- prompt previews;
|
|
34
|
+
- memory imports;
|
|
35
|
+
- logs and watch events;
|
|
36
|
+
- artifacts;
|
|
37
|
+
- audit records;
|
|
38
|
+
- browser traces.
|
|
39
|
+
|
|
40
|
+
## Supply chain
|
|
41
|
+
|
|
42
|
+
Release gates should eventually include:
|
|
43
|
+
|
|
44
|
+
- dependency vulnerability scan;
|
|
45
|
+
- license policy scan;
|
|
46
|
+
- Docker image scan;
|
|
47
|
+
- SBOM generation;
|
|
48
|
+
- image/chart provenance or signatures;
|
|
49
|
+
- GitHub Actions workflow lint.
|
|
50
|
+
|
|
51
|
+
## Agent-specific security
|
|
52
|
+
|
|
53
|
+
- Memory records are untrusted prompt content.
|
|
54
|
+
- Tool calls are admitted by Krate, not Agent Mux alone.
|
|
55
|
+
- Historical memory runs cannot read current memory without refresh/approval.
|
|
56
|
+
- Agent write-back requires artifact digest and approval.
|
|
57
|
+
- `.a5c` imports are redacted and validated before entering company brain.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Test framework and tools
|
|
2
|
+
|
|
3
|
+
## Existing baseline
|
|
4
|
+
|
|
5
|
+
Krate currently uses Node.js with ESM and the built-in `node:test` runner for unit and E2E tests. The package scripts are the source of truth for current gates.
|
|
6
|
+
|
|
7
|
+
Existing tools:
|
|
8
|
+
|
|
9
|
+
| Tool | Use |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Node `node:test` | unit, integration, and current E2E tests. |
|
|
12
|
+
| `assert/strict` | assertions. |
|
|
13
|
+
| Next.js build | production UI build validation. |
|
|
14
|
+
| custom scripts | docs, package, smoke, UI, minikube dry-run validation. |
|
|
15
|
+
| Helm/minikube dry-run plans | install command validation without a live cluster. |
|
|
16
|
+
|
|
17
|
+
## Recommended additions
|
|
18
|
+
|
|
19
|
+
| Tool | Add when | Use |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| Playwright | first browser suite | browser E2E, traces, screenshots, route assertions, accessibility hooks. |
|
|
22
|
+
| Testing Library / React test utilities | component-level UI tests | component interaction tests without full browser cost. |
|
|
23
|
+
| Istanbul/c8 or Node coverage | coverage reporting | line/branch/function coverage for `src` and critical scripts. |
|
|
24
|
+
| `axe-core` or Playwright accessibility assertions | UI accessibility gate | WCAG smoke checks on primary pages. |
|
|
25
|
+
| Helm unittest or template assertions | chart complexity grows | focused Helm render checks beyond current string tests. |
|
|
26
|
+
| kubeconform/kubeval | CRD/chart validation | Kubernetes schema validation for rendered manifests. |
|
|
27
|
+
| actionlint | workflow validation | GitHub Actions YAML checks. |
|
|
28
|
+
| secret scanner | before memory imports and release | ensure fixtures/logs/artifacts do not leak secrets. |
|
|
29
|
+
| dependency/license scanner | release gate | supply-chain checks. |
|
|
30
|
+
| k6 or autocannon | performance stage | API/web smoke load tests. |
|
|
31
|
+
|
|
32
|
+
## Tool selection principles
|
|
33
|
+
|
|
34
|
+
- Prefer fast built-in Node tests for pure logic and contracts.
|
|
35
|
+
- Use browser automation only for routes and interactions that cannot be validated below the browser layer.
|
|
36
|
+
- Use deterministic fakes for Kubernetes, Gitea, Agent Mux, NATS, Argo CD, and object storage in PR gates.
|
|
37
|
+
- Use live integration only in nightly/staging or explicit release gates.
|
|
38
|
+
- Keep tests runnable on Windows and Linux.
|
|
39
|
+
- Store fixtures in repo; avoid network calls in deterministic CI unless the suite is explicitly live.
|
|
40
|
+
|
|
41
|
+
## Proposed npm scripts
|
|
42
|
+
|
|
43
|
+
Future scripts should be additive and keep current scripts stable:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"test:unit": "node --test tests/unit/**/*.test.js",
|
|
48
|
+
"test:integration": "node --test tests/integration/**/*.test.js",
|
|
49
|
+
"test:api": "node --test tests/api/**/*.test.js",
|
|
50
|
+
"test:e2e": "node --test tests/e2e/**/*.test.js",
|
|
51
|
+
"test:browser": "playwright test",
|
|
52
|
+
"test:coverage": "node --test --experimental-test-coverage tests/**/*.test.js",
|
|
53
|
+
"test:security": "node scripts/security-check.mjs",
|
|
54
|
+
"test:charts": "node scripts/validate-package.mjs",
|
|
55
|
+
"test:all": "npm run check && npm run test:browser"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The exact script names can change during implementation, but the suite split should remain recognizable.
|
|
60
|
+
|
|
61
|
+
## Test doubles
|
|
62
|
+
|
|
63
|
+
Required fakes/mocks:
|
|
64
|
+
|
|
65
|
+
| Adapter | Fake behavior |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| Kubernetes API | list/get/apply/delete/watch resources, SubjectAccessReview, events. |
|
|
68
|
+
| Gitea/Git | repository create, refs, commits, clone URL, protected branches, webhook callbacks. |
|
|
69
|
+
| Postgres | aggregated resources and migrations, preferably in-memory or isolated test DB. |
|
|
70
|
+
| Object storage | artifact put/get by digest. |
|
|
71
|
+
| NATS/webhook queue | enqueue, deliver, retry, replay. |
|
|
72
|
+
| Agent Mux | create run/session, stream events, accept chat continuation, cancel/resume. |
|
|
73
|
+
| Memory Git repo | resolve refs, read files, grep, write branch/PR, merge, diff. |
|
|
74
|
+
| Argo CD/KubeVela | Application status, sync plan, rollout state. |
|
|
75
|
+
|
|
76
|
+
## Artifacts
|
|
77
|
+
|
|
78
|
+
Test failures should preserve:
|
|
79
|
+
|
|
80
|
+
- assertion output;
|
|
81
|
+
- API request/response body with secrets redacted;
|
|
82
|
+
- generated YAML/resource plans;
|
|
83
|
+
- browser trace and screenshot;
|
|
84
|
+
- console/network logs for browser failures;
|
|
85
|
+
- rendered Helm manifests;
|
|
86
|
+
- memory import validation report;
|
|
87
|
+
- `.a5c` fixture redaction report;
|
|
88
|
+
- coverage report.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Test suite layout and naming
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This document defines the future test directory layout, naming conventions, fixture locations, and ownership model. The current repository can keep existing tests while migrating incrementally toward this structure.
|
|
6
|
+
|
|
7
|
+
## Proposed layout
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
tests/
|
|
11
|
+
unit/
|
|
12
|
+
resource-model.test.js
|
|
13
|
+
route-helpers.test.js
|
|
14
|
+
redaction.test.js
|
|
15
|
+
memory-ref-resolution.test.js
|
|
16
|
+
integration/
|
|
17
|
+
api-controller.test.js
|
|
18
|
+
controller-ui-model.test.js
|
|
19
|
+
gitea-backend.test.js
|
|
20
|
+
memory-import-normalizer.test.js
|
|
21
|
+
api/
|
|
22
|
+
org-resources.test.js
|
|
23
|
+
agent-dispatch.test.js
|
|
24
|
+
memory-query.test.js
|
|
25
|
+
watch-filters.test.js
|
|
26
|
+
e2e/
|
|
27
|
+
lifecycle.test.js
|
|
28
|
+
org-isolation.test.js
|
|
29
|
+
repository-pr-ci.test.js
|
|
30
|
+
deployment-promotion.test.js
|
|
31
|
+
agent-memory-vertical.test.js
|
|
32
|
+
browser/
|
|
33
|
+
org-navigation.spec.ts
|
|
34
|
+
repository-flow.spec.ts
|
|
35
|
+
run-detail.spec.ts
|
|
36
|
+
agent-memory.spec.ts
|
|
37
|
+
fixtures/
|
|
38
|
+
orgs/
|
|
39
|
+
resources/
|
|
40
|
+
repositories/
|
|
41
|
+
webhooks/
|
|
42
|
+
deployments/
|
|
43
|
+
agents/
|
|
44
|
+
memory/
|
|
45
|
+
company-brain/
|
|
46
|
+
a5c-runs/
|
|
47
|
+
sessions/
|
|
48
|
+
helpers/
|
|
49
|
+
fake-kubernetes.js
|
|
50
|
+
fake-gitea.js
|
|
51
|
+
fake-agent-mux.js
|
|
52
|
+
fake-memory-repo.js
|
|
53
|
+
assertions.js
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Naming conventions
|
|
57
|
+
|
|
58
|
+
| Type | Convention |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| Node tests | `*.test.js` using Node `node:test`. |
|
|
61
|
+
| Playwright tests | `*.spec.ts` or `*.spec.js` under `tests/browser`. |
|
|
62
|
+
| Fixtures | kebab-case directory and file names. |
|
|
63
|
+
| Fake adapters | `fake-<adapter>.js`. |
|
|
64
|
+
| Golden outputs | `<scenario>.expected.json` only when stable and reviewed. |
|
|
65
|
+
| Redaction fixtures | include `redact-me` in synthetic secret values. |
|
|
66
|
+
|
|
67
|
+
## Test metadata
|
|
68
|
+
|
|
69
|
+
Each larger scenario test should declare:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const meta = {
|
|
73
|
+
area: 'agents-memory',
|
|
74
|
+
owner: 'platform-agents',
|
|
75
|
+
gate: 'pr|merge|nightly|release',
|
|
76
|
+
requires: ['fake-kubernetes', 'fake-memory-repo'],
|
|
77
|
+
covers: ['ORG-ISOLATION', 'MEMORY-SNAPSHOT']
|
|
78
|
+
};
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Metadata can be comments or exported constants at first. Later it can feed reports.
|
|
82
|
+
|
|
83
|
+
## Fixture policy
|
|
84
|
+
|
|
85
|
+
- Tests may mutate copies of fixtures, never the fixture source.
|
|
86
|
+
- Fixtures with secret-like values must be synthetic and documented.
|
|
87
|
+
- Fixture IDs and timestamps should be stable.
|
|
88
|
+
- Fixture resource names should include org where useful.
|
|
89
|
+
- Large fixture artifacts should be minimized; prefer digest manifests.
|
|
90
|
+
|
|
91
|
+
## Migration from current layout
|
|
92
|
+
|
|
93
|
+
Current tests in `tests/*.test.js` and `tests/e2e/*.test.js` do not need to move immediately. Migration steps:
|
|
94
|
+
|
|
95
|
+
1. keep existing scripts green;
|
|
96
|
+
2. add new directories when first tests for that layer are created;
|
|
97
|
+
3. move tests only when imports and CI scripts are updated in the same change;
|
|
98
|
+
4. keep `npm test` backwards-compatible or make it run all unit/integration tests;
|
|
99
|
+
5. update docs/tests and package scripts together.
|
|
100
|
+
|
|
101
|
+
## Ownership labels
|
|
102
|
+
|
|
103
|
+
Recommended owners:
|
|
104
|
+
|
|
105
|
+
| Prefix | Area |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `core-*` | resource model, API controller, storage. |
|
|
108
|
+
| `ui-*` | web UI, browser, accessibility. |
|
|
109
|
+
| `runtime-*` | runners, pipelines, jobs, Gitea, hooks. |
|
|
110
|
+
| `deploy-*` | Argo CD, KubeVela, chart/install. |
|
|
111
|
+
| `security-*` | auth, RBAC, secrets, policy, audit. |
|
|
112
|
+
| `agents-*` | agent stacks, Agent Mux, memory, triggers, imports. |
|
|
113
|
+
|
|
114
|
+
## Review checklist
|
|
115
|
+
|
|
116
|
+
- Does the test run without network unless marked live?
|
|
117
|
+
- Does it clean up temporary files/resources?
|
|
118
|
+
- Does it assert org and namespace where relevant?
|
|
119
|
+
- Does it assert stable error codes for failure paths?
|
|
120
|
+
- Does it avoid real secrets and PII?
|
|
121
|
+
- Does it avoid brittle visual or string-only assertions when semantic assertions are possible?
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Unit and integration tests
|
|
2
|
+
|
|
3
|
+
## Unit test targets
|
|
4
|
+
|
|
5
|
+
| Area | Examples |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| Resource model | kind definitions, required spec fields, schema generation, plural names. |
|
|
8
|
+
| Org routing helpers | `orgHref`, route ambiguity, slug handling, breadcrumb construction. |
|
|
9
|
+
| API validation | required fields, stable errors, org mismatch, no-secret responses. |
|
|
10
|
+
| Context assembly | source manifests, digest calculation, redaction ordering, truncation. |
|
|
11
|
+
| Memory utilities | ref resolution, graph/frontmatter parsing, grep result bounding, import normalization. |
|
|
12
|
+
| Auth/RBAC helpers | delegated identity, SubjectAccessReview requests, permission summaries. |
|
|
13
|
+
| Chart/package scripts | required files, CRD coverage, values coverage. |
|
|
14
|
+
| Setup/smoke scripts | deterministic dry-run output and command plans. |
|
|
15
|
+
|
|
16
|
+
## Integration test targets
|
|
17
|
+
|
|
18
|
+
| Boundary | Required tests |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| API controller + fake Kubernetes | list/get/apply/delete resources, org filters, watch setup. |
|
|
21
|
+
| UI model + fake controller | dashboard summaries, org pages, repository pages, run pages. |
|
|
22
|
+
| Controller + fake Gitea | repository create, branch protection, permissions, webhook sync. |
|
|
23
|
+
| Runner + fake Kubernetes | ServiceAccount selection, untrusted fork policy, job lifecycle. |
|
|
24
|
+
| Hook queue + fake delivery | signing, retry, replay, failure status. |
|
|
25
|
+
| Memory import + fake Git repo | read `.a5c`, redact, normalize, validate, open PR. |
|
|
26
|
+
| Agent dispatch + fake Agent Mux | launch, session binding, events, cancel/resume. |
|
|
27
|
+
|
|
28
|
+
## Required negative tests
|
|
29
|
+
|
|
30
|
+
- missing `organizationRef`;
|
|
31
|
+
- namespace does not match org binding;
|
|
32
|
+
- cross-org repository, memory, secret, config, runner, or session ref;
|
|
33
|
+
- denied SubjectAccessReview;
|
|
34
|
+
- missing Secret/ConfigMap grant;
|
|
35
|
+
- untrusted fork tries to access secrets;
|
|
36
|
+
- memory import contains secret-like content;
|
|
37
|
+
- webhook signature mismatch;
|
|
38
|
+
- duplicate repository slug through legacy route;
|
|
39
|
+
- stale memory ref cannot resolve.
|
|
40
|
+
|
|
41
|
+
## Test style
|
|
42
|
+
|
|
43
|
+
- Use table-driven cases for resource and API validation.
|
|
44
|
+
- Keep fixtures small and explicit.
|
|
45
|
+
- Prefer fake adapters over network calls.
|
|
46
|
+
- Assert stable error codes, not only messages.
|
|
47
|
+
- Assert status conditions and audit fields.
|
|
48
|
+
- Assert no secret values appear in responses, logs, snapshots, or artifacts.
|