refactor: 项目更名 WeKnora → Academy
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s

- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名)
- 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块)
- docreader proto 描述符采用等长替换,保持序列化字节布局有效
- Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像
- 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
This commit is contained in:
runny committed 2026-11-13 20:52:51 +08:00
1 parent 9097ee699d
commit 9058149576
3136 files changed
+18018 -18004

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context"
"time"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types/interfaces"
)
// MemoryActivityRegistry shares the binding store's background leases and lock,
@@ -5,9 +5,9 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/background"
"github.com/Tencent/WeKnora/internal/background/backgroundtest"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/background"
"academy/internal/background/backgroundtest"
"academy/internal/types/interfaces"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types/interfaces"
"github.com/redis/go-redis/v9"
)
@@ -5,10 +5,10 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/background/backgroundtest"
"github.com/Tencent/WeKnora/internal/sandbox/admission"
"github.com/Tencent/WeKnora/internal/sandbox/allocation"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/background/backgroundtest"
"academy/internal/sandbox/admission"
"academy/internal/sandbox/allocation"
"academy/internal/types/interfaces"
"github.com/alicebob/miniredis/v2"
"github.com/stretchr/testify/require"
)
@@ -31,8 +31,8 @@ func TestRedisActivityRegistryContract(t *testing.T) {
func TestRedisActivityRegistryUsesBindingHashTag(t *testing.T) {
store, _, _ := newRedisBindingTestStore(t)
key := SessionSandboxKey{TenantID: 7, SessionID: "s1"}
require.Equal(t, "weknora:sandbox:session:{test:7:s1}:activity", store.activityKey(key))
require.Equal(t, "weknora:sandbox:session:{test:7:s1}:turn", store.turnKey(key))
require.Equal(t, "academy:sandbox:session:{test:7:s1}:activity", store.activityKey(key))
require.Equal(t, "academy:sandbox:session:{test:7:s1}:turn", store.turnKey(key))
}
func TestRedisActivityRegistryRejectsInvalidSession(t *testing.T) {
@@ -53,9 +53,9 @@ func newSharedActivityManagers(
allocs := newFakeAllocations(userAssignmentFor(userSessionA), userAssignmentFor(userSessionB))
remote := newFakeRemoteClient(SandboxTypeCube)
h1 := newUserManagerHarnessWithDirectory(t, remote, store,
admission.NewRedis(client, "weknora:sandbox:user:"), allocs, store.namespace)
admission.NewRedis(client, "academy:sandbox:user:"), allocs, store.namespace)
h2 := newUserManagerHarnessWithDirectory(t, remote, other,
admission.NewRedis(client, "weknora:sandbox:user:"), allocs, store.namespace)
admission.NewRedis(client, "academy:sandbox:user:"), allocs, store.namespace)
return h1, h2, NewRedisActivityRegistry(store).WithAllocations(allocs), mini
}
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require"
)
const prefix = "weknora:sandbox:user:"
const prefix = "academy:sandbox:user:"
func newRedis(t *testing.T) (*RedisRegistry, *miniredis.Miniredis) {
t.Helper()
+2 -2
View File
@@ -6,7 +6,7 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/common/redislock"
"academy/internal/common/redislock"
"github.com/redis/go-redis/v9"
)
@@ -63,7 +63,7 @@ type RedisRegistry struct {
}
// NewRedis builds a registry whose keys start with keyPrefix, e.g.
// "weknora:sandbox:user:", matching the user binding keys.
// "academy:sandbox:user:", matching the user binding keys.
func NewRedis(client redis.UniversalClient, keyPrefix string) *RedisRegistry {
return &RedisRegistry{client: client, prefix: keyPrefix}
}
@@ -10,11 +10,11 @@ import (
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/require"
"github.com/Tencent/WeKnora/internal/sandbox/admission"
"academy/internal/sandbox/admission"
)
// integrationEnv returns an integration dependency's address. Missing, the
// test is skipped — unless WEKNORA_REQUIRE_INTEGRATION=1, which turns the
// test is skipped — unless ACADEMY_REQUIRE_INTEGRATION=1, which turns the
// skip into a failure so an enablement run cannot pass by skipping.
func integrationEnv(t *testing.T, name string) string {
t.Helper()
@@ -22,17 +22,17 @@ func integrationEnv(t *testing.T, name string) string {
if v != "" {
return v
}
if os.Getenv("WEKNORA_REQUIRE_INTEGRATION") == "1" {
t.Fatalf("%s is required when WEKNORA_REQUIRE_INTEGRATION=1", name)
if os.Getenv("ACADEMY_REQUIRE_INTEGRATION") == "1" {
t.Fatalf("%s is required when ACADEMY_REQUIRE_INTEGRATION=1", name)
}
t.Skipf("set %s to run against a real dependency", name)
return ""
}
// realRedisPair dials WEKNORA_TEST_REDIS_ADDR twice. prefix isolates this run.
// realRedisPair dials ACADEMY_TEST_REDIS_ADDR twice. prefix isolates this run.
func realRedisPair(t *testing.T) (c1, c2 *admission.RedisRegistry, raw *redis.Client, prefix string) {
t.Helper()
addr := integrationEnv(t, "WEKNORA_TEST_REDIS_ADDR")
addr := integrationEnv(t, "ACADEMY_TEST_REDIS_ADDR")
prefix = "it-" + uuid.NewString() + ":"
open := func() *redis.Client {
rc := redis.NewClient(&redis.Options{Addr: addr})
@@ -112,9 +112,9 @@ func TestEligibleForUser(t *testing.T) {
func TestUserMachineDigestIsStableAndUnambiguous(t *testing.T) {
m := UserMachine{OwnerTenantID: 7, OwnerID: "u-1", ConfigTenantID: 9, ConfigID: "cfg"}
require.NoError(t, m.Validate())
d := m.Digest("weknora")
d := m.Digest("academy")
require.Len(t, d, 64)
require.Equal(t, d, m.Digest("weknora"))
require.Equal(t, d, m.Digest("academy"))
require.NotEqual(t, d, m.Digest("other"))
// Length-prefixing keeps field boundaries: these two must not collide.
a := UserMachine{OwnerTenantID: 7, OwnerID: "ab", ConfigTenantID: 9, ConfigID: "c"}
+1 -1
View File
@@ -3,7 +3,7 @@ package allocation
import (
"time"
"github.com/Tencent/WeKnora/internal/sandbox/workspace"
"academy/internal/sandbox/workspace"
)
// Assignment is the persisted placement of one session. Only the config
+1 -1
View File
@@ -8,7 +8,7 @@ import (
// UserModeEnvVar opts a deployment into user-mode allocation. It must be set
// on every replica before any config is switched to "user".
const UserModeEnvVar = "WEKNORA_SANDBOX_USER_ALLOCATION"
const UserModeEnvVar = "ACADEMY_SANDBOX_USER_ALLOCATION"
var userModeAvailable atomic.Bool
+1 -1
View File
@@ -48,7 +48,7 @@ func (m UserMachine) Digest(namespace string) string {
h.Write(n[:])
h.Write([]byte(s))
}
write("weknora-user-sandbox/v1")
write("academy-user-sandbox/v1")
write(namespace)
write(strconv.FormatUint(m.OwnerTenantID, 10))
write(m.OwnerID)
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"strings"
"unicode"
"github.com/Tencent/WeKnora/internal/sandbox/workspace"
"academy/internal/sandbox/workspace"
)
// OwnerKind classifies who sessions.user_id names.
+1 -1
View File
@@ -19,7 +19,7 @@
package sandbox
import (
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// SandboxIdentity is the comparable projection of a config: two configs with
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// Identity comes from the stored row alone. Nothing about the deployment can
+1 -1
View File
@@ -17,7 +17,7 @@ import (
"strconv"
"strings"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// ConfigSandboxLister is the read half of the provider client.
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// fakeConfigSandboxClient records the filters it was asked for and serves a
+10 -10
View File
@@ -27,7 +27,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
const (
@@ -263,8 +263,8 @@ func TestIntegrationCubeClient_LifecycleRoundTrip(t *testing.T) {
})
// Write a file inside the sandbox.
path := "/tmp/weknora-integration.txt"
payload := []byte("hello from weknora integration\n")
path := "/tmp/academy-integration.txt"
payload := []byte("hello from academy integration\n")
if err := client.WriteFile(ctx, handle, path, payload); err != nil {
t.Fatalf("WriteFile: %v", err)
}
@@ -291,7 +291,7 @@ func TestIntegrationCubeClient_LifecycleRoundTrip(t *testing.T) {
if result.ExitCode != 0 {
t.Fatalf("Exec exit code: %d stderr=%q", result.ExitCode, result.Stderr)
}
if !strings.Contains(result.Stdout, "hello from weknora integration") {
if !strings.Contains(result.Stdout, "hello from academy integration") {
t.Fatalf("stdout missing marker: %q", result.Stdout)
}
@@ -342,7 +342,7 @@ func TestIntegrationCubeClient_FilesystemOps(t *testing.T) {
_ = client.Delete(cleanupCtx, handle.ID())
})
base := "/tmp/weknora-fs"
base := "/tmp/academy-fs"
if err := client.MakeDir(ctx, handle, base); err != nil {
t.Fatalf("MakeDir %s: %v", base, err)
}
@@ -422,7 +422,7 @@ func TestIntegrationCubeClient_FilesystemOps(t *testing.T) {
// sandboxes present per Execute.
func TestIntegrationRemoteSandbox_EphemeralExecute(t *testing.T) {
mgr := newIntegrationManager(t)
script := writeIntegrationScript(t, "hello.py", "print('weknora-integration-hi')\n")
script := writeIntegrationScript(t, "hello.py", "print('academy-integration-hi')\n")
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
@@ -437,7 +437,7 @@ func TestIntegrationRemoteSandbox_EphemeralExecute(t *testing.T) {
if result.ExitCode != 0 {
t.Fatalf("exit code %d stderr=%q err=%q", result.ExitCode, result.Stderr, result.Error)
}
if !strings.Contains(result.Stdout, "weknora-integration-hi") {
if !strings.Contains(result.Stdout, "academy-integration-hi") {
t.Fatalf("stdout missing expected marker: %q", result.Stdout)
}
}
@@ -454,13 +454,13 @@ func TestIntegrationSessionBoundManager_StatePersistsAcrossExecutes(t *testing.T
ctx := integrationTenantContext(baseCtx)
first := writeIntegrationScript(t, "write.py", strings.Join([]string{
"with open('/tmp/weknora-session-marker', 'w') as f:",
"with open('/tmp/academy-session-marker', 'w') as f:",
" f.write('session-state-ok')",
"print('wrote marker')",
"",
}, "\n"))
second := writeIntegrationScript(t, "read.py", strings.Join([]string{
"with open('/tmp/weknora-session-marker') as f:",
"with open('/tmp/academy-session-marker') as f:",
" print('marker=' + f.read())",
"",
}, "\n"))
@@ -489,7 +489,7 @@ func TestIntegrationSessionBoundManager_StatePersistsAcrossExecutes(t *testing.T
// regression that collapses all sessions onto the same VM slip by.
miss := writeIntegrationScript(t, "miss.py", strings.Join([]string{
"import os",
"print('exists=' + str(os.path.exists('/tmp/weknora-session-marker')))",
"print('exists=' + str(os.path.exists('/tmp/academy-session-marker')))",
"",
}, "\n"))
r3, err := mgr.Execute(ctx, &ExecuteConfig{
+11 -11
View File
@@ -17,7 +17,7 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/logger"
"github.com/gorilla/websocket"
cubesandbox "github.com/tencentcloud/CubeSandbox/sdk/go"
)
@@ -204,7 +204,7 @@ func (c *CubeRemoteClient) ListTemplates(ctx context.Context) ([]RemoteTemplate,
// Cube only reports a name when the template carries an alias, so fall
// back to the image before falling back to the opaque ID: recognising
// our own template is what keeps EnsureStandardTemplate idempotent.
standard, desktop := classifyWeKnoraTemplate(name, item.ImageInfo)
standard, desktop := classifyAcademyTemplate(name, item.ImageInfo)
if name == "" {
switch {
case desktop:
@@ -263,7 +263,7 @@ func cubeTemplateIsSnapshot(templateID string, snapshotIDs map[string]struct{})
return ok
}
// EnsureStandardTemplate makes the cluster hold exactly one WeKnora template.
// EnsureStandardTemplate makes the cluster hold exactly one Academy template.
// A healthy or still-building one is returned as is; a failed one is rebuilt in
// place. If CubeMaster refuses the redo, the failed card is returned as-is;
// ReplaceStandardTemplate (the settings-page "delete and rebuild" action) is
@@ -291,7 +291,7 @@ func (c *CubeRemoteClient) EnsureStandardTemplate(ctx context.Context) (*RemoteT
return c.buildStandardTemplate(ctx)
}
// ReplaceStandardTemplate applies the current spec to the cluster's WeKnora
// ReplaceStandardTemplate applies the current spec to the cluster's Academy
// template. Cube bakes DNS into the template, so a READY template only picks
// up a settings change via rebuild (preferred: same ID) or a replacement.
//
@@ -331,7 +331,7 @@ func (c *CubeRemoteClient) ReplaceStandardTemplate(ctx context.Context) (*Remote
return c.buildStandardTemplate(ctx)
}
// EnsureDesktopTemplate returns the cluster's WeKnora desktop template,
// EnsureDesktopTemplate returns the cluster's Academy desktop template,
// rebuilding a failed one or building it when absent. A cluster may hold
// both the CLI and desktop templates; the admin picks which ID a config boots.
func (c *CubeRemoteClient) EnsureDesktopTemplate(ctx context.Context) (*RemoteTemplate, error) {
@@ -414,7 +414,7 @@ func (c *CubeRemoteClient) DeleteSupersededDesktopTemplates(ctx context.Context,
return nil
}
// DeleteSupersededStandardTemplates drops WeKnora templates other than keepID.
// DeleteSupersededStandardTemplates drops Academy templates other than keepID.
func (c *CubeRemoteClient) DeleteSupersededStandardTemplates(ctx context.Context, keepID string) error {
keepID = strings.TrimSpace(keepID)
if keepID == "" {
@@ -607,7 +607,7 @@ func (c *CubeRemoteClient) desktopTemplateSpec() map[string]any {
return cubeDesktopTemplateSpec(dns)
}
// cubeStandardTemplateSpec is the single definition of how the WeKnora template
// cubeStandardTemplateSpec is the single definition of how the Academy template
// is built. Both the first build and every rebuild send it verbatim — the
// rebuild endpoint takes a raw payload rather than BuildTemplateOptions, and
// two hand-kept copies of the spec would eventually disagree.
@@ -636,7 +636,7 @@ func cubeStandardTemplateSpec(dns []string) map[string]any {
// standard template can never silently alter the desktop's exposed ports.
//
// 6080 is deliberately not in exposedPorts. Cube maps that list through eBPF
// static NAT on the host NIC, which bypasses CubeProxy. WeKnora already
// static NAT on the host NIC, which bypasses CubeProxy. Academy already
// reaches websockify the same way it reaches envd: CubeProxy Host
// "{port}-{id}.{domain}" plus the inbound token. Publishing 6080 on the host
// would let anyone who can read /run/desktop/secret (the agent Execs as
@@ -704,7 +704,7 @@ func (c *CubeRemoteClient) Create(
network.AllowInternetAccess = &defaultOn
}
// Deliberately the opposite of Cube's own default. Cube leaves the
// sandbox URL reachable by anyone who knows the ID; WeKnora closes it and
// sandbox URL reachable by anyone who knows the ID; Academy closes it and
// relies on the per-sandbox traffic token, which the SDK attaches to
// data-plane requests for us. Do not change this to true.
if network.AllowPublicTraffic == nil {
@@ -1023,7 +1023,7 @@ func (c *CubeRemoteClient) ListDir(
}
// normaliseFileType maps envd's proto enum strings ("FILE_TYPE_FILE",
// "FILE_TYPE_DIRECTORY", …) onto the short lowercase names WeKnora already
// "FILE_TYPE_DIRECTORY", …) onto the short lowercase names Academy already
// stores.
func normaliseFileType(t string) string {
switch strings.ToUpper(t) {
@@ -1294,7 +1294,7 @@ func buildShellLine(cmd string, args []string) string {
// callers actually need to pipe data.
func wrapWithStdin(line, stdin string) string {
// Use a heredoc delimiter unlikely to appear in caller data.
const delim = "WEKNORA_STDIN_EOF"
const delim = "ACADEMY_STDIN_EOF"
// Escape lines containing the delimiter defensively.
safe := strings.ReplaceAll(stdin, delim, "")
return "cat <<'" + delim + "' | " + line + "\n" + safe + "\n" + delim
+8 -8
View File
@@ -9,7 +9,7 @@ import (
cubesandbox "github.com/tencentcloud/CubeSandbox/sdk/go"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -67,15 +67,15 @@ func TestCubeRemoteClientCreateSnapshot(t *testing.T) {
handle, err := client.Create(ctx, RemoteCreateRequest{TemplateID: "template-a"})
require.NoError(t, err)
ref, err := client.CreateSnapshot(ctx, handle.ID(), "weknora-sk-cfg1-g1")
ref, err := client.CreateSnapshot(ctx, handle.ID(), "academy-sk-cfg1-g1")
require.NoError(t, err)
require.Equal(t, "snap-1", ref.ID)
require.Equal(t, []string{"weknora-sk-cfg1-g1"}, ref.Names)
require.Equal(t, []string{"academy-sk-cfg1-g1"}, ref.Names)
mock.mu.Lock()
body := mock.snapshotCreateBody
mock.mu.Unlock()
require.Equal(t, "weknora-sk-cfg1-g1", body["name"])
require.Equal(t, "academy-sk-cfg1-g1", body["name"])
}
func TestCubeRemoteClientCreateSnapshotRejectsEmptySandboxID(t *testing.T) {
@@ -137,9 +137,9 @@ func TestCubeRemoteClientListSnapshotsPagesAllResults(t *testing.T) {
require.NoError(t, err)
second, err := client.Create(ctx, RemoteCreateRequest{TemplateID: "template-a"})
require.NoError(t, err)
firstRef, err := client.CreateSnapshot(ctx, first.ID(), "weknora-sk-cfg1-g1")
firstRef, err := client.CreateSnapshot(ctx, first.ID(), "academy-sk-cfg1-g1")
require.NoError(t, err)
secondRef, err := client.CreateSnapshot(ctx, first.ID(), "weknora-sk-cfg2-g1")
secondRef, err := client.CreateSnapshot(ctx, first.ID(), "academy-sk-cfg2-g1")
require.NoError(t, err)
_, err = client.CreateSnapshot(ctx, second.ID(), "other")
require.NoError(t, err)
@@ -287,7 +287,7 @@ func TestCubeRemoteClientCreateForwardsNetworkPolicy(t *testing.T) {
require.Equal(t, false, second["action"].(map[string]any)["allow"])
}
// WeKnora's default deliberately differs from Cube's: an unspecified policy
// Academy's default deliberately differs from Cube's: an unspecified policy
// closes inbound access, because "anyone who knows the sandbox ID" used to be
// the only barrier in front of the sandbox URL. Egress stays open so skill
// installs keep working.
@@ -322,7 +322,7 @@ func TestCubeRemoteHandleExposesTrafficAccessToken(t *testing.T) {
}
// The provider issues the traffic token once, at create time. Everything that
// re-attaches later — auto-resume, a WeKnora restart, an artifact download —
// re-attaches later — auto-resume, a Academy restart, an artifact download —
// has to put it back or every data-plane call answers 403.
func TestCubeRemoteClientConnectRestoresTrafficAccessToken(t *testing.T) {
mock := newCubeMockServer(t)
+13 -13
View File
@@ -180,13 +180,13 @@ func TestCubeRemoteClientListTemplatesHidesSnapPrefixedIDs(t *testing.T) {
client := newCubeTemplateClient(t, cubeCatalogHandler(
[]map[string]any{
{
"templateID": "tpl-weknora",
"name": "weknora",
"templateID": "tpl-academy",
"name": "academy",
"status": "READY",
},
{
"templateID": "snap-1546901f7e5e40bdb8794c78",
"aliases": []string{"weknora-sk-c838ac20-g2"},
"aliases": []string{"academy-sk-c838ac20-g2"},
"status": "READY",
},
{
@@ -200,7 +200,7 @@ func TestCubeRemoteClientListTemplatesHidesSnapPrefixedIDs(t *testing.T) {
templates, err := client.ListTemplates(context.Background())
require.NoError(t, err)
require.Len(t, templates, 1)
require.Equal(t, "tpl-weknora", templates[0].ID)
require.Equal(t, "tpl-academy", templates[0].ID)
}
// Snapshot IDs that do not use the snap- prefix still belong to GET
@@ -208,18 +208,18 @@ func TestCubeRemoteClientListTemplatesHidesSnapPrefixedIDs(t *testing.T) {
func TestCubeRemoteClientListTemplatesHidesListedSnapshots(t *testing.T) {
client := newCubeTemplateClient(t, cubeCatalogHandler(
[]map[string]any{
{"templateID": "tpl-weknora", "name": "weknora", "status": "READY"},
{"templateID": "abc123unprefixed", "aliases": []string{"weknora-sk-cfg-g1"}, "status": "READY"},
{"templateID": "tpl-academy", "name": "academy", "status": "READY"},
{"templateID": "abc123unprefixed", "aliases": []string{"academy-sk-cfg-g1"}, "status": "READY"},
},
[]map[string]any{
{"snapshotID": "abc123unprefixed", "names": []string{"weknora-sk-cfg-g1"}},
{"snapshotID": "abc123unprefixed", "names": []string{"academy-sk-cfg-g1"}},
},
))
templates, err := client.ListTemplates(context.Background())
require.NoError(t, err)
require.Len(t, templates, 1)
require.Equal(t, "tpl-weknora", templates[0].ID)
require.Equal(t, "tpl-academy", templates[0].ID)
}
func TestCubeRemoteClientListTemplatesKeepsTemplatesWhenSnapshotListFails(t *testing.T) {
@@ -227,7 +227,7 @@ func TestCubeRemoteClientListTemplatesKeepsTemplatesWhenSnapshotListFails(t *tes
switch r.URL.Path {
case "/templates":
writeJSON(w, http.StatusOK, []map[string]any{
{"templateID": "tpl-weknora", "status": "READY"},
{"templateID": "tpl-academy", "status": "READY"},
{"templateID": "snap-orphan", "status": "READY"},
})
case "/snapshots":
@@ -240,7 +240,7 @@ func TestCubeRemoteClientListTemplatesKeepsTemplatesWhenSnapshotListFails(t *tes
templates, err := client.ListTemplates(context.Background())
require.NoError(t, err)
require.Len(t, templates, 1)
require.Equal(t, "tpl-weknora", templates[0].ID)
require.Equal(t, "tpl-academy", templates[0].ID)
}
func TestCubeTemplateIsSnapshot(t *testing.T) {
@@ -248,7 +248,7 @@ func TestCubeTemplateIsSnapshot(t *testing.T) {
require.True(t, cubeTemplateIsSnapshot("snap-1", nil))
require.True(t, cubeTemplateIsSnapshot("SNAP-1", nil))
require.True(t, cubeTemplateIsSnapshot("listed-id", listed))
require.False(t, cubeTemplateIsSnapshot("tpl-weknora", listed))
require.False(t, cubeTemplateIsSnapshot("tpl-academy", listed))
require.False(t, cubeTemplateIsSnapshot("", listed))
}
@@ -271,7 +271,7 @@ func cubeCatalogHandler(templates, snapshots []map[string]any) http.HandlerFunc
}
}
// The bug this guards: an unnamed WeKnora template was invisible to the
// The bug this guards: an unnamed Academy template was invisible to the
// idempotency check, so every visit to the template step queued another build.
func TestCubeRemoteClientEnsureStandardTemplateSkipsBuildForNamelessTemplate(t *testing.T) {
var builds atomic.Int32
@@ -597,7 +597,7 @@ func TestIsStandardTemplateImage(t *testing.T) {
"",
"python:3.11",
"wechatopenai/weknora-docreader:latest",
"someone-else/weknora-sandbox:latest",
"someone-else/academy-sandbox:latest",
} {
require.False(t, isStandardTemplateImage(image), image)
}
+2 -2
View File
@@ -19,7 +19,7 @@ var _ RemoteTerminalManager = (*CubeRemoteClient)(nil)
// cubeTerminalTimeout bounds the envd stream server-side (Connect-Timeout-Ms)
// and client-side (idle abort). The SDK treats <= 0 as "use its 60s default",
// which would silently kill idle terminals, so WeKnora always passes an
// which would silently kill idle terminals, so Academy always passes an
// explicit long window. A session hitting it ends; the frontend reconnects
// and reattaches by PID when the shell is still running.
const cubeTerminalTimeout = 24 * time.Hour
@@ -170,7 +170,7 @@ func (s *cubeTerminalSession) Resize(ctx context.Context, cols, rows uint32) err
return nil
}
// Close disconnects WeKnora from the PTY without killing the remote shell,
// Close disconnects Academy from the PTY without killing the remote shell,
// leaving it reattachable via Pty.Connect. Wait unblocks through the
// disconnect without recording a stream error.
func (s *cubeTerminalSession) Close() error {
+1 -1
View File
@@ -28,7 +28,7 @@ const DesktopEnsureUnsupportedExit = 2
// DesktopEnsureUnsupportedMarker is written to stderr immediately before
// that exit 2. Go must see both or the failure is a broken wrapper, not
// a BYO image without a desktop.
const DesktopEnsureUnsupportedMarker = "WEKNORA_DESKTOP_UNSUPPORTED"
const DesktopEnsureUnsupportedMarker = "ACADEMY_DESKTOP_UNSUPPORTED"
var desktopReadyLine = regexp.MustCompile(`^READY ([A-Za-z0-9]{32})$`)
+1 -1
View File
@@ -172,7 +172,7 @@ func TestDesktopEnsureCmdDetachesDaemonStdio(t *testing.T) {
require.Contains(t, code, ">>\"$log\" 2>&1")
require.Contains(t, code, "tail -c")
require.Contains(t, code, `printf 'READY %s\n' "$secret"`)
require.Contains(t, code, "WEKNORA_DESKTOP_UNSUPPORTED")
require.Contains(t, code, "ACADEMY_DESKTOP_UNSUPPORTED")
require.Contains(t, code, "exit 2")
require.NotContains(t, code, "pkill")
}
+2 -2
View File
@@ -2,7 +2,7 @@
# One Exec: prove the image has a desktop, start it, print the websockify secret.
#
# exit 2 — start-desktop.sh missing. stderr MUST contain
# WEKNORA_DESKTOP_UNSUPPORTED; POSIX sh also uses 2 for
# ACADEMY_DESKTOP_UNSUPPORTED; POSIX sh also uses 2 for
# syntax errors, so Go ignores a bare 2.
# exit 1 — start failed or listeners never came up
# exit 0 — stdout is exactly one line: READY <32 alnum>
@@ -13,7 +13,7 @@
set -u
if [ ! -x /usr/local/bin/start-desktop.sh ]; then
echo WEKNORA_DESKTOP_UNSUPPORTED >&2
echo ACADEMY_DESKTOP_UNSUPPORTED >&2
exit 2
fi
+2 -2
View File
@@ -16,7 +16,7 @@ import (
// whatever Engine API this process can reach — typically the host's
// docker.sock, which is host root. It is therefore off until a
// SystemAdmin or deployer opts in.
const DockerBackendEnabledEnv = "WEKNORA_SANDBOX_DOCKER_ENABLED"
const DockerBackendEnabledEnv = "ACADEMY_SANDBOX_DOCKER_ENABLED"
// DockerBackendEnabledSettingKey is the system_settings registry key.
const DockerBackendEnabledSettingKey = "sandbox.docker_enabled"
@@ -24,7 +24,7 @@ const DockerBackendEnabledSettingKey = "sandbox.docker_enabled"
// ErrDockerBackendDisabled is returned when a Docker sandbox config is saved,
// probed, or resolved and the process has not opted in.
var ErrDockerBackendDisabled = errors.New(
"sandbox: docker backend is disabled; enable it in System Settings or set WEKNORA_SANDBOX_DOCKER_ENABLED=true",
"sandbox: docker backend is disabled; enable it in System Settings or set ACADEMY_SANDBOX_DOCKER_ENABLED=true",
)
// dockerBackendEnabledOverride is the runtime-tunable source. Nil means
+7 -7
View File
@@ -1,6 +1,6 @@
// Docker Engine plumbing for the docker backend.
//
// This file owns everything between WeKnora and the Docker Engine API that is
// This file owns everything between Academy and the Docker Engine API that is
// not sandbox semantics: the narrow interface the adapter talks to (so unit
// tests need no daemon), how a daemon connection is built and shared, and how
// Engine errors are classified into the provider-neutral RemoteErrorKind.
@@ -239,7 +239,7 @@ func newDockerEngineClient(endpoint dockerEndpoint) (*client.Client, error) {
}
// dockerHostNeedsDialGuard reports whether host is a network endpoint whose
// dials must pass the outbound policy. Unix sockets are local to the WeKnora
// dials must pass the outbound policy. Unix sockets are local to the Academy
// process and carry no address to check.
func dockerHostNeedsDialGuard(host string) bool {
scheme, _, found := strings.Cut(strings.TrimSpace(host), "://")
@@ -258,7 +258,7 @@ func dockerHostNeedsDialGuard(host string) bool {
//
// A TCP endpoint gets the same outbound treatment as any other workspace-
// supplied URL: a daemon socket accepts container creation, so an admin who
// can point it anywhere can make WeKnora talk to an arbitrary internal
// can point it anywhere can make Academy talk to an arbitrary internal
// service. Unix sockets are local by definition and only have to be absolute.
func ValidateDockerHost(host string, allowPrivate bool) error {
trimmed := strings.TrimSpace(host)
@@ -290,7 +290,7 @@ func ValidateDockerHost(host string, allowPrivate bool) error {
// ValidateDockerRemoteTLS requires client certificates for a TCP daemon.
// A remote Engine API that accepts container creation is a root shell on
// that host; plaintext tcp://2375 is not an acceptable way to reach it.
// Unix sockets are local to the WeKnora process and do not use TLS.
// Unix sockets are local to the Academy process and do not use TLS.
func ValidateDockerRemoteTLS(host, tlsCertPath string) error {
trimmed := strings.TrimSpace(host)
if trimmed == "" {
@@ -313,7 +313,7 @@ func ValidateDockerRemoteTLS(host, tlsCertPath string) error {
// ValidateDockerNetworkMode allows only bridge (egress) and none (no egress).
//
// host and container: modes share another namespace outright, which would put
// sandbox code on the WeKnora host's or a sibling container's network. A
// sandbox code on the Academy host's or a sibling container's network. A
// user-defined network name is refused for the weaker but equally real version
// of the same problem: the usual deployment reaches its daemon through the
// mounted docker.sock, so naming the deployment's own compose network would
@@ -455,9 +455,9 @@ func dockerSandboxMetadata(labels map[string]string) map[string]string {
}
// dockerManagedLabel marks every container this backend creates. Sweeps filter
// on it so a WeKnora deployment sharing a daemon with other workloads can
// on it so a Academy deployment sharing a daemon with other workloads can
// never delete a container it does not own.
const dockerManagedLabel = "com.weknora.sandbox.managed"
const dockerManagedLabel = "com.academy.sandbox.managed"
// dockerContainerStartedAt parses the daemon's RFC3339Nano timestamps, which
// are the zero value string "0001-01-01T00:00:00Z" when unset.
+3 -3
View File
@@ -27,14 +27,14 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/logger"
"github.com/moby/moby/client"
)
// dockerIdleTTLLabel records the TTL each container was created with, so a
// sweep triggered by one workspace config never applies its own TTL to a
// container belonging to another.
const dockerIdleTTLLabel = "com.weknora.sandbox.idle-ttl-seconds"
const dockerIdleTTLLabel = "com.academy.sandbox.idle-ttl-seconds"
// dockerSweepMinInterval bounds how often one daemon is swept, no matter how
// many requests trigger it. Sweeping is a list plus one stat per container;
@@ -200,7 +200,7 @@ func (s *dockerIdleSweeper) lastActivity(
return summary.StartedAt.UTC()
}
// dockerActivityClockSkew is how far ahead of WeKnora the daemon's clock may
// dockerActivityClockSkew is how far ahead of Academy the daemon's clock may
// run before a marker is treated as forged. The marker is stamped by the
// daemon host while the comparison happens here, and the two are not
// necessarily the same machine.
+1 -1
View File
@@ -95,7 +95,7 @@ func TestDockerIdleSweeperRejectsFutureActivityMarker(t *testing.T) {
require.Equal(t, []string{"forged"}, engine.removed)
}
// A daemon on another host may run slightly ahead of WeKnora. That must not be
// A daemon on another host may run slightly ahead of Academy. That must not be
// mistaken for tampering, or every sandbox on that daemon would be judged by
// its start time alone and reclaimed mid-session.
func TestDockerIdleSweeperToleratesSmallClockSkew(t *testing.T) {
+18 -18
View File
@@ -35,9 +35,9 @@ import (
"github.com/moby/moby/client"
"github.com/redis/go-redis/v9"
"github.com/Tencent/WeKnora/internal/sandbox/admission"
"github.com/Tencent/WeKnora/internal/sandbox/allocation"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/sandbox/admission"
"academy/internal/sandbox/allocation"
"academy/internal/types"
)
const dockerIntegrationTenantID = 1
@@ -66,7 +66,7 @@ func newDockerIntegrationManager(t *testing.T, cfg *Config) *SessionBoundManager
probeCtx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
if err := client.Health(probeCtx); err != nil {
if os.Getenv("WEKNORA_REQUIRE_INTEGRATION") == "1" {
if os.Getenv("ACADEMY_REQUIRE_INTEGRATION") == "1" {
t.Fatalf("docker daemon unreachable: %v", err)
}
t.Skipf("docker daemon unreachable: %v", err)
@@ -592,7 +592,7 @@ func TestDockerSkillSnapshotIntegration(t *testing.T) {
probeCtx, cancelProbe := context.WithTimeout(context.Background(), 15*time.Second)
defer cancelProbe()
if err := client.Health(probeCtx); err != nil {
if os.Getenv("WEKNORA_REQUIRE_INTEGRATION") == "1" {
if os.Getenv("ACADEMY_REQUIRE_INTEGRATION") == "1" {
t.Fatalf("docker daemon unreachable: %v", err)
}
t.Skipf("docker daemon unreachable: %v", err)
@@ -609,7 +609,7 @@ func TestDockerSkillSnapshotIntegration(t *testing.T) {
builder, err := client.Create(ctx, RemoteCreateRequest{
TemplateID: cfg.DockerImage,
Metadata: map[string]string{"weknora.test": "skill-snapshot"},
Metadata: map[string]string{"academy.test": "skill-snapshot"},
})
if err != nil {
t.Fatalf("Create builder: %v", err)
@@ -636,7 +636,7 @@ func TestDockerSkillSnapshotIntegration(t *testing.T) {
t.Fatalf("seed skill tree: err=%v result=%#v", err, seed)
}
ref, err := client.CreateSnapshot(ctx, builder.ID(), "weknora-sk-itest-g1")
ref, err := client.CreateSnapshot(ctx, builder.ID(), "academy-sk-itest-g1")
if err != nil {
t.Fatalf("CreateSnapshot: %v", err)
}
@@ -655,7 +655,7 @@ func TestDockerSkillSnapshotIntegration(t *testing.T) {
booted, err := client.Create(ctx, RemoteCreateRequest{
TemplateID: ref.ID,
Metadata: map[string]string{"weknora.test": "skill-snapshot-boot"},
Metadata: map[string]string{"academy.test": "skill-snapshot-boot"},
})
if err != nil {
t.Fatalf("Create from snapshot: %v", err)
@@ -892,7 +892,7 @@ func TestDockerBackendTerminalCloseTerminatesShellIntegration(t *testing.T) {
// Record the shell PID and start a long foreground job with a unique
// marker so the probe can find the job without matching itself.
if err := session.Write(ctx, []byte("echo $$ > /tmp/weknora-close.pid\n")); err != nil {
if err := session.Write(ctx, []byte("echo $$ > /tmp/academy-close.pid\n")); err != nil {
t.Fatalf("write pid: %v", err)
}
// A job the user detached on purpose must outlive the hangup, as it would
@@ -909,7 +909,7 @@ func TestDockerBackendTerminalCloseTerminatesShellIntegration(t *testing.T) {
var shellPID string
for deadline := time.Now().Add(15 * time.Second); time.Now().Before(deadline); {
shellPID = strings.TrimSpace(terminalProbeOutput(
t, ctx, executor, sessionID, "cat /tmp/weknora-close.pid 2>/dev/null || true"))
t, ctx, executor, sessionID, "cat /tmp/academy-close.pid 2>/dev/null || true"))
if shellPID != "" && terminalProbeJobAlive(t, ctx, executor, sessionID, "sleep 3611") {
break
}
@@ -998,7 +998,7 @@ func TestDockerBackendTerminalContextCancelTerminatesShellIntegration(t *testing
}
}()
if err := session.Write(sessionCtx, []byte("echo $$ > /tmp/weknora-cancel.pid\n")); err != nil {
if err := session.Write(sessionCtx, []byte("echo $$ > /tmp/academy-cancel.pid\n")); err != nil {
t.Fatalf("write pid: %v", err)
}
if err := session.Write(sessionCtx, []byte("sleep 3613\n")); err != nil {
@@ -1008,7 +1008,7 @@ func TestDockerBackendTerminalContextCancelTerminatesShellIntegration(t *testing
var shellPID string
for deadline := time.Now().Add(15 * time.Second); time.Now().Before(deadline); {
shellPID = strings.TrimSpace(terminalProbeOutput(
t, probeCtx, executor, sessionID, "cat /tmp/weknora-cancel.pid 2>/dev/null || true"))
t, probeCtx, executor, sessionID, "cat /tmp/academy-cancel.pid 2>/dev/null || true"))
if shellPID != "" && terminalProbeJobAlive(t, probeCtx, executor, sessionID, "sleep 3613") {
break
}
@@ -1093,8 +1093,8 @@ func dockerCheckpointScript(l WorkspaceLayout, messageID string) string {
git_ws rev-parse --git-dir >/dev/null 2>&1 || {
mkdir -p "$(dirname "$GIT_DIR")"
git_ws init -q
git_ws config user.email agent@weknora.local
git_ws config user.name 'WeKnora Agent'
git_ws config user.email agent@academy.local
git_ws config user.name 'Academy Agent'
}
git_ws add -A
git_ws commit -q --allow-empty -m 'turn:%s'
@@ -1158,7 +1158,7 @@ func requireDockerContainerGone(t *testing.T, ctx context.Context, id string) {
func TestDockerUserMachineSharesContainerAndIsolatesDirectories(t *testing.T) {
cfg := dockerIntegrationConfig(t)
redisAddr := integrationEnv(t, "WEKNORA_TEST_REDIS_ADDR")
redisAddr := integrationEnv(t, "ACADEMY_TEST_REDIS_ADDR")
remote, err := NewDockerRemoteClient(cfg)
if err != nil {
t.Fatalf("build docker client: %v", err)
@@ -1167,14 +1167,14 @@ func TestDockerUserMachineSharesContainerAndIsolatesDirectories(t *testing.T) {
probeCtx, cancelProbe := context.WithTimeout(context.Background(), 15*time.Second)
defer cancelProbe()
if err := remote.Health(probeCtx); err != nil {
if os.Getenv("WEKNORA_REQUIRE_INTEGRATION") == "1" {
if os.Getenv("ACADEMY_REQUIRE_INTEGRATION") == "1" {
t.Fatalf("docker daemon unreachable: %v", err)
}
t.Skipf("docker daemon unreachable: %v", err)
}
sessionA, sessionB, sessionC := uuid.NewString(), uuid.NewString(), uuid.NewString()
ns := "weknora-it-" + uuid.NewString()[:8]
ns := "academy-it-" + uuid.NewString()[:8]
rc := redis.NewClient(&redis.Options{Addr: redisAddr})
t.Cleanup(func() { _ = rc.Close() })
store, err := NewRedisSessionSandboxBindingStore(rc, ns)
@@ -1188,7 +1188,7 @@ func TestDockerUserMachineSharesContainerAndIsolatesDirectories(t *testing.T) {
Config: cfg, Client: remote, Store: store,
Checker: PermissiveSessionExistenceChecker{}, SkipHealthProbe: true,
ConfigID: "docker-conformance", ConfigTenantID: dockerIntegrationTenantID,
Allocations: allocs, Admission: admission.NewRedis(rc, "weknora:sandbox:user:"),
Allocations: allocs, Admission: admission.NewRedis(rc, "academy:sandbox:user:"),
Namespace: ns,
})
if err != nil {
+8 -8
View File
@@ -14,7 +14,7 @@
// Get/List → GET /containers/json?filters=label=…
// Delete → DELETE /containers/{id}?force=1
// Exec → POST /containers/{id}/exec → /exec/{id}/start (hijack)
// Snapshot → POST /commit (skill images under weknora-skill/, fork images under weknora-fork/)
// Snapshot → POST /commit (skill images under academy-skill/, fork images under academy-fork/)
//
// Every file operation uses exec with an explicit account (root by default),
// timeout and activity tracking. Archive endpoints bypass those exec settings.
@@ -23,7 +23,7 @@
// See WriteFile for the limits of the file API's path guards.
//
// ListDir and Stat use `find -printf`, which needs GNU findutils in the image;
// the standard WeKnora sandbox image provides it.
// the standard Academy sandbox image provides it.
//
// Two Docker facts shape the rest of this file:
//
@@ -56,7 +56,7 @@ import (
// dockerActivityMarker is touched by every exec and read by the idle sweeper.
// It lives outside /workspace so a script cannot mistake it for its own data,
// and outside /tmp so a tmpfs mount cannot hide it.
const dockerActivityMarker = "/var/lib/weknora-sandbox-activity"
const dockerActivityMarker = "/var/lib/academy-sandbox-activity"
// dockerSandboxEntrypoint keeps the container alive without running anything —
// the container is a place to exec into, not a service — and prepares the
@@ -213,7 +213,7 @@ func (c *DockerRemoteClient) Provider() RemoteProvider { return SandboxTypeDocke
// Capabilities reports what this backend can do.
//
// SupportsTimeoutRefresh is false because the daemon has no timeout to
// refresh: idle reclamation is WeKnora's own sweep, not a provider feature.
// refresh: idle reclamation is Academy's own sweep, not a provider feature.
// SupportsVolumes is false until the volume-mount surface is mapped onto
// Docker named volumes; advertising it early would let a workspace configure
// a mount that silently never appears. SupportsDesktop stays false: the
@@ -656,7 +656,7 @@ func (c *DockerRemoteClient) removeQuietly(ctx context.Context, id string) {
// The command is wrapped so that the container, not the client, enforces the
// timeout: cancelling the HTTP request leaves the process running (verified in
// docs/poc/docker-sandbox), which would let a runaway script keep burning the
// host's CPU long after WeKnora reported a timeout to the user.
// host's CPU long after Academy reported a timeout to the user.
func (c *DockerRemoteClient) Exec(
ctx context.Context,
handle RemoteSandboxHandle,
@@ -828,13 +828,13 @@ func dockerExecCommand(req RemoteExecRequest, timeout time.Duration) []string {
return []string{
"/bin/sh", "-c",
touch + `exec timeout -s KILL ` + seconds + ` /bin/bash --noprofile --norc -c "$1"`,
"weknora-exec", req.Command,
"academy-exec", req.Command,
}
}
argv := []string{
"/bin/sh", "-c",
touch + `exec timeout -s KILL ` + seconds + ` "$@"`,
"weknora-exec", req.Command,
"academy-exec", req.Command,
}
return append(argv, req.Args...)
}
@@ -900,7 +900,7 @@ func (c *DockerRemoteClient) WriteFile(
// metacharacters cannot change what the redirect targets.
result, err := c.Exec(ctx, &dockerSandboxHandle{id: id}, RemoteExecRequest{
Command: "sh",
Args: []string{"-c", `cat > "$1"`, "weknora-write", clean},
Args: []string{"-c", `cat > "$1"`, "academy-write", clean},
Stdin: string(content),
User: remoteFileUser(ctx),
Timeout: dockerFilesystemOpTimeout,
+30 -30
View File
@@ -522,7 +522,7 @@ func newTestDockerClient(t *testing.T, engine *fakeDockerEngine) *DockerRemoteCl
t.Helper()
settings, err := dockerSettingsFromConfig(&Config{
Type: SandboxTypeDocker,
DockerImage: "weknora/sandbox:test",
DockerImage: "academy/sandbox:test",
})
require.NoError(t, err)
// Idle sweeping is disabled: it would race the assertions with a
@@ -539,11 +539,11 @@ func testHandle(id string) RemoteSandboxHandle {
func TestDockerClientCreateAppliesIsolationAndMetadata(t *testing.T) {
engine := newFakeDockerEngine()
engine.imagePresent["weknora/sandbox:test"] = true
engine.imagePresent["academy/sandbox:test"] = true
docker := newTestDockerClient(t, engine)
handle, err := docker.Create(context.Background(), RemoteCreateRequest{
TemplateID: "weknora/sandbox:test",
TemplateID: "academy/sandbox:test",
Metadata: map[string]string{remoteMetadataSessionID: "sess-1"},
EnvVars: map[string]string{"FOO": "bar"},
Timeout: RemoteTimeoutPolicy{Mode: RemoteTimeoutExplicit, Value: 15 * time.Minute},
@@ -596,22 +596,22 @@ func TestDockerClientCreatePullsMissingImage(t *testing.T) {
docker := newTestDockerClient(t, engine)
_, err := docker.Create(context.Background(), RemoteCreateRequest{
TemplateID: "weknora/sandbox:test",
TemplateID: "academy/sandbox:test",
})
require.NoError(t, err)
require.Equal(t, []string{"weknora/sandbox:test"}, engine.pulled)
require.Equal(t, []string{"academy/sandbox:test"}, engine.pulled)
}
// A container that cannot start is a leak waiting to happen: nothing binds it,
// so only the much later idle sweep would notice.
func TestDockerClientCreateRemovesContainerThatCannotStart(t *testing.T) {
engine := newFakeDockerEngine()
engine.imagePresent["weknora/sandbox:test"] = true
engine.imagePresent["academy/sandbox:test"] = true
engine.startErr = errors.New("no space left on device")
docker := newTestDockerClient(t, engine)
_, err := docker.Create(context.Background(), RemoteCreateRequest{
TemplateID: "weknora/sandbox:test",
TemplateID: "academy/sandbox:test",
})
require.Error(t, err)
require.Equal(t, []string{"container-1"}, engine.removed)
@@ -622,7 +622,7 @@ func TestDockerClientCreateRemovesContainerThatCannotStart(t *testing.T) {
// what makes the first attempt succeed.
func TestDockerClientCreateWaitsUntilTheContainerIsRunning(t *testing.T) {
engine := newFakeDockerEngine()
engine.imagePresent["weknora/sandbox:test"] = true
engine.imagePresent["academy/sandbox:test"] = true
engine.startLeavesState = true
var inspects int
engine.inspectHook = func(id string) (container.InspectResponse, error) {
@@ -639,7 +639,7 @@ func TestDockerClientCreateWaitsUntilTheContainerIsRunning(t *testing.T) {
docker := newTestDockerClient(t, engine)
handle, err := docker.Create(context.Background(), RemoteCreateRequest{
TemplateID: "weknora/sandbox:test",
TemplateID: "academy/sandbox:test",
})
require.NoError(t, err)
require.Equal(t, "container-1", handle.ID())
@@ -650,7 +650,7 @@ func TestDockerClientCreateWaitsUntilTheContainerIsRunning(t *testing.T) {
// the container has to be removed the same way a failed Start is.
func TestDockerClientCreateRemovesContainerThatExitsImmediately(t *testing.T) {
engine := newFakeDockerEngine()
engine.imagePresent["weknora/sandbox:test"] = true
engine.imagePresent["academy/sandbox:test"] = true
engine.startLeavesState = true
engine.inspect["container-1"] = container.InspectResponse{
ID: "container-1",
@@ -659,7 +659,7 @@ func TestDockerClientCreateRemovesContainerThatExitsImmediately(t *testing.T) {
docker := newTestDockerClient(t, engine)
_, err := docker.Create(context.Background(), RemoteCreateRequest{
TemplateID: "weknora/sandbox:test",
TemplateID: "academy/sandbox:test",
})
require.Error(t, err)
require.Equal(t, []string{"container-1"}, engine.removed)
@@ -669,7 +669,7 @@ func TestDockerClientCreateRemovesContainerThatExitsImmediately(t *testing.T) {
func TestDockerClientCreateRefusesVolumeMounts(t *testing.T) {
docker := newTestDockerClient(t, newFakeDockerEngine())
_, err := docker.Create(context.Background(), RemoteCreateRequest{
TemplateID: "weknora/sandbox:test",
TemplateID: "academy/sandbox:test",
VolumeMounts: []RemoteVolumeMount{{Name: "skills", Path: "/skills"}},
})
require.Error(t, err)
@@ -678,12 +678,12 @@ func TestDockerClientCreateRefusesVolumeMounts(t *testing.T) {
func TestDockerClientCreateNoEgressUsesNoneNetwork(t *testing.T) {
engine := newFakeDockerEngine()
engine.imagePresent["weknora/sandbox:test"] = true
engine.imagePresent["academy/sandbox:test"] = true
docker := newTestDockerClient(t, engine)
denied := false
_, err := docker.Create(context.Background(), RemoteCreateRequest{
TemplateID: "weknora/sandbox:test",
TemplateID: "academy/sandbox:test",
Network: RemoteNetworkPolicy{AllowInternetAccess: &denied},
})
require.NoError(t, err)
@@ -744,7 +744,7 @@ func TestDockerClientGetNormalizesState(t *testing.T) {
StartedAt: "2026-08-12T10:00:00.000000000Z",
},
Config: &container.Config{
Image: "weknora/sandbox:test",
Image: "academy/sandbox:test",
Labels: map[string]string{remoteMetadataSessionID: "sess-1"},
},
}
@@ -754,7 +754,7 @@ func TestDockerClientGetNormalizesState(t *testing.T) {
require.NoError(t, err)
require.Equal(t, RemoteStateRunning, summary.State)
require.Equal(t, "running", summary.RawState)
require.Equal(t, "weknora/sandbox:test", summary.TemplateID)
require.Equal(t, "academy/sandbox:test", summary.TemplateID)
require.Equal(t, 2026, summary.StartedAt.Year())
}
@@ -825,7 +825,7 @@ func TestDockerClientExecWrapsCommandWithTimeoutAndActivityMarker(t *testing.T)
require.Equal(t, "/bin/sh", opts.Cmd[0])
require.Contains(t, opts.Cmd[2], dockerActivityMarker)
require.Contains(t, opts.Cmd[2], "timeout -s KILL 45")
require.Equal(t, []string{"weknora-exec", "python3", "/workspace/script.py", "--flag"},
require.Equal(t, []string{"academy-exec", "python3", "/workspace/script.py", "--flag"},
opts.Cmd[3:], "the command must reach the shell as positional args, never interpolated")
}
@@ -892,7 +892,7 @@ func TestDockerClientExecShellPassesCommandAsPositionalArgument(t *testing.T) {
})
require.NoError(t, err)
opts := engine.execOptions[0]
require.Equal(t, []string{"weknora-exec", `echo "a b"; rm -rf /nope`}, opts.Cmd[3:])
require.Equal(t, []string{"academy-exec", `echo "a b"; rm -rf /nope`}, opts.Cmd[3:])
require.Equal(t, DefaultSandboxExecUser, opts.User,
"an unnamed account must resolve to the sandbox user, never to root")
}
@@ -985,7 +985,7 @@ func TestDockerClientWriteFileRunsAsSandboxUserOverExec(t *testing.T) {
require.True(t, write.AttachStdin)
require.Equal(t, "hello", engine.execStdin.String())
require.Equal(t,
[]string{"weknora-exec", "sh", "-c", `cat > "$1"`, "weknora-write", "/workspace/input/note.txt"},
[]string{"academy-exec", "sh", "-c", `cat > "$1"`, "academy-write", "/workspace/input/note.txt"},
write.Cmd[3:],
"the destination must reach the shell as a positional arg, never interpolated")
}
@@ -1003,7 +1003,7 @@ func TestDockerClientReadFileRunsAsSandboxUserOverExec(t *testing.T) {
require.Len(t, engine.execOptions, 1)
require.Equal(t, DefaultSandboxExecUser, engine.execOptions[0].User)
require.Equal(t,
[]string{"weknora-exec", "cat", "--", "/workspace/output/report.txt"},
[]string{"academy-exec", "cat", "--", "/workspace/output/report.txt"},
engine.execOptions[0].Cmd[3:])
}
@@ -1146,7 +1146,7 @@ func TestDockerClientStatMapsEntryType(t *testing.T) {
require.Equal(t, RemoteEntryDir, entry.Type)
require.Equal(t, int64(4096), entry.Size)
require.Equal(t,
[]string{"weknora-exec", "find", "/workspace/output", "-maxdepth", "0", "-printf", `%y\t%s\t%T@\t%p\n`},
[]string{"academy-exec", "find", "/workspace/output", "-maxdepth", "0", "-printf", `%y\t%s\t%T@\t%p\n`},
engine.execOptions[0].Cmd[3:])
missing := newFakeDockerEngine()
@@ -1164,7 +1164,7 @@ func TestDockerClientCapabilities(t *testing.T) {
require.True(t, caps.SupportsListSandboxes)
require.True(t, caps.SupportsFilesystemEnumeration)
require.False(t, caps.SupportsTimeoutRefresh,
"the daemon has no TTL to refresh; reclamation is WeKnora's own sweep")
"the daemon has no TTL to refresh; reclamation is Academy's own sweep")
require.True(t, caps.SupportsSnapshots,
"docker commit is the skill-image snapshot; without this flag install is refused")
require.True(t, caps.SupportsTerminals,
@@ -1207,7 +1207,7 @@ func TestValidateDockerRemoteTLS(t *testing.T) {
require.NoError(t, ValidateDockerRemoteTLS("unix:///var/run/docker.sock", ""))
require.Error(t, ValidateDockerRemoteTLS("tcp://10.0.0.5:2376", ""),
"a remote daemon without TLS is a plaintext root socket")
require.NoError(t, ValidateDockerRemoteTLS("tcp://10.0.0.5:2376", "/etc/weknora/docker-certs"))
require.NoError(t, ValidateDockerRemoteTLS("tcp://10.0.0.5:2376", "/etc/academy/docker-certs"))
}
// File operations run as the sandbox account, so the kernel decides what is
@@ -1259,7 +1259,7 @@ func TestDockerEndpointKeySeparatesOutboundPolicy(t *testing.T) {
func TestDockerSettingsCarryOutboundPolicy(t *testing.T) {
settings, err := dockerSettingsFromConfig(&Config{
Type: SandboxTypeDocker,
DockerImage: "weknora/sandbox:test",
DockerImage: "academy/sandbox:test",
AllowPrivateEndpoints: true,
})
require.NoError(t, err)
@@ -1275,21 +1275,21 @@ func TestValidateDockerNetworkMode(t *testing.T) {
require.Error(t, ValidateDockerNetworkMode("ns:/var/run/netns/foo"))
// A named network is usually the deployment's own compose network, which
// would put the sandbox alongside Postgres and Redis.
require.Error(t, ValidateDockerNetworkMode("weknora_default"))
require.Error(t, ValidateDockerNetworkMode("weknora-sandbox"))
require.Error(t, ValidateDockerNetworkMode("academy_default"))
require.Error(t, ValidateDockerNetworkMode("academy-sandbox"))
}
func TestDockerSettingsRejectHostNetworkAndPlaintextTCP(t *testing.T) {
_, err := dockerSettingsFromConfig(&Config{
Type: SandboxTypeDocker,
DockerImage: "weknora/sandbox:test",
DockerImage: "academy/sandbox:test",
DockerNetworkMode: "host",
})
require.Error(t, err)
_, err = dockerSettingsFromConfig(&Config{
Type: SandboxTypeDocker,
DockerImage: "weknora/sandbox:test",
DockerImage: "academy/sandbox:test",
DockerHost: "tcp://10.0.0.5:2376",
})
require.Error(t, err)
@@ -1303,12 +1303,12 @@ func TestDockerSettingsRequireImage(t *testing.T) {
func TestDockerSessionCreateRequestDeletesIdleSandboxes(t *testing.T) {
cfg := DefaultConfig()
cfg.Type = SandboxTypeDocker
cfg.DockerImage = "weknora/sandbox:test"
cfg.DockerImage = "academy/sandbox:test"
applyDockerRuntimeDefaults(cfg)
request, err := buildSessionCreateRequest(SandboxTypeDocker, cfg)
require.NoError(t, err)
require.Equal(t, "weknora/sandbox:test", request.TemplateID)
require.Equal(t, "academy/sandbox:test", request.TemplateID)
require.Equal(t, DefaultDockerIdleTTL, request.Timeout.Value)
require.Equal(t, RemoteOnTimeoutKill, request.Timeout.Action,
"pausing a container keeps its memory on the host, so it reclaims nothing")
+8 -8
View File
@@ -14,20 +14,20 @@ const (
// snapshot is committed into. It is not a registry path: these tags are
// never pulled, and ListTemplates hides anything under it so an admin
// cannot pick a baked skill image as the config's base template.
dockerSkillSnapshotRepo = "weknora-skill"
dockerSkillSnapshotRepo = "academy-skill"
dockerSkillSnapshotLabel = "com.weknora.sandbox.skill-snapshot"
dockerSkillSnapshotSourceLabel = "com.weknora.sandbox.skill-snapshot-source"
dockerSkillSnapshotLabel = "com.academy.sandbox.skill-snapshot"
dockerSkillSnapshotSourceLabel = "com.academy.sandbox.skill-snapshot-source"
// DockerForkSnapshotRepo is the local image namespace for session-fork
// snapshots. It is deliberately separate from dockerSkillSnapshotRepo: the
// skill reaper prunes by the skill namespace and labels, and letting fork
// snapshots share them would have each reaper collecting the other's
// images.
DockerForkSnapshotRepo = "weknora-fork"
DockerForkSnapshotRepo = "academy-fork"
dockerForkSnapshotLabel = "com.weknora.sandbox.fork-snapshot"
dockerForkSnapshotSourceLabel = "com.weknora.sandbox.fork-snapshot-source"
dockerForkSnapshotLabel = "com.academy.sandbox.fork-snapshot"
dockerForkSnapshotSourceLabel = "com.academy.sandbox.fork-snapshot-source"
)
// CreateSnapshot commits the container's filesystem into a tagged local image.
@@ -47,7 +47,7 @@ func (c *DockerRemoteClient) CreateSnapshot(
return c.commitSnapshot(
ctx, id, name,
dockerSkillSnapshotRepo,
"weknora skill snapshot",
"academy skill snapshot",
dockerSkillSnapshotLabel,
dockerSkillSnapshotSourceLabel,
"CreateSnapshot",
@@ -67,7 +67,7 @@ func (c *DockerRemoteClient) CreateForkSnapshot(
return c.commitSnapshot(
ctx, id, name,
DockerForkSnapshotRepo,
"weknora fork snapshot",
"academy fork snapshot",
dockerForkSnapshotLabel,
dockerForkSnapshotSourceLabel,
"CreateForkSnapshot",
+25 -25
View File
@@ -13,11 +13,11 @@ func TestDockerCreateSnapshotTagsASkillImage(t *testing.T) {
engine := newFakeDockerEngine()
docker := newTestDockerClient(t, engine)
ref, err := docker.CreateSnapshot(context.Background(), "container-1", "weknora-sk-cfg1-g1")
ref, err := docker.CreateSnapshot(context.Background(), "container-1", "academy-sk-cfg1-g1")
require.NoError(t, err)
require.Equal(t, "weknora-skill/weknora-sk-cfg1-g1", ref.ID)
require.Equal(t, "academy-skill/academy-sk-cfg1-g1", ref.ID)
require.Len(t, engine.committed, 1)
require.Equal(t, "weknora-skill/weknora-sk-cfg1-g1", engine.committed[0].Reference)
require.Equal(t, "academy-skill/academy-sk-cfg1-g1", engine.committed[0].Reference)
require.False(t, engine.committed[0].NoPause,
"the Engine must pause the container for the duration of the commit")
require.Contains(t, engine.committed[0].Changes, "LABEL "+dockerSkillSnapshotLabel+"=true")
@@ -33,7 +33,7 @@ func TestDockerCreateSnapshotRejectsEmptySandboxID(t *testing.T) {
func TestDockerDeleteSnapshotTreatsMissingAsSuccess(t *testing.T) {
err := newTestDockerClient(t, newFakeDockerEngine()).
DeleteSnapshot(context.Background(), "weknora-skill/missing")
DeleteSnapshot(context.Background(), "academy-skill/missing")
require.NoError(t, err)
}
@@ -48,11 +48,11 @@ func TestDockerSnapshotRoundTripAndListFilter(t *testing.T) {
docker := newTestDockerClient(t, engine)
ctx := context.Background()
first, err := docker.CreateSnapshot(ctx, "container-a", "weknora-sk-a-g1")
first, err := docker.CreateSnapshot(ctx, "container-a", "academy-sk-a-g1")
require.NoError(t, err)
second, err := docker.CreateSnapshot(ctx, "container-a", "weknora-sk-a-g2")
second, err := docker.CreateSnapshot(ctx, "container-a", "academy-sk-a-g2")
require.NoError(t, err)
_, err = docker.CreateSnapshot(ctx, "container-b", "weknora-sk-b-g1")
_, err = docker.CreateSnapshot(ctx, "container-b", "academy-sk-b-g1")
require.NoError(t, err)
all, err := docker.ListSnapshots(ctx, "")
@@ -82,7 +82,7 @@ func TestDockerDeleteSnapshotPrunesUntaggedAncestors(t *testing.T) {
engine := newFakeDockerEngine()
docker := newTestDockerClient(t, engine)
ref, err := docker.CreateSnapshot(context.Background(), "container-a", "weknora-sk-a-g1")
ref, err := docker.CreateSnapshot(context.Background(), "container-a", "academy-sk-a-g1")
require.NoError(t, err)
require.NoError(t, docker.DeleteSnapshot(context.Background(), ref.ID))
@@ -99,7 +99,7 @@ func TestDockerDeleteSnapshotSweepsUntaggedSkillImages(t *testing.T) {
engine.images = []image.Summary{
{
ID: "sha256:retired",
RepoTags: []string{"weknora-skill/weknora-sk-a-g1:latest"},
RepoTags: []string{"academy-skill/academy-sk-a-g1:latest"},
Labels: map[string]string{dockerSkillSnapshotLabel: "true"},
},
{
@@ -109,22 +109,22 @@ func TestDockerDeleteSnapshotSweepsUntaggedSkillImages(t *testing.T) {
},
{
ID: "sha256:live",
RepoTags: []string{"weknora-skill/weknora-sk-a-g2:latest"},
RepoTags: []string{"academy-skill/academy-sk-a-g2:latest"},
Labels: map[string]string{dockerSkillSnapshotLabel: "true"},
},
{
ID: "sha256:base",
RepoTags: []string{"weknora/sandbox:test"},
RepoTags: []string{"academy/sandbox:test"},
Labels: map[string]string{dockerTemplateLabel: "true"},
},
}
docker := newTestDockerClient(t, engine)
require.NoError(t, docker.DeleteSnapshot(
context.Background(), "weknora-skill/weknora-sk-a-g1"))
context.Background(), "academy-skill/academy-sk-a-g1"))
require.Equal(t,
[]string{"weknora-skill/weknora-sk-a-g1", "sha256:orphan"},
[]string{"academy-skill/academy-sk-a-g1", "sha256:orphan"},
engine.removedImages,
"the sweep must take the untagged snapshot and nothing that is still named")
}
@@ -173,12 +173,12 @@ func TestDockerDeleteSnapshotSweepFailureIsNotAnError(t *testing.T) {
Labels: map[string]string{dockerSkillSnapshotLabel: "true"},
},
}
engine.imagePresent["weknora-skill/weknora-sk-a-g1"] = true
engine.imagePresent["academy-skill/academy-sk-a-g1"] = true
engine.listImagesErr = errors.New("daemon busy")
docker := newTestDockerClient(t, engine)
require.NoError(t, docker.DeleteSnapshot(
context.Background(), "weknora-skill/weknora-sk-a-g1"),
context.Background(), "academy-skill/academy-sk-a-g1"),
"reclaiming storage must not turn a completed delete into a failure")
}
@@ -187,12 +187,12 @@ func TestDockerListTemplatesHidesSkillSnapshots(t *testing.T) {
engine.images = []image.Summary{
{
ID: "sha256:base",
RepoTags: []string{"weknora/sandbox:test"},
RepoTags: []string{"academy/sandbox:test"},
Labels: map[string]string{dockerTemplateLabel: "true"},
},
{
ID: "sha256:snap",
RepoTags: []string{"weknora-skill/weknora-sk-cfg1-g1:latest"},
RepoTags: []string{"academy-skill/academy-sk-cfg1-g1:latest"},
Labels: map[string]string{dockerSkillSnapshotLabel: "true"},
},
}
@@ -201,7 +201,7 @@ func TestDockerListTemplatesHidesSkillSnapshots(t *testing.T) {
templates, err := docker.ListTemplates(context.Background())
require.NoError(t, err)
require.Len(t, templates, 1)
require.Equal(t, "weknora/sandbox:test", templates[0].ID)
require.Equal(t, "academy/sandbox:test", templates[0].ID)
}
func TestDockerCreateDoesNotPullAMissingSkillSnapshot(t *testing.T) {
@@ -209,7 +209,7 @@ func TestDockerCreateDoesNotPullAMissingSkillSnapshot(t *testing.T) {
docker := newTestDockerClient(t, engine)
_, err := docker.Create(context.Background(), RemoteCreateRequest{
TemplateID: "weknora-skill/weknora-sk-cfg1-g1",
TemplateID: "academy-skill/academy-sk-cfg1-g1",
})
require.True(t, IsRemoteInvalidRequest(err), err)
require.Empty(t, engine.pulled,
@@ -225,7 +225,7 @@ func TestDockerCreateForkSnapshotTagsAForkImage(t *testing.T) {
require.Equal(t, DockerForkSnapshotRepo+"/fork-session-a-1", ref.ID)
require.Len(t, engine.committed, 1)
require.Equal(t, DockerForkSnapshotRepo+"/fork-session-a-1", engine.committed[0].Reference)
require.Equal(t, "weknora fork snapshot", engine.committed[0].Comment)
require.Equal(t, "academy fork snapshot", engine.committed[0].Comment)
require.False(t, engine.committed[0].NoPause,
"the Engine must pause the container for the duration of the commit")
require.Contains(t, engine.committed[0].Changes, "LABEL "+dockerForkSnapshotLabel+"=true")
@@ -238,7 +238,7 @@ func TestDockerListTemplatesHidesForkSnapshots(t *testing.T) {
engine.images = []image.Summary{
{
ID: "sha256:base",
RepoTags: []string{"weknora/sandbox:test"},
RepoTags: []string{"academy/sandbox:test"},
Labels: map[string]string{dockerTemplateLabel: "true"},
},
{
@@ -256,7 +256,7 @@ func TestDockerListTemplatesHidesForkSnapshots(t *testing.T) {
templates, err := docker.ListTemplates(context.Background())
require.NoError(t, err)
require.Len(t, templates, 1)
require.Equal(t, "weknora/sandbox:test", templates[0].ID)
require.Equal(t, "academy/sandbox:test", templates[0].ID)
}
func TestDockerListSnapshotsExcludesForkImages(t *testing.T) {
@@ -264,7 +264,7 @@ func TestDockerListSnapshotsExcludesForkImages(t *testing.T) {
docker := newTestDockerClient(t, engine)
ctx := context.Background()
_, err := docker.CreateSnapshot(ctx, "container-1", "weknora-sk-cfg1-g1")
_, err := docker.CreateSnapshot(ctx, "container-1", "academy-sk-cfg1-g1")
require.NoError(t, err)
_, err = docker.CreateForkSnapshot(ctx, "container-1", "fork-session-a-1")
require.NoError(t, err)
@@ -272,7 +272,7 @@ func TestDockerListSnapshotsExcludesForkImages(t *testing.T) {
listed, err := docker.ListSnapshots(ctx, "")
require.NoError(t, err)
require.Len(t, listed, 1)
require.Equal(t, "weknora-skill/weknora-sk-cfg1-g1", listed[0].ID)
require.Equal(t, "academy-skill/academy-sk-cfg1-g1", listed[0].ID)
}
func TestDockerCreateDoesNotPullAMissingForkSnapshot(t *testing.T) {
@@ -288,7 +288,7 @@ func TestDockerCreateDoesNotPullAMissingForkSnapshot(t *testing.T) {
}
func TestDockerSanitizeImageName(t *testing.T) {
require.Equal(t, "weknora-sk-cfg1-g1", dockerSanitizeImageName("weknora-sk-cfg1-g1"))
require.Equal(t, "academy-sk-cfg1-g1", dockerSanitizeImageName("academy-sk-cfg1-g1"))
require.Equal(t, "abc-def", dockerSanitizeImageName("ABC_DEF"))
require.Equal(t, "snap", dockerSanitizeImageName("--snap--"))
require.Empty(t, dockerSanitizeImageName("***"))
+4 -4
View File
@@ -11,8 +11,8 @@
// nothing to do with sandboxes. Listing all of them would bury the one the
// admin needs, so the catalog only reports images that are recognisably
// sandbox templates.
// - Skill and fork snapshots live in the same image store (weknora-skill/…
// and weknora-fork/…), so they are subtracted the way Cube hides snap- IDs
// - Skill and fork snapshots live in the same image store (academy-skill/…
// and academy-fork/…), so they are subtracted the way Cube hides snap- IDs
// from GET /templates.
// - Making the standard template exist means pulling, which can take minutes
// on a cold host. The pull therefore runs in the background and the
@@ -31,9 +31,9 @@ import (
"github.com/moby/moby/client"
)
// dockerTemplateLabel marks an image as a WeKnora sandbox template. Images
// dockerTemplateLabel marks an image as a Academy sandbox template. Images
// built by an operator can opt into the catalog by carrying it.
const dockerTemplateLabel = "com.weknora.sandbox.template"
const dockerTemplateLabel = "com.academy.sandbox.template"
// dockerImagePulls tracks background pulls per daemon endpoint and image, so a
// second refresh reports the in-flight pull instead of starting another one.
+5 -5
View File
@@ -29,7 +29,7 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/logger"
"github.com/moby/moby/client"
)
@@ -57,7 +57,7 @@ const (
// it — which is what lets teardown find and kill the shell's whole tree from
// inside the container, without having to map ExecInspect's host PID into the
// container's PID namespace.
const dockerTerminalIDEnv = "WEKNORA_TERMINAL_ID"
const dockerTerminalIDEnv = "ACADEMY_TERMINAL_ID"
// dockerTerminalToken mints a per-open marker. It only has to distinguish
// concurrent terminals in one container, so a random 16-byte hex string is
@@ -328,7 +328,7 @@ func (s *dockerTerminalSession) Resize(ctx context.Context, cols, rows uint32) e
return nil
}
// Close detaches WeKnora from the PTY and, because Docker has no re-attach to
// Close detaches Academy from the PTY and, because Docker has no re-attach to
// preserve, hangs up the shell inside the container. Unlike Cube/E2B,
// closing the hijacked connection does not end the exec — the daemon keeps it
// (and any foreground jobs) alive — so a bare disconnect would strand the
@@ -373,7 +373,7 @@ func (s *dockerTerminalSession) terminate() {
// It matches on the marker environment variable rather than a PID because
// ExecInspect reports the *host* PID, which is meaningless inside the
// container's PID namespace — a kill exec running there cannot see /proc/<pid>.
// Every process the shell starts inherits WEKNORA_TERMINAL_ID, so walking
// Every process the shell starts inherits ACADEMY_TERMINAL_ID, so walking
// /proc finds the shell and its whole job tree (a running foreground job is in
// its own process group, so signalling the shell or its group alone would
// orphan it). A shell that already exited has no carriers left, which is why
@@ -407,7 +407,7 @@ set -- ${s##*) }
[ "$4" = "$q" ] && kill -9 "$q" 2>/dev/null
done
exit 0`
return []string{"/bin/sh", "-c", script, "weknora-terminate", token}
return []string{"/bin/sh", "-c", script, "academy-terminate", token}
}
// teardown closes the stream and the marker-refresh loop exactly once. Both
+3 -3
View File
@@ -23,7 +23,7 @@ func newTerminalTestClient(
t.Helper()
settings, err := dockerSettingsFromConfig(&Config{
Type: SandboxTypeDocker,
DockerImage: "weknora/sandbox:test",
DockerImage: "academy/sandbox:test",
})
require.NoError(t, err)
settings.IdleTTL = ttl
@@ -338,7 +338,7 @@ func TestDockerTerminalKillCmdTargetsMarkerEnv(t *testing.T) {
cmd := dockerTerminalKillCmd("deadbeef")
require.Equal(t, "/bin/sh", cmd[0])
require.Equal(t, "-c", cmd[1])
require.Equal(t, "weknora-terminate", cmd[3])
require.Equal(t, "academy-terminate", cmd[3])
require.Equal(t, "deadbeef", cmd[4], "the token travels as argv")
require.Contains(t, cmd[2], dockerTerminalIDEnv+"=$1",
"the script matches the marker env")
@@ -362,7 +362,7 @@ func drainTerminalOutput(session RemoteTerminalSession) {
}
}
// terminalMarkerToken extracts the WEKNORA_TERMINAL_ID value the adapter set on
// terminalMarkerToken extracts the ACADEMY_TERMINAL_ID value the adapter set on
// a captured ExecCreate, so a test can predict the kill argv.
func terminalMarkerToken(t *testing.T, opts client.ExecCreateOptions) string {
t.Helper()
@@ -2,7 +2,7 @@
// Conformance test for E2B-protocol control planes.
//
// WeKnora treats "E2B protocol" as the single integration contract for remote
// Academy treats "E2B protocol" as the single integration contract for remote
// sandboxes, so the same suite must pass against every implementation of it:
// E2B Cloud, a self-hosted e2b-dev/infra, CubeSandbox's CubeAPI, or a
// container-backed gateway such as Agent-Sandbox. It drives the same public
@@ -35,7 +35,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
const (
@@ -90,7 +90,7 @@ func TestE2BCompatibleControlPlaneConformance(t *testing.T) {
})
// State is written under the artifact directory rather than an arbitrary
// path: that directory is the one WeKnora provisions and grants to the
// path: that directory is the one Academy provisions and grants to the
// script account, so the assertion tests session persistence instead of a
// template's /workspace permissions.
counterPath := path.Join(SessionOutputRoot, "counter.txt")
+1 -1
View File
@@ -84,7 +84,7 @@ func TestE2BIntegrationLifecycleParity(t *testing.T) {
firstHandle.Metadata(), expectedMetadata)
}
base := "/tmp/weknora-e2b-integration"
base := "/tmp/academy-e2b-integration"
path := base + "/state.txt"
payload := []byte("e2b lifecycle state persists\n")
if err := firstClient.MakeDir(ctx, firstHandle, base); err != nil {
+13 -13
View File
@@ -19,7 +19,7 @@ import (
"github.com/gorilla/websocket"
e2b "github.com/matiasinsaurralde/go-e2b"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/logger"
)
// E2BRemoteClient implements RemoteSandboxClient on top of the go-e2b client.
@@ -214,7 +214,7 @@ func (h *e2bRemoteHandle) Metadata() map[string]string {
// TrafficAccessToken implements RemoteInboundTokenCarrier. E2B issues it only
// in the create response; go-e2b keeps the field but never sends the header,
// so both persisting it and attaching it are WeKnora's job.
// so both persisting it and attaching it are Academy's job.
func (h *e2bRemoteHandle) TrafficAccessToken() string {
if h == nil || h.sandbox == nil {
return ""
@@ -237,7 +237,7 @@ func (c *E2BRemoteClient) Capabilities() RemoteSandboxCapabilities {
// E2B stores snapshots as templates, so a snapshot ID can be handed
// straight back as CreateOptions.TemplateID.
SupportsSnapshots: true,
// E2B has no named-volume mount API that WeKnora can use; advertising
// E2B has no named-volume mount API that Academy can use; advertising
// it would let a workspace configure a mount that never appears.
SupportsVolumes: false,
// envd exposes an interactive PTY service that go-e2b wraps.
@@ -276,9 +276,9 @@ func (c *E2BRemoteClient) ListTemplates(ctx context.Context) ([]RemoteTemplate,
} else if len(item.Aliases) > 0 && strings.TrimSpace(item.Aliases[0]) != "" {
name = strings.TrimSpace(item.Aliases[0])
}
standard, desktop := classifyWeKnoraTemplate(name, "")
standard, desktop := classifyAcademyTemplate(name, "")
for _, candidate := range append(append([]string(nil), item.Aliases...), item.Names...) {
s, d := classifyWeKnoraTemplate(candidate, "")
s, d := classifyAcademyTemplate(candidate, "")
if d {
standard, desktop = false, true
break
@@ -419,7 +419,7 @@ func isE2BTemplateBuildPending(status string) bool {
}
}
// EnsureStandardTemplate returns the cluster's WeKnora template, building it
// EnsureStandardTemplate returns the cluster's Academy template, building it
// when absent. A failed or untagged template is not returned as is: it can
// never spawn a sandbox, so it falls through to the build below. E2B resolves
// the build by name, so that is a rebuild of the same template rather than a
@@ -437,7 +437,7 @@ func (c *E2BRemoteClient) EnsureStandardTemplate(ctx context.Context) (*RemoteTe
return c.buildStandardTemplate(ctx)
}
// ReplaceStandardTemplate starts a new WeKnora-template build from the current
// ReplaceStandardTemplate starts a new Academy-template build from the current
// spec. E2B resolves builds by name, so this is often a rebuild of the same
// ID. The previous template stays listed until the caller has persisted a
// spawnable replacement and called DeleteSupersededStandardTemplates: deleting
@@ -447,7 +447,7 @@ func (c *E2BRemoteClient) ReplaceStandardTemplate(ctx context.Context) (*RemoteT
return c.buildStandardTemplate(ctx)
}
// EnsureDesktopTemplate returns the cluster's WeKnora desktop template,
// EnsureDesktopTemplate returns the cluster's Academy desktop template,
// building it when absent. It is a sibling of EnsureStandardTemplate: a
// cluster may hold both, and the admin picks which ID a config boots.
func (c *E2BRemoteClient) EnsureDesktopTemplate(ctx context.Context) (*RemoteTemplate, error) {
@@ -494,7 +494,7 @@ func (c *E2BRemoteClient) DeleteSupersededDesktopTemplates(ctx context.Context,
return nil
}
// DeleteSupersededStandardTemplates drops WeKnora templates other than keepID.
// DeleteSupersededStandardTemplates drops Academy templates other than keepID.
func (c *E2BRemoteClient) DeleteSupersededStandardTemplates(ctx context.Context, keepID string) error {
keepID = strings.TrimSpace(keepID)
if keepID == "" {
@@ -521,11 +521,11 @@ func (c *E2BRemoteClient) DeleteSupersededStandardTemplates(ctx context.Context,
// e2bPtyPromptOverrideCmd re-sources the image prompt after E2B's
// template provisioner appends `PS1='\w $ '` to bashrc. Harmless if the
// image already sources /etc/weknora/pty-prompt.sh (PROMPT_COMMAND wins
// image already sources /etc/academy/pty-prompt.sh (PROMPT_COMMAND wins
// either way); required when rebuilding from an older image that does not.
const e2bPtyPromptOverrideCmd = `. /etc/weknora/pty-prompt.sh 2>/dev/null; ` +
`for f in /root/.bashrc /home/user/.bashrc /etc/profile.d/zz-weknora-prompt.sh; do ` +
`grep -q /etc/weknora/pty-prompt.sh "$f" 2>/dev/null || echo '. /etc/weknora/pty-prompt.sh' >> "$f"; ` +
const e2bPtyPromptOverrideCmd = `. /etc/academy/pty-prompt.sh 2>/dev/null; ` +
`for f in /root/.bashrc /home/user/.bashrc /etc/profile.d/zz-academy-prompt.sh; do ` +
`grep -q /etc/academy/pty-prompt.sh "$f" 2>/dev/null || echo '. /etc/academy/pty-prompt.sh' >> "$f"; ` +
`done`
func (c *E2BRemoteClient) buildStandardTemplate(ctx context.Context) (*RemoteTemplate, error) {
+22 -22
View File
@@ -19,7 +19,7 @@ import (
"time"
"connectrpc.com/connect"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
e2b "github.com/matiasinsaurralde/go-e2b"
"github.com/stretchr/testify/require"
)
@@ -414,12 +414,12 @@ func TestE2BRemoteClientCreateSnapshot(t *testing.T) {
handle, err := client.Create(ctx, RemoteCreateRequest{TemplateID: "template-a"})
require.NoError(t, err)
ref, err := client.CreateSnapshot(ctx, handle.ID(), "weknora-sk-cfg1-g1")
ref, err := client.CreateSnapshot(ctx, handle.ID(), "academy-sk-cfg1-g1")
require.NoError(t, err)
require.Equal(t, "snap-1", ref.ID)
require.Equal(t, []string{"weknora-sk-cfg1-g1"}, ref.Names)
require.Equal(t, "weknora-sk-cfg1-g1", mock.snapshotCreateBody["name"])
require.Equal(t, []string{"academy-sk-cfg1-g1"}, ref.Names)
require.Equal(t, "academy-sk-cfg1-g1", mock.snapshotCreateBody["name"])
require.Equal(t, int32(1), mock.connectCount.Load())
}
@@ -482,9 +482,9 @@ func TestE2BRemoteClientListSnapshotsPagesAllResults(t *testing.T) {
require.NoError(t, err)
second, err := client.Create(ctx, RemoteCreateRequest{TemplateID: "template-a"})
require.NoError(t, err)
firstRef, err := client.CreateSnapshot(ctx, first.ID(), "weknora-sk-cfg1-g1")
firstRef, err := client.CreateSnapshot(ctx, first.ID(), "academy-sk-cfg1-g1")
require.NoError(t, err)
secondRef, err := client.CreateSnapshot(ctx, first.ID(), "weknora-sk-cfg2-g1")
secondRef, err := client.CreateSnapshot(ctx, first.ID(), "academy-sk-cfg2-g1")
require.NoError(t, err)
_, err = client.CreateSnapshot(ctx, second.ID(), "other")
require.NoError(t, err)
@@ -519,7 +519,7 @@ func TestE2BRemoteClientListTemplatesInProgress(t *testing.T) {
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "template-weagentbox",
"buildID": tc.buildID,
"names": []string{"project/weknora"},
"names": []string{"project/academy"},
"buildStatus": "in_progress",
}})
case "/templates/template-weagentbox/builds/" + tc.buildID + "/status":
@@ -561,8 +561,8 @@ func TestE2BRemoteClientListTemplatesReconcilesStandardTemplateBuildStatus(t *te
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "template-ready",
"buildID": "build-success",
"names": []string{"project/weknora"},
"aliases": []string{"weknora"},
"names": []string{"project/academy"},
"aliases": []string{"academy"},
"buildStatus": "waiting",
"envdVersion": "0.4.0",
}})
@@ -591,7 +591,7 @@ func TestE2BRemoteClientListTemplatesReconcilesStandardTemplateBuildStatus(t *te
require.NoError(t, err)
require.Len(t, templates, 1)
require.True(t, templates[0].Standard)
require.Equal(t, "project/weknora", templates[0].Name)
require.Equal(t, "project/academy", templates[0].Name)
require.Equal(t, "ready", templates[0].Status)
require.Equal(t, int32(1), statusRequests.Load())
}
@@ -606,7 +606,7 @@ func TestE2BRemoteClientListTemplatesIgnoresOlderSuccessfulBuild(t *testing.T) {
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "template-queued",
"buildID": "build-queued",
"names": []string{"project/weknora"},
"names": []string{"project/academy"},
"buildStatus": "waiting",
}})
case "/templates/template-queued/builds/build-queued/status":
@@ -618,7 +618,7 @@ func TestE2BRemoteClientListTemplatesIgnoresOlderSuccessfulBuild(t *testing.T) {
case "/templates/template-queued":
writeJSON(w, http.StatusOK, map[string]any{
"templateID": "template-queued",
"names": []string{"project/weknora"},
"names": []string{"project/academy"},
"builds": []map[string]any{
{"buildID": "build-queued", "status": "waiting"},
{"buildID": "build-older", "status": "success"},
@@ -654,7 +654,7 @@ func TestE2BRemoteClientListTemplatesKeepsPendingWithoutBuildReference(t *testin
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "template-unbuilt",
"buildID": "00000000-0000-0000-0000-000000000000",
"names": []string{"project/weknora"},
"names": []string{"project/academy"},
"buildStatus": "building",
"spawnCount": 0,
}})
@@ -688,7 +688,7 @@ func TestE2BRemoteClientListTemplatesKeepsPendingWithoutSuccessfulBuild(t *testi
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "template-fresh",
"buildID": "build-fresh",
"names": []string{"project/weknora"},
"names": []string{"project/academy"},
"buildStatus": "building",
}})
case "/templates/template-fresh/builds/build-fresh/status":
@@ -733,7 +733,7 @@ func TestE2BRemoteClientListTemplatesReportsUntaggedBuilds(t *testing.T) {
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "template-untagged",
"buildID": "00000000-0000-0000-0000-000000000000",
"names": []string{"project/weknora"},
"names": []string{"project/academy"},
"buildStatus": "waiting",
"buildCount": 2,
}})
@@ -773,7 +773,7 @@ func TestE2BRemoteClientListTemplatesKeepsPendingOnFirstBuild(t *testing.T) {
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "template-first",
"buildID": "00000000-0000-0000-0000-000000000000",
"names": []string{"project/weknora"},
"names": []string{"project/academy"},
"buildStatus": "building",
"buildCount": 1,
}})
@@ -810,7 +810,7 @@ func TestE2BRemoteClientListTemplatesIgnoresSpawnCount(t *testing.T) {
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "template-spawned",
"buildID": "build-x",
"names": []string{"weknora"},
"names": []string{"academy"},
"buildStatus": "waiting",
"spawnCount": 4,
}})
@@ -888,12 +888,12 @@ func TestE2BRemoteClientListTemplatesMarksDesktopSibling(t *testing.T) {
writeJSON(w, http.StatusOK, []map[string]any{
{
"templateID": "tpl-cli",
"names": []string{"weknora"},
"names": []string{"academy"},
"buildStatus": "ready",
},
{
"templateID": "tpl-desktop",
"names": []string{"weknora-desktop"},
"names": []string{"academy-desktop"},
"buildStatus": "ready",
},
})
@@ -969,7 +969,7 @@ func TestE2BEnsureDesktopTemplateBuildsDesktopImage(t *testing.T) {
case r.Method == http.MethodGet && r.URL.Path == "/templates":
writeJSON(w, http.StatusOK, []map[string]any{{
"templateID": "tpl-cli",
"names": []string{"weknora"},
"names": []string{"academy"},
"buildStatus": "ready",
}})
case r.Method == http.MethodPost && r.URL.Path == "/v3/templates":
@@ -1126,7 +1126,7 @@ func TestE2BSnapshotCreateDropsEnvVarsAfterProviderRejectsThem(t *testing.T) {
handle, err := client.Create(context.Background(), RemoteCreateRequest{
TemplateID: "snap-1",
FromSnapshot: true,
EnvVars: map[string]string{"WEKNORA_SKILL_OUTPUT_DIR": "/workspace/output"},
EnvVars: map[string]string{"ACADEMY_SKILL_OUTPUT_DIR": "/workspace/output"},
Timeout: RemoteTimeoutPolicy{
Mode: RemoteTimeoutExplicit,
Value: time.Minute,
@@ -1154,7 +1154,7 @@ func TestE2BAliyunSnapshotCreateOmitsEnvVarsUpFront(t *testing.T) {
_, err := client.Create(context.Background(), RemoteCreateRequest{
TemplateID: "snap-1",
FromSnapshot: true,
EnvVars: map[string]string{"WEKNORA_SKILL_OUTPUT_DIR": "/workspace/output", "HF_TOKEN": "secret"},
EnvVars: map[string]string{"ACADEMY_SKILL_OUTPUT_DIR": "/workspace/output", "HF_TOKEN": "secret"},
Timeout: RemoteTimeoutPolicy{
Mode: RemoteTimeoutExplicit,
Value: time.Minute,
+1 -1
View File
@@ -196,7 +196,7 @@ func (s *e2bTerminalSession) Resize(ctx context.Context, cols, rows uint32) erro
return nil
}
// Close disconnects WeKnora from the PTY without killing the remote shell,
// Close disconnects Academy from the PTY without killing the remote shell,
// leaving it reattachable via Pty.Connect. The pump goroutine observes the
// disconnect and closes the output channel silently.
func (s *e2bTerminalSession) Close() error {
+1 -1
View File
@@ -8,7 +8,7 @@
//
// E2B Cloud's own gateway is lenient enough to hide the difference, so the gap
// only surfaces against other implementations of the protocol — the very
// backends WeKnora wants to support without carrying one adapter per vendor.
// backends Academy wants to support without carrying one adapter per vendor.
// Rather than fork the SDK, this transport rewrites the two data-plane details
// on the way out:
//
+2 -2
View File
@@ -4,7 +4,7 @@
// traffic token. Cube's SDK attaches that header
// itself once Sandbox.TrafficAccessToken is set, but go-e2b stores the token
// and never sends it — so for E2B the header has to be added by the one
// component WeKnora owns on that path: the data-plane RoundTripper.
// component Academy owns on that path: the data-plane RoundTripper.
//
// This registry is the lookup that makes it possible. It is process-local and
// lost on restart, which is fine: the first reconnect after a restart carries
@@ -67,7 +67,7 @@ func (r *InboundTokenRegistry) Delete(sandboxID string) {
// deliberate: an E2B Cloud deployment may leave sandbox_domain empty and let
// the SDK resolve its own default, and a domain-based check would then never
// fire. The registry lookup is the real authority — only Cube/E2B sandboxes
// whose token WeKnora recorded are in it.
// whose token Academy recorded are in it.
func sandboxIDFromDataPlaneHost(host string) string {
host = strings.ToLower(strings.TrimSpace(host))
if host == "" {
+2 -2
View File
@@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
type keepAliveCall struct {
@@ -83,7 +83,7 @@ func TestDockerKeepAliveRunsANoOpExecThatTouchesTheActivityMarker(t *testing.T)
require.Len(t, engine.execOptions, 1)
cmd := engine.execOptions[0].Cmd
require.Contains(t, cmd[2], dockerActivityMarker)
require.Equal(t, []string{"weknora-exec", "true"}, cmd[3:])
require.Equal(t, []string{"academy-exec", "true"}, cmd[3:])
}
func TestKeepAliverFromSeesThroughLangfuse(t *testing.T) {
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context"
"unicode/utf8"
"github.com/Tencent/WeKnora/internal/tracing/langfuse"
"academy/internal/tracing/langfuse"
"github.com/gorilla/websocket"
)
+6 -6
View File
@@ -16,7 +16,7 @@ import (
"context"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// RemoteProvider identifies a remote sandbox backend. Values match the
@@ -123,7 +123,7 @@ type RemoteCreateRequest struct {
Timeout RemoteTimeoutPolicy
// Metadata is a small key/value bag the provider stores alongside the
// sandbox. WeKnora uses this to recover ownership of stray sandboxes
// sandbox. Academy uses this to recover ownership of stray sandboxes
// after a restart. Adapters that cannot persist metadata return
// RemoteErrorKindUnsupported when non-empty metadata is supplied.
Metadata map[string]string
@@ -353,7 +353,7 @@ type RemoteExecRequest struct {
Timeout time.Duration
}
// DefaultSandboxExecUser is the account WeKnora runs sandboxed scripts as.
// DefaultSandboxExecUser is the account Academy runs sandboxed scripts as.
// It is root: every chat session gets its own sandbox, so the in-container
// account is not a tenant boundary and root is the least surprising default
// for an agent that installs packages and writes wherever it needs. The
@@ -386,7 +386,7 @@ type RemoteDirEntryType string
const (
RemoteEntryFile RemoteDirEntryType = "file"
RemoteEntryDir RemoteDirEntryType = "dir"
// RemoteEntryOther covers symlinks, sockets, devices, etc. WeKnora
// RemoteEntryOther covers symlinks, sockets, devices, etc. Academy
// artifact code treats these as opaque and skips them.
RemoteEntryOther RemoteDirEntryType = "other"
)
@@ -408,11 +408,11 @@ type RemoteStatEntry struct {
// SupportsReconnect is required for persistent session lifecycle management.
type RemoteSandboxCapabilities struct {
// SupportsReconnect is true when Connect can recover an operable handle
// from a provider-scoped sandbox ID after a WeKnora process restart.
// from a provider-scoped sandbox ID after a Academy process restart.
SupportsReconnect bool
// SupportsMetadata is true when Create+List preserve the Metadata bag,
// enabling orphan-sandbox recovery after a WeKnora restart.
// enabling orphan-sandbox recovery after a Academy restart.
SupportsMetadata bool
// SupportsListSandboxes is true when List enumerates existing sandboxes
+1 -1
View File
@@ -134,7 +134,7 @@ func TestIsRemoteDirAlreadyExists(t *testing.T) {
cubeSeedErr := NewRemoteError(
SandboxTypeCube, "MakeDir", RemoteErrorKindInternal,
"failed to make dir /opt/weknora/tenant/skills/sk-1: directory already exists: /opt/weknora/tenant/skills/sk-1",
"failed to make dir /opt/academy/tenant/skills/sk-1: directory already exists: /opt/academy/tenant/skills/sk-1",
nil,
)
tests := []struct {
+2 -2
View File
@@ -27,7 +27,7 @@ import (
)
// remoteScriptDir is the absolute directory inside every remote sandbox where
// WeKnora uploads scripts before execution. Kept identical to the historical
// Academy uploads scripts before execution. Kept identical to the historical
// Cube path so existing tenant scripts continue to reference /workspace files.
const remoteScriptDir = "/workspace"
@@ -198,7 +198,7 @@ func (s *RemoteSandbox) disposeEphemeral(parent context.Context, handle RemoteSa
// stays predictable regardless of which path performs the cleanup.
const remoteCleanupTimeout = 30 * time.Second
// remoteExecuteResult projects RemoteExecResult onto WeKnora's ExecuteResult.
// remoteExecuteResult projects RemoteExecResult onto Academy's ExecuteResult.
// It preserves the timeout contract: a timeout returns a killed result with
// exit code -1 and ErrTimeout as Error, never an error return.
func remoteExecuteResult(result *RemoteExecResult, err error, duration time.Duration) *ExecuteResult {
+1 -1
View File
@@ -42,7 +42,7 @@ func TestFakeSnapshotRoundTrip(t *testing.T) {
ctx := context.Background()
client := newFakeRemoteClient(SandboxTypeCube)
ref, err := client.CreateSnapshot(ctx, "sb-1", "weknora-sk-abc-g1")
ref, err := client.CreateSnapshot(ctx, "sb-1", "academy-sk-abc-g1")
require.NoError(t, err)
require.NotEmpty(t, ref.ID)
+4 -4
View File
@@ -80,7 +80,7 @@ const (
// envd (target "desktop-cube").
DefaultCubeDesktopTemplateImage = "wechatopenai/weknora-sandbox:main-desktop-cube"
// DesktopWebsockifyPort is websockify inside the sandbox. WeKnora dials
// DesktopWebsockifyPort is websockify inside the sandbox. Academy dials
// it through the provider gateway (Host "{port}-{id}.{domain}"), not by
// publishing the port on the host NIC. x11vnc stays on 127.0.0.1:5900
// with no RFB password; the Basic-auth check lives on websockify.
@@ -100,7 +100,7 @@ const (
DesktopSecretPath = "/run/desktop/secret"
// DesktopBasicAuthUser is the fixed username half of that credential.
DesktopBasicAuthUser = "weknora"
DesktopBasicAuthUser = "academy"
// The two commands the backend Execs around DesktopStartScript live in
// desktop_scripts.go as embedded .sh files:
@@ -336,7 +336,7 @@ type Config struct {
// DefaultDockerHost.
DockerHost string
// DockerTLSCertPath is a directory on the WeKnora host holding
// DockerTLSCertPath is a directory on the Academy host holding
// ca.pem / cert.pem / key.pem. Required for a TCP daemon; unix sockets
// do not use TLS.
DockerTLSCertPath string
@@ -409,7 +409,7 @@ type Config struct {
// CubeHTTPTimeout bounds each HTTP call to CubeAPI. Zero uses the default.
CubeHTTPTimeout time.Duration
// CubeDNSServers are nameserver IPs included when WeKnora builds the
// CubeDNSServers are nameserver IPs included when Academy builds the
// standard Cube template. Empty omits the field so Cubelet uses its
// cluster default.
CubeDNSServers []string
+4 -4
View File
@@ -9,9 +9,9 @@ import (
"time"
"unicode"
"github.com/Tencent/WeKnora/internal/background"
"github.com/Tencent/WeKnora/internal/sandbox/allocation"
"github.com/Tencent/WeKnora/internal/sandbox/workspace"
"academy/internal/background"
"academy/internal/sandbox/allocation"
"academy/internal/sandbox/workspace"
)
// SessionSandboxBindingVersion is the schema of a per-session machine binding.
@@ -116,7 +116,7 @@ type SessionSandboxBinding struct {
//
// Cube may reissue it on Connect after pause/resume; the lifecycle writes
// the fresh value back here. E2B issues it only at create. Either way this
// binding is the only place the credential survives a WeKnora restart.
// binding is the only place the credential survives a Academy restart.
//
// Stored as-is. It is a bearer credential, so the Redis instance holding
// these bindings must be access-controlled — it already holds the
+7 -7
View File
@@ -12,7 +12,7 @@ import (
"github.com/redis/go-redis/v9"
"github.com/Tencent/WeKnora/internal/common/redislock"
"academy/internal/common/redislock"
)
const (
@@ -280,7 +280,7 @@ func (s *RedisSessionSandboxBindingStore) ReplaceTrafficTokenIfMatch(
}
// WithLifecycleLock serializes create, recover, replace, and delete transitions
// across all WeKnora processes sharing Redis.
// across all Academy processes sharing Redis.
func (s *RedisSessionSandboxBindingStore) WithLifecycleLock(
ctx context.Context,
key SessionSandboxKey,
@@ -331,7 +331,7 @@ func (s *RedisSessionSandboxBindingStore) listTenantBindingKeys(
tenantID uint64,
) ([]SessionSandboxKey, error) {
prefix := fmt.Sprintf(
"weknora:sandbox:session:{%s:%d:", s.namespace, tenantID,
"academy:sandbox:session:{%s:%d:", s.namespace, tenantID,
)
const suffix = "}:binding"
pattern := escapeRedisGlob(prefix) + "*" + suffix
@@ -646,9 +646,9 @@ func (s *RedisSessionSandboxBindingStore) renewRewindLock(
// carry the allocation digest, which already includes the namespace.
func (s *RedisSessionSandboxBindingStore) keyBase(key SessionSandboxKey) string {
if key.IsUserScoped() {
return "weknora:sandbox:user:{" + key.User.Digest(s.namespace) + "}"
return "academy:sandbox:user:{" + key.User.Digest(s.namespace) + "}"
}
return "weknora:sandbox:session:{" + s.hashTag(key) + "}"
return "academy:sandbox:session:{" + s.hashTag(key) + "}"
}
func (s *RedisSessionSandboxBindingStore) bindingKey(key SessionSandboxKey) string {
@@ -672,11 +672,11 @@ var (
func validateRedisNamespace(namespace string) error {
if strings.ContainsAny(namespace, "{}") {
return errors.New("WEKNORA_REDIS_NAMESPACE must not contain braces")
return errors.New("ACADEMY_REDIS_NAMESPACE must not contain braces")
}
for _, r := range namespace {
if unicode.IsControl(r) {
return errors.New("WEKNORA_REDIS_NAMESPACE must not contain control characters")
return errors.New("ACADEMY_REDIS_NAMESPACE must not contain control characters")
}
}
return nil
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types/interfaces"
"github.com/stretchr/testify/require"
)
@@ -8,7 +8,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/common/redislock"
"academy/internal/common/redislock"
"github.com/alicebob/miniredis/v2"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/require"
@@ -154,8 +154,8 @@ func TestRedisSessionSandboxBindingUsesHashTagAndNoTTL(t *testing.T) {
bindingKey := store.bindingKey(key)
lockKey := store.lockKey(key)
require.Equal(t, "weknora:sandbox:session:{test:42:session-a}:binding", bindingKey)
require.Equal(t, "weknora:sandbox:session:{test:42:session-a}:create-lock", lockKey)
require.Equal(t, "academy:sandbox:session:{test:42:session-a}:binding", bindingKey)
require.Equal(t, "academy:sandbox:session:{test:42:session-a}:create-lock", lockKey)
created, err := store.Create(context.Background(), key, validSessionSandboxBinding(key, "sandbox-a"))
require.NoError(t, err)
@@ -311,11 +311,11 @@ func TestRedisUserMachineKeysShareOneHashTag(t *testing.T) {
require.True(t, created)
digest := testUserMachine().Digest(store.namespace)
require.True(t, mini.Exists("weknora:sandbox:user:{"+digest+"}:binding"))
require.True(t, mini.Exists("academy:sandbox:user:{"+digest+"}:binding"))
scoped := SessionSandboxKey{TenantID: 42, SessionID: userKeySessionID, User: testUserMachine()}
require.NoError(t, store.BeginTurn(ctx, scoped))
require.True(t, mini.Exists("weknora:sandbox:user:{"+digest+"}:session:"+userKeySessionID+":turn"))
require.True(t, mini.Exists("academy:sandbox:user:{"+digest+"}:session:"+userKeySessionID+":turn"))
got, err := store.Get(ctx, key)
require.NoError(t, err)
@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
func newTenantKeyTestManager(t *testing.T) (*SessionBoundManager, *fakeRemoteClient) {
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/Tencent/WeKnora/internal/sandbox/allocation"
"academy/internal/sandbox/allocation"
)
func validSessionSandboxBinding(key SessionSandboxKey, sandboxID string) SessionSandboxBinding {
@@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
+14 -14
View File
@@ -10,33 +10,33 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/common/redislock"
"github.com/Tencent/WeKnora/internal/sandbox/admission"
"github.com/Tencent/WeKnora/internal/sandbox/allocation"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/common/redislock"
"academy/internal/sandbox/admission"
"academy/internal/sandbox/allocation"
"academy/internal/types"
)
const (
remoteMetadataTenantID = "weknora_tenant_id"
remoteMetadataSessionID = "weknora_session_id"
remoteMetadataBindingVersion = "weknora_binding_version"
remoteMetadataProvider = "weknora_provider"
remoteMetadataTenantID = "academy_tenant_id"
remoteMetadataSessionID = "academy_session_id"
remoteMetadataBindingVersion = "academy_binding_version"
remoteMetadataProvider = "academy_provider"
// remoteMetadataConfigID records which sandbox config created the sandbox.
// Two configs in one workspace may share a provider account, so cleanup
// must filter by config as well as tenant/session ownership.
remoteMetadataConfigID = "weknora_sandbox_config_id"
remoteMetadataConfigID = "academy_sandbox_config_id"
// User machines are identified by their allocation digest, never by a
// session. weknora_tenant_id on a user machine is the CONFIG owner, so
// session. academy_tenant_id on a user machine is the CONFIG owner, so
// the config inventory and the credential-change sweep include every
// borrower's machine; the owner tenant is recorded separately.
remoteMetadataOwnerTenantID = "weknora_owner_tenant_id"
remoteMetadataMachineDigest = "weknora_machine_digest"
remoteMetadataAllocation = "weknora_allocation"
remoteMetadataOwnerTenantID = "academy_owner_tenant_id"
remoteMetadataMachineDigest = "academy_machine_digest"
remoteMetadataAllocation = "academy_allocation"
)
// ErrSandboxSessionDeleted reports that the owning WeKnora session no longer
// ErrSandboxSessionDeleted reports that the owning Academy session no longer
// exists. Callers must not execute work with the returned nil handle.
var ErrSandboxSessionDeleted = errors.New("sandbox session no longer exists")
+11 -11
View File
@@ -7,9 +7,9 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/sandbox/admission"
"github.com/Tencent/WeKnora/internal/sandbox/allocation"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/sandbox/admission"
"academy/internal/sandbox/allocation"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -1385,7 +1385,7 @@ func newUserLifecycleFixture(t *testing.T) *userLifecycleFixture {
skillOutputEnvVar: SessionOutputRoot, sessionInputEnvVar: SessionInputRoot, "KEEP": "1",
}},
time.Minute, "cfg-1", nil,
withUserMachines("weknora", reg),
withUserMachines("academy", reg),
withConfigCreateGate(reg, 42),
)
require.NoError(t, err)
@@ -1443,7 +1443,7 @@ func TestUserMachineIsSharedBySessions(t *testing.T) {
req := f.client.lastCreateRequest
require.Equal(t, "user", req.Metadata[remoteMetadataAllocation])
require.Equal(t, f.machine.Digest("weknora"), req.Metadata[remoteMetadataMachineDigest])
require.Equal(t, f.machine.Digest("academy"), req.Metadata[remoteMetadataMachineDigest])
require.Equal(t, "42", req.Metadata[remoteMetadataTenantID])
require.NotContains(t, req.Metadata, remoteMetadataSessionID)
require.NotContains(t, req.EnvVars, skillOutputEnvVar, "session paths are per call on a shared machine")
@@ -1548,7 +1548,7 @@ func TestStaleUserMachineWaitsForOtherSessions(t *testing.T) {
require.NoError(t, err)
require.Equal(t, 1, n)
machine := admission.MachineScope(f.machine.Digest("weknora"))
machine := admission.MachineScope(f.machine.Digest("academy"))
self := admission.SessionMember(userSessionA, "shell", "self")
selfLease, err := f.admission.Hold(ctx, machine, self, time.Minute)
require.NoError(t, err)
@@ -1589,7 +1589,7 @@ func TestStaleRebuildStopsWhenTheBarrierIsLost(t *testing.T) {
require.NoError(t, err)
f.client.deleteHook = func(context.Context, string) error {
f.admission.LoseBarrier(admission.MachineScope(f.machine.Digest("weknora")))
f.admission.LoseBarrier(admission.MachineScope(f.machine.Digest("academy")))
return nil
}
_, err = f.lifecycle.Resolve(ctx, f.sessionKey(userSessionA))
@@ -1612,7 +1612,7 @@ func TestReclaimUserMachineRespectsAdmissionAndTheCheck(t *testing.T) {
h, err := f.lifecycle.Resolve(ctx, f.sessionKey(userSessionA))
require.NoError(t, err)
machine := f.sessionKey(userSessionA).Machine()
scope := admission.MachineScope(f.machine.Digest("weknora"))
scope := admission.MachineScope(f.machine.Digest("academy"))
pty, err := f.admission.Hold(ctx, scope, admission.SessionMember(userSessionB, "pty", "t"), time.Minute)
require.NoError(t, err)
@@ -1644,7 +1644,7 @@ func TestReclaimUserMachineStopsWhenTheBarrierIsLost(t *testing.T) {
_, err := f.lifecycle.Resolve(ctx, f.sessionKey(userSessionA))
require.NoError(t, err)
machine := f.sessionKey(userSessionA).Machine()
scope := admission.MachineScope(f.machine.Digest("weknora"))
scope := admission.MachineScope(f.machine.Digest("academy"))
f.client.deleteHook = func(context.Context, string) error {
f.admission.LoseBarrier(scope)
return nil
@@ -1667,7 +1667,7 @@ func TestReclaimUserMachineChecksTheBarrierBeforeEachMetadataDelete(t *testing.T
_, err = f.bindings.DeleteIfMatch(ctx, machine, SandboxTypeCube, first.ID())
require.NoError(t, err)
second := f.client.addSandboxWithMetadata(f.lifecycle.metadata(machine)) // a duplicate left by a failed create
scope := admission.MachineScope(f.machine.Digest("weknora"))
scope := admission.MachineScope(f.machine.Digest("academy"))
deletes := 0
f.client.deleteHook = func(context.Context, string) error {
deletes++
@@ -1688,7 +1688,7 @@ func TestReclaimUserMachineMetadataDeleteStopsWhenTheBarrierIsLost(t *testing.T)
machine := f.sessionKey(userSessionA).Machine()
_, err = f.bindings.DeleteIfMatch(ctx, machine, SandboxTypeCube, first.ID())
require.NoError(t, err)
scope := admission.MachineScope(f.machine.Digest("weknora"))
scope := admission.MachineScope(f.machine.Digest("academy"))
f.client.deleteHook = func(hookCtx context.Context, _ string) error {
f.admission.LoseBarrier(scope)
+26 -26
View File
@@ -5,7 +5,7 @@
// treats the authoritative session→sandbox binding as external state that
// lives in SessionSandboxBindingStore (Redis in production, memory in tests
// and single-process deployments). This makes the manager provider-neutral
// (Cube , E2B) and multi-instance safe: two WeKnora processes
// (Cube , E2B) and multi-instance safe: two Academy processes
// concurrently servicing the same session never allocate duplicate sandboxes,
// and a restart never loses the session's remote resource.
//
@@ -37,12 +37,12 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/common/redislock"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/sandbox/admission"
"github.com/Tencent/WeKnora/internal/sandbox/allocation"
"github.com/Tencent/WeKnora/internal/sandbox/workspace"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/common/redislock"
"academy/internal/logger"
"academy/internal/sandbox/admission"
"academy/internal/sandbox/allocation"
"academy/internal/sandbox/workspace"
"academy/internal/types"
)
// SessionInputRoot is reserved for durable user attachments restored from
@@ -55,14 +55,14 @@ const SessionInputRoot = workspace.InputDir
// do not depend on the template user being able to mkdir under /workspace.
const SessionOutputRoot = workspace.OutputDir
// skillOutputEnvVar matches the skills manager's WEKNORA_SKILL_OUTPUT_DIR.
const skillOutputEnvVar = "WEKNORA_SKILL_OUTPUT_DIR"
// skillOutputEnvVar matches the skills manager's ACADEMY_SKILL_OUTPUT_DIR.
const skillOutputEnvVar = "ACADEMY_SKILL_OUTPUT_DIR"
// sessionInputEnvVar matches the skills manager's WEKNORA_SESSION_INPUT_DIR.
// sessionInputEnvVar matches the skills manager's ACADEMY_SESSION_INPUT_DIR.
// Both names are injected into the sandbox environment itself, not only into
// the skill-script Execute call, so an agent exploring with shell_exec reads
// the same paths the skills framework uses.
const sessionInputEnvVar = "WEKNORA_SESSION_INPUT_DIR"
const sessionInputEnvVar = "ACADEMY_SESSION_INPUT_DIR"
// SessionWorkspaceRoot is the writable workspace root inside remote sandboxes.
// shell_exec work_dir must stay underneath this path.
@@ -476,7 +476,7 @@ func withWorkspaceEnvDefaults(env map[string]string) map[string]string {
}
// executionOutputDir resolves the artifact directory for this Execute call.
// It prefers WEKNORA_SKILL_OUTPUT_DIR from cfg.Env when the path stays under
// It prefers ACADEMY_SKILL_OUTPUT_DIR from cfg.Env when the path stays under
// SessionWorkspaceRoot; otherwise it falls back to SessionOutputRoot.
func executionOutputDir(cfg *ExecuteConfig) string {
if cfg != nil && cfg.Env != nil {
@@ -769,7 +769,7 @@ func (m *SessionBoundManager) WriteSessionWorkspaceFiles(
parents := make(map[string]struct{}, len(files))
for _, file := range files {
// Session mode keeps the historical cleaner, which is pinned to
// /workspace and ignores a host WEKNORA_SKILL_OUTPUT_DIR overlay.
// /workspace and ignores a host ACADEMY_SKILL_OUTPUT_DIR overlay.
clean, err := cleanSessionWorkspaceWritePath(file.Path)
if sc.user {
clean, err = workspace.CleanWriteFileIn(sc.layout, file.Path)
@@ -1035,7 +1035,7 @@ func (m *SessionBoundManager) ExecShellCommand(
// ExecShellCommandWithOptions runs a shell command with install-only options.
// Fallback is explicitly refused so even privileged installer calls never
// escape onto the WeKnora host machine.
// escape onto the Academy host machine.
func (m *SessionBoundManager) ExecShellCommandWithOptions(
ctx context.Context,
sessionID string,
@@ -1218,7 +1218,7 @@ func (m *SessionBoundManager) SessionInstallShellExecutor() SessionInstallShellE
}
// SessionWorkspaceLayout reports where sessionID's files live. A session-owned
// machine keeps the /workspace contract (a validated WEKNORA_SKILL_OUTPUT_DIR
// machine keeps the /workspace contract (a validated ACADEMY_SKILL_OUTPUT_DIR
// overlays OutputDir). A shared machine reports that session's directory.
// Lookups do not admit and do not require a tenant: tool descriptions call
// this before any provider operation.
@@ -1508,7 +1508,7 @@ var _ SessionDesktopProvider = (*SessionBoundManager)(nil)
// Cleanup marks the manager closed. Session sandboxes are not force-deleted
// here: their lifecycle is authoritative in the binding store and would
// leak to any other WeKnora replica if this replica reaped them on shutdown.
// leak to any other Academy replica if this replica reaped them on shutdown.
// Providers reclaim idle sandboxes via their own timeout/pause policies.
func (m *SessionBoundManager) Cleanup(_ context.Context) error {
if m == nil {
@@ -1690,7 +1690,7 @@ type forkSnapshotCreator interface {
}
// createForkOrProviderSnapshot uses a fork-specific commit when the client
// has one (Docker's weknora-fork/ namespace). Cube and E2B have no extra
// has one (Docker's academy-fork/ namespace). Cube and E2B have no extra
// namespace, so they keep using CreateSnapshot.
func createForkOrProviderSnapshot(
ctx context.Context,
@@ -2338,7 +2338,7 @@ func (m *SessionBoundManager) DeleteSessionWorkspaces(
// Refuse a symlinked parent instead of following it: an agent on this
// machine runs as root and may have replaced one.
script := `set -eu
for p in /workspace /workspace/sessions /var/lib/weknora /var/lib/weknora/sessions; do
for p in /workspace /workspace/sessions /var/lib/academy /var/lib/academy/sessions; do
if [ -L "$p" ]; then echo "refusing to clean through symlinked $p" >&2; exit 4; fi
done
for t in ` + strings.Join(targets, " ") + `; do
@@ -2397,7 +2397,7 @@ func withSessionEnv(env map[string]string, layout WorkspaceLayout) map[string]st
// userScriptDir is where an uploaded skill script lands on a shared machine.
func userScriptDir(layout WorkspaceLayout) string {
return path.Join(layout.Root, ".weknora", "scripts")
return path.Join(layout.Root, ".academy", "scripts")
}
// sessionKey resolves the tenant-scoped binding key. Tenant ID comes from the
@@ -2696,12 +2696,12 @@ SRC_GIT=%s
DST_TREE=%s
DST_GIT=%s
SHA=%s
for p in /workspace /workspace/sessions /var/lib/weknora /var/lib/weknora/sessions; do
for p in /workspace /workspace/sessions /var/lib/academy /var/lib/academy/sessions; do
if [ -L "$p" ]; then echo "refusing symlinked $p" >&2; exit 4; fi
done
if [ -e "$DST_TREE" ] || [ -e "$DST_GIT" ]; then echo "fork target exists" >&2; exit 5; fi
mkdir -p /var/lib/weknora/sessions /workspace/sessions
tmp=$(mktemp -d /var/lib/weknora/sessions/.fork.XXXXXX)
mkdir -p /var/lib/academy/sessions /workspace/sessions
tmp=$(mktemp -d /var/lib/academy/sessions/.fork.XXXXXX)
trap 'rm -rf -- "$tmp"' EXIT
g() { git -c safe.directory='*' -c core.hooksPath=/dev/null "$@"; }
g --git-dir="$SRC_GIT" cat-file -e "$SHA^{commit}"
@@ -2712,8 +2712,8 @@ g init -q --bare "$tmp/repo.git"
g -c uploadpack.allowAnySHA1InWant=true --git-dir="$tmp/repo.git" fetch -q --no-tags "$SRC_GIT" "$SHA:refs/heads/main"
g --git-dir="$tmp/repo.git" symbolic-ref HEAD refs/heads/main
g --git-dir="$tmp/repo.git" config core.bare false
g --git-dir="$tmp/repo.git" config user.email agent@weknora.local
g --git-dir="$tmp/repo.git" config user.name 'WeKnora Agent'
g --git-dir="$tmp/repo.git" config user.email agent@academy.local
g --git-dir="$tmp/repo.git" config user.name 'Academy Agent'
mkdir -p "$tmp/tree"
g --git-dir="$tmp/repo.git" --work-tree="$tmp/tree" checkout -q -f main
mkdir -p "$tmp/tree/input" "$tmp/tree/output"
@@ -2743,7 +2743,7 @@ func (f *workspaceFork) Remove(targetSessionID string) error {
return err
}
_, err = f.run(fmt.Sprintf(`set -eu
for p in /workspace /workspace/sessions /var/lib/weknora /var/lib/weknora/sessions; do
for p in /workspace /workspace/sessions /var/lib/academy /var/lib/academy/sessions; do
if [ -L "$p" ]; then echo "refusing symlinked $p" >&2; exit 4; fi
done
rm -rf -- %s %s`, ShellQuote(target.Root), ShellQuote(target.GitDir)))
@@ -2762,7 +2762,7 @@ var (
)
// PermissiveSessionExistenceChecker accepts every session. It is safe in
// deployments where WeKnora's own DestroySession is the only session-delete
// deployments where Academy's own DestroySession is the only session-delete
// path (single-process memory binding store); the Redis-authoritative
// deployment must inject a real checker consulting the session repository.
type PermissiveSessionExistenceChecker struct{}
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
func newSessionManagerTerminalTestHarness(t *testing.T) (*SessionBoundManager, *terminalFakeClient) {
@@ -27,7 +27,7 @@ func newSessionManagerTerminalTestHarnessFor(
client.omitsInboundTokenCarrier = provider == SandboxTypeDocker
cfg := DefaultConfig()
cfg.CubeTemplate = "tpl-test"
cfg.DockerImage = "weknora/sandbox:test"
cfg.DockerImage = "academy/sandbox:test"
mgr, err := NewSessionBoundManager(SessionBoundManagerConfig{
Config: cfg,
Client: client,
+27 -27
View File
@@ -15,10 +15,10 @@ import (
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/require"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/sandbox/admission"
"github.com/Tencent/WeKnora/internal/sandbox/allocation"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/logger"
"academy/internal/sandbox/admission"
"academy/internal/sandbox/allocation"
"academy/internal/types"
)
func TestExecutionOutputDir(t *testing.T) {
@@ -47,7 +47,7 @@ func TestExecutionOutputDir(t *testing.T) {
name: "rejects path outside workspace",
cfg: &ExecuteConfig{
Env: map[string]string{
skillOutputEnvVar: "/tmp/weknora-skill-output",
skillOutputEnvVar: "/tmp/academy-skill-output",
},
},
want: SessionOutputRoot,
@@ -116,7 +116,7 @@ func TestWorkspaceBootstrapPreservesExistingData(t *testing.T) {
}
// The agent can delete /workspace/output between turns. Preparing only once
// per process would leave later writes failing until WeKnora restarted.
// per process would leave later writes failing until Academy restarted.
func TestSessionBoundManagerPreparesWorkspaceOnEveryCall(t *testing.T) {
client := newFakeRemoteClient(SandboxTypeCube)
cfg := DefaultConfig()
@@ -527,7 +527,7 @@ func TestBuildSessionCreateRequestMarksSkillSnapshot(t *testing.T) {
require.NoError(t, err)
require.True(t, request.FromSnapshot)
require.Equal(t, "secret", request.EnvVars["HF_TOKEN"])
require.NotEmpty(t, request.EnvVars["WEKNORA_SKILL_OUTPUT_DIR"])
require.NotEmpty(t, request.EnvVars["ACADEMY_SKILL_OUTPUT_DIR"])
}
func newSessionManagerExecTestHarness(t *testing.T) (*SessionBoundManager, *fakeRemoteClient) {
@@ -911,7 +911,7 @@ func (b *clientBoundRecordingBootstrapper) AfterCreate(
return errors.New("AfterCreate must use the bound remote client")
}
_, err := b.client.Exec(ctx, handle, RemoteExecRequest{
Command: "echo weknora-fork-after-create",
Command: "echo academy-fork-after-create",
Shell: true,
WorkDir: SessionWorkspaceRoot,
Timeout: time.Second,
@@ -958,7 +958,7 @@ func TestNewSessionBoundManagerBindsBootstrapperToClient(t *testing.T) {
found := false
client.mu.Lock()
for _, req := range client.execRequests {
if strings.Contains(req.Command, "weknora-fork-after-create") {
if strings.Contains(req.Command, "academy-fork-after-create") {
found = true
require.True(t, req.Shell)
require.Equal(t, SessionWorkspaceRoot, req.WorkDir)
@@ -1080,7 +1080,7 @@ func newUserManagerHarnessWith(
assignments ...allocation.Assignment,
) *userHarness {
t.Helper()
return newUserManagerHarnessWithDirectory(t, client, store, reg, newFakeAllocations(assignments...), "weknora")
return newUserManagerHarnessWithDirectory(t, client, store, reg, newFakeAllocations(assignments...), "academy")
}
// newUserManagerHarnessWithDirectory is newUserManagerHarnessWith with the
@@ -1105,7 +1105,7 @@ func newUserManagerHarnessWithDirectory(
}
// integrationEnv returns an integration dependency's address. Missing, the
// test is skipped — unless WEKNORA_REQUIRE_INTEGRATION=1, which turns the
// test is skipped — unless ACADEMY_REQUIRE_INTEGRATION=1, which turns the
// skip into a failure so an enablement run cannot pass by skipping.
func integrationEnv(t *testing.T, name string) string {
t.Helper()
@@ -1113,8 +1113,8 @@ func integrationEnv(t *testing.T, name string) string {
if v != "" {
return v
}
if os.Getenv("WEKNORA_REQUIRE_INTEGRATION") == "1" {
t.Fatalf("%s is required when WEKNORA_REQUIRE_INTEGRATION=1", name)
if os.Getenv("ACADEMY_REQUIRE_INTEGRATION") == "1" {
t.Fatalf("%s is required when ACADEMY_REQUIRE_INTEGRATION=1", name)
}
t.Skipf("set %s to run against a real dependency", name)
return ""
@@ -1131,7 +1131,7 @@ func multiReplicaPair(
if redisAddr == "" {
redisAddr = miniredis.RunT(t).Addr()
}
ns := "weknora-it-" + uuid.NewString()[:8]
ns := "academy-it-" + uuid.NewString()[:8]
client := newFakeRemoteClient(SandboxTypeCube)
allocs := newFakeAllocations(assignments...)
replica := func() *userHarness {
@@ -1155,7 +1155,7 @@ func machineDigest(t *testing.T, sessionID string) string {
t.Helper()
m, ok := userAssignmentFor(sessionID).UserMachine()
require.True(t, ok)
return m.Digest("weknora")
return m.Digest("academy")
}
func TestUserSessionsShareOneMachineWithSeparateDirectories(t *testing.T) {
@@ -1166,7 +1166,7 @@ func TestUserSessionsShareOneMachineWithSeparateDirectories(t *testing.T) {
require.NoError(t, err)
reqA := lastExecRequest(t, h.client)
_, err = h.mgr.ExecShellCommand(ctx, userSessionB, "true", "", time.Second, map[string]string{
"WEKNORA_SKILL_OUTPUT_DIR": "/workspace/output", // a config value must not win
"ACADEMY_SKILL_OUTPUT_DIR": "/workspace/output", // a config value must not win
})
require.NoError(t, err)
reqB := lastExecRequest(t, h.client)
@@ -1175,8 +1175,8 @@ func TestUserSessionsShareOneMachineWithSeparateDirectories(t *testing.T) {
require.Equal(t, 1, creates)
require.Equal(t, userSessionRoot(userSessionA), reqA.WorkDir)
require.Equal(t, userSessionRoot(userSessionB), reqB.WorkDir)
require.Equal(t, userSessionRoot(userSessionB)+"/output", reqB.Env["WEKNORA_SKILL_OUTPUT_DIR"])
require.Equal(t, userSessionRoot(userSessionB)+"/input", reqB.Env["WEKNORA_SESSION_INPUT_DIR"])
require.Equal(t, userSessionRoot(userSessionB)+"/output", reqB.Env["ACADEMY_SKILL_OUTPUT_DIR"])
require.Equal(t, userSessionRoot(userSessionB)+"/input", reqB.Env["ACADEMY_SESSION_INPUT_DIR"])
idA, ok := h.mgr.BoundSandboxID(ctx, userSessionA)
require.True(t, ok)
@@ -1500,7 +1500,7 @@ func TestUploadedScriptsStayInTheSessionDirectory(t *testing.T) {
h.client.mu.Lock()
defer h.client.mu.Unlock()
require.NotEmpty(t, h.client.writeFiles)
require.Equal(t, userSessionRoot(userSessionA)+"/.weknora/scripts/run.py",
require.Equal(t, userSessionRoot(userSessionA)+"/.academy/scripts/run.py",
h.client.writeFiles[len(h.client.writeFiles)-1].path)
}
@@ -1609,7 +1609,7 @@ func TestDeleteSessionWorkspacesStopsTheCommandWhenALeaseIsLost(t *testing.T) {
m, _ := userAssignmentFor(userSessionA).UserMachine()
h.client.execHook = func(req RemoteExecRequest) (*RemoteExecResult, error) {
if strings.Contains(req.Command, "rm -rf") {
h.admission.LoseBarrier(admission.SessionScope(m.Digest("weknora"), userSessionA))
h.admission.LoseBarrier(admission.SessionScope(m.Digest("academy"), userSessionA))
time.Sleep(50 * time.Millisecond) // the cancellation reaches the call
return nil, context.Canceled
}
@@ -1653,7 +1653,7 @@ func TestWorkspaceForkHoldsLeasesAndCopiesWithOneGuardedScript(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, fork.SandboxID())
machine, _ := userAssignmentFor(userSessionA).UserMachine()
active, err := h.admission.ActiveExcept(ctx, admission.MachineScope(machine.Digest("weknora")))
active, err := h.admission.ActiveExcept(ctx, admission.MachineScope(machine.Digest("academy")))
require.NoError(t, err)
require.Equal(t, 1, active, "the fork holds the machine until Release")
@@ -1662,7 +1662,7 @@ func TestWorkspaceForkHoldsLeasesAndCopiesWithOneGuardedScript(t *testing.T) {
require.Equal(t, map[string]bool{sha: true, older: true}, reachable)
req := lastExecRequest(t, h.client)
require.Equal(t, "root", req.User)
require.Contains(t, req.Command, "/var/lib/weknora/sessions/c812e1edb644.git")
require.Contains(t, req.Command, "/var/lib/academy/sessions/c812e1edb644.git")
require.Contains(t, req.Command, userSessionRoot(userSessionB))
require.Contains(t, req.Command, "core.hooksPath=/dev/null")
require.Contains(t, req.Command, `"160000"`, "gitlinks are refused")
@@ -1676,7 +1676,7 @@ func TestWorkspaceForkHoldsLeasesAndCopiesWithOneGuardedScript(t *testing.T) {
require.NoError(t, fork.Remove(userSessionB))
require.Contains(t, lastExecRequest(t, h.client).Command, userSessionRoot(userSessionB))
fork.Release()
active, _ = h.admission.ActiveExcept(ctx, admission.MachineScope(machine.Digest("weknora")))
active, _ = h.admission.ActiveExcept(ctx, admission.MachineScope(machine.Digest("academy")))
require.Zero(t, active)
}
@@ -1689,7 +1689,7 @@ func TestWorkspaceForkStopsAfterTheLeaseIsLost(t *testing.T) {
require.NoError(t, err)
defer fork.Release()
machine, _ := userAssignmentFor(userSessionA).UserMachine()
h.admission.ExpireMember(admission.MachineScope(machine.Digest("weknora")),
h.admission.ExpireMember(admission.MachineScope(machine.Digest("academy")),
fork.(interface{ Member() string }).Member())
require.Eventually(t, func() bool {
@@ -1734,7 +1734,7 @@ func TestUserModeTerminalNeverReattachesAClientPID(t *testing.T) {
}
func TestMultiReplicaRealRedisFirstAllocationCreatesOneMachine(t *testing.T) {
r1, r2, _ := multiReplicaPair(t, integrationEnv(t, "WEKNORA_TEST_REDIS_ADDR"),
r1, r2, _ := multiReplicaPair(t, integrationEnv(t, "ACADEMY_TEST_REDIS_ADDR"),
userAssignmentFor(userSessionA), userAssignmentFor(userSessionB))
ctx := ownerCtx()
var wg sync.WaitGroup
@@ -1767,7 +1767,7 @@ func TestMultiReplicaRealRedisFirstAllocationCreatesOneMachine(t *testing.T) {
}
func TestMultiReplicaRealRedisLeaseBlocksRebuildAndReclaim(t *testing.T) {
r1, r2, _ := multiReplicaPair(t, integrationEnv(t, "WEKNORA_TEST_REDIS_ADDR"),
r1, r2, _ := multiReplicaPair(t, integrationEnv(t, "ACADEMY_TEST_REDIS_ADDR"),
userAssignmentFor(userSessionA), userAssignmentFor(userSessionB))
ctx := ownerCtx()
_, err := r1.mgr.ExecShellCommand(ctx, userSessionA, "true", "", time.Second, nil)
@@ -1797,7 +1797,7 @@ func TestMultiReplicaRealRedisLeaseBlocksRebuildAndReclaim(t *testing.T) {
}
func TestMultiReplicaRealRedisLostLeaseStopsTheHolderAndFreesTheMachine(t *testing.T) {
r1, r2, raw := multiReplicaPair(t, integrationEnv(t, "WEKNORA_TEST_REDIS_ADDR"),
r1, r2, raw := multiReplicaPair(t, integrationEnv(t, "ACADEMY_TEST_REDIS_ADDR"),
userAssignmentFor(userSessionA), userAssignmentFor(userSessionB))
ctx := ownerCtx()
_, err := r1.mgr.ExecShellCommand(ctx, userSessionA, "true", "", time.Second, nil)
@@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -15,7 +15,7 @@ import (
// ShellJobsRoot is where job directories live inside a remote sandbox, outside
// the /workspace git worktree so checkpoints never see them (shell 稿 §9.1).
const ShellJobsRoot = "/var/lib/weknora/jobs"
const ShellJobsRoot = "/var/lib/academy/jobs"
const (
shellJobSegmentBytes = 16 * 1024 * 1024
@@ -241,7 +241,7 @@ func dockerIntegrationHandleFrom(t *testing.T, client RemoteSandboxClient) Remot
defer cancel()
handle, err := client.Create(ctx, RemoteCreateRequest{
TemplateID: image,
Metadata: map[string]string{"weknora.test": "shell-job"},
Metadata: map[string]string{"academy.test": "shell-job"},
})
require.NoError(t, err)
t.Cleanup(func() {
@@ -503,7 +503,7 @@ func TestShellJobBudgetedIncrementalReadAfterRotation(t *testing.T) {
client := dockerIntegrationClient(t)
handle := dockerIntegrationHandle(t, client)
id := "sj_c111"
script := `D=/var/lib/weknora/jobs/sj_c111; mkdir -p "$D"
script := `D=/var/lib/academy/jobs/sj_c111; mkdir -p "$D"
printf '%s' '{"work_id":"sj_c111"}' > "$D/meta.json"
printf '%s' '{"state":"succeeded"}' > "$D/status.json"
printf 65536 > "$D/stdout.rotated"
+3 -3
View File
@@ -11,7 +11,7 @@ import (
"strings"
)
const shellJobMarkerPrefix = "__WEKNORA_SJ__"
const shellJobMarkerPrefix = "__ACADEMY_SJ__"
// shellJobRotateFunc keeps an 8 KiB head and rotates a stream at 16 MiB.
// Truncating with `: >` leaves no sparse hole; writers only append.
@@ -304,7 +304,7 @@ func shellJobWrapperScript(job ShellJobMeta, execCommand string, docker bool) st
shSingleQuote(execCommand))
b.WriteString("C=$!;\n")
if docker {
b.WriteString("( while :; do sleep 30; touch /var/lib/weknora-sandbox-activity; done ) &\n")
b.WriteString("( while :; do sleep 30; touch /var/lib/academy-sandbox-activity; done ) &\n")
b.WriteString("TOUCH=$!;\n")
} else {
b.WriteString("TOUCH=0;\n")
@@ -351,7 +351,7 @@ if [ "$PGID" -gt 1 ] && [ -d "/proc/$PGID" ]; then
kill -KILL -$PGID 2>/dev/null || true
fi
if [ "$TOUCH" -gt 1 ] && [ -r "/proc/$TOUCH/cmdline" ] &&
tr '\0' ' ' < "/proc/$TOUCH/cmdline" | grep -F -q weknora-sandbox-activity; then
tr '\0' ' ' < "/proc/$TOUCH/cmdline" | grep -F -q academy-sandbox-activity; then
kill -KILL "$TOUCH" 2>/dev/null || true
fi
true
+8 -8
View File
@@ -22,7 +22,7 @@ func TestSubmitScriptEmbedsJobAndYield(t *testing.T) {
job := ShellJobMeta{ID: "sj_0123", Command: "TOKEN=1 make build", WorkDir: "/workspace"}
script, marker := ShellJobSubmitScript(job, "TOKEN=1 make build", 10000)
require.True(t, strings.HasPrefix(marker, shellJobMarkerPrefix))
require.Contains(t, script, "/var/lib/weknora/jobs/sj_0123")
require.Contains(t, script, "/var/lib/academy/jobs/sj_0123")
require.Contains(t, script, marker) // 结尾行标记
require.Contains(t, script, "10000") // yield 轮询上限
require.Contains(t, script, "setsid") // wrapper 脱管启动
@@ -49,11 +49,11 @@ func TestSubmitScriptPersistsMaskedMetaNotExecCommand(t *testing.T) {
func TestSubmitScriptDockerFollowsBackendNotSandboxID(t *testing.T) {
job := ShellJobMeta{ID: "sj_0123", SandboxID: "abc123def"}
script, _ := ShellJobSubmitScript(job, "true", 1)
require.NotContains(t, script, "weknora-sandbox-activity")
require.NotContains(t, script, "academy-sandbox-activity")
script, _ = ShellJobSubmitScriptWithBackend(job, "true", 1, true)
require.Contains(t, script, "weknora-sandbox-activity")
require.Contains(t, script, "academy-sandbox-activity")
script, _ = ShellJobSubmitScriptWithBackend(job, "true", 1, false)
require.NotContains(t, script, "weknora-sandbox-activity")
require.NotContains(t, script, "academy-sandbox-activity")
}
func TestWrapperScriptRotatesAndTrapsTerm(t *testing.T) {
@@ -63,7 +63,7 @@ func TestWrapperScriptRotatesAndTrapsTerm(t *testing.T) {
require.Contains(t, script, "kill -") // 杀命令进程组
require.Contains(t, script, "8192") // .head 保留 8 KiB
require.Contains(t, script, "16777216") // 16 MiB 轮转阈值
require.Contains(t, script, "weknora-sandbox-activity") // docker touch
require.Contains(t, script, "academy-sandbox-activity") // docker touch
require.Contains(t, script, "touch_pid")
require.Contains(t, script, ">>") // 追加写,轮转截断无空洞
// 终态只写一次:构建残留的 printf … > /dev/null 不能留下。
@@ -71,7 +71,7 @@ func TestWrapperScriptRotatesAndTrapsTerm(t *testing.T) {
require.Contains(t, script, "cancelled")
require.Contains(t, script, `%Y-%m-%dT%H:%M:%S.%3NZ`)
plain := shellJobWrapperScript(job, "sleep 100", false)
require.NotContains(t, plain, "weknora-sandbox-activity")
require.NotContains(t, plain, "academy-sandbox-activity")
require.Contains(t, plain, "TOUCH=0")
require.NotContains(t, plain, "> /dev/null")
requireShellSyntax(t, script)
@@ -103,7 +103,7 @@ func TestMarkerFilterHoldsOnlyPrefixLengthTail(t *testing.T) {
require.Equal(t, "keep", string(body))
require.Equal(t, "__WEK", string(tail))
body, tail = s.Feed([]byte("NORA_SJ"))
require.Equal(t, "__WEKNORA_SJ", string(tail), "非标记前缀最终全部放行")
require.Equal(t, "__ACADEMY_SJ", string(tail), "非标记前缀最终全部放行")
require.Empty(t, body)
}
@@ -298,7 +298,7 @@ func TestKillOrphansScriptSkipsPidOne(t *testing.T) {
require.Contains(t, script, "TOUCH=77")
require.Contains(t, script, "kill -TERM -$PGID")
require.Contains(t, script, "kill -KILL -$PGID")
require.Contains(t, script, "weknora-sandbox-activity")
require.Contains(t, script, "academy-sandbox-activity")
require.Contains(t, script, `-gt 1`)
require.Contains(t, script, "\ntrue\n")
idle := ShellJobKillOrphansScript(1, 0)
+2 -2
View File
@@ -7,9 +7,9 @@ import (
)
func TestShellQuoteNeutralisesShellMetacharacters(t *testing.T) {
quoted := ShellQuote("/opt/weknora/tenant/skills/sk-1/scripts/x$(id).py")
quoted := ShellQuote("/opt/academy/tenant/skills/sk-1/scripts/x$(id).py")
require.Equal(t, `'/opt/weknora/tenant/skills/sk-1/scripts/x$(id).py'`, quoted,
require.Equal(t, `'/opt/academy/tenant/skills/sk-1/scripts/x$(id).py'`, quoted,
"single quotes are the only form that keeps $ and backticks inert in sh")
}
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"encoding/hex"
"strings"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// SkillImageFingerprint identifies the provider account a skill snapshot lives
+6 -6
View File
@@ -6,7 +6,7 @@ import (
"path"
"strings"
"github.com/Tencent/WeKnora/internal/sandbox/workspace"
"academy/internal/sandbox/workspace"
)
const (
@@ -30,7 +30,7 @@ func IsHostSkillTarget(configID string) bool {
return strings.TrimSpace(configID) == HostSkillTargetID
}
const skillShellArgv0 = "weknora-skill"
const skillShellArgv0 = "academy-skill"
// ErrInvalidSkillName is returned when a skill name would escape SkillsImageRoot
// or is not a single path segment.
@@ -92,7 +92,7 @@ func SkillRequirementsPathIn(skillDir string) string {
if strings.TrimSpace(skillDir) == "" {
return ""
}
return path.Join(skillDir, ".weknora", "requirements.json")
return path.Join(skillDir, ".academy", "requirements.json")
}
// RunnableWorkspaceScript reports whether scriptPath is a session-writable
@@ -110,7 +110,7 @@ func RunnableWorkspaceScriptIn(l WorkspaceLayout, scriptPath string) (string, bo
// ValidatedSessionOutputDir normalises a configured artifact directory and
// reports whether it may be used.
//
// It is the single gate for every WEKNORA_SKILL_OUTPUT_DIR override, wherever
// It is the single gate for every ACADEMY_SKILL_OUTPUT_DIR override, wherever
// it comes from: the host environment the app reads at startup, or a tenant's
// sandbox config. Without it the two disagreed — execution validated the path
// and fell back to SessionOutputRoot, while the tools and the artifact
@@ -131,7 +131,7 @@ func ValidatedOutputDirIn(l WorkspaceLayout, dir string) (string, bool) {
}
// ValidatedImageSkillDir reports whether skillDir is exactly one installed
// skill directory under SkillsImageRoot (for example /opt/weknora/tenant/skills/pdf).
// skill directory under SkillsImageRoot (for example /opt/academy/tenant/skills/pdf).
func ValidatedImageSkillDir(skillDir string) (string, bool) {
return ValidatedSkillDirUnder(SkillsImageRoot, skillDir)
}
@@ -246,5 +246,5 @@ func SkillInterpreterCommand(skillDir, scriptPath string) (string, []string) {
// SkillCommandPath is shared by normal skill execution and installation verification.
func SkillCommandPath(dir string) string {
return path.Join(dir, ".venv", "bin") + ":" +
path.Join(dir, "node_modules", ".bin") + ":" + path.Join(dir, ".weknora", "bin")
path.Join(dir, "node_modules", ".bin") + ":" + path.Join(dir, ".academy", "bin")
}
+12 -12
View File
@@ -12,11 +12,11 @@ import (
func TestSkillDirFor(t *testing.T) {
dir, err := SkillDirFor("sk-1")
require.NoError(t, err)
require.Equal(t, "/opt/weknora/tenant/skills/sk-1", dir)
require.Equal(t, "/opt/academy/tenant/skills/sk-1", dir)
}
func TestSkillVenvPython(t *testing.T) {
require.Equal(t, "/opt/weknora/tenant/skills/律师助手/.venv/bin/python",
require.Equal(t, "/opt/academy/tenant/skills/律师助手/.venv/bin/python",
SkillVenvPython(SkillsImageRoot+"/律师助手"))
}
@@ -93,7 +93,7 @@ func TestRunnableWorkspaceScript(t *testing.T) {
"/workspace/output",
"/workspace/input",
"/workspace/input/upload.py",
"/opt/weknora/tenant/skills/pdf/scripts/run.py",
"/opt/academy/tenant/skills/pdf/scripts/run.py",
"/etc/passwd",
"",
} {
@@ -111,7 +111,7 @@ func TestValidatedImageSkillDir(t *testing.T) {
SkillsImageRoot,
SkillsImageRoot + "/pdf/scripts",
"/workspace/output",
"/opt/weknora/tenant/skills/../skills/pdf/x",
"/opt/academy/tenant/skills/../skills/pdf/x",
"",
} {
_, ok := ValidatedImageSkillDir(p)
@@ -150,7 +150,7 @@ func TestSkillInterpreterCommand(t *testing.T) {
require.Contains(t, args[1], dir+"/.venv/bin/python",
"a skill with its own venv must not be run by the system interpreter")
require.Contains(t, args[1], "else", "there must be a fallback when the venv is absent")
require.Equal(t, "weknora-skill", args[2])
require.Equal(t, "academy-skill", args[2])
})
t.Run("javascript uses node", func(t *testing.T) {
@@ -173,7 +173,7 @@ func TestSkillInterpreterCommand(t *testing.T) {
require.Equal(t, "-c", args[0])
require.Contains(t, args[1], "exec bash "+dir+"/scripts/run.sh")
require.Contains(t, args[1], "else", "there must be a fallback when bash is absent")
require.Equal(t, "weknora-skill", args[2])
require.Equal(t, "academy-skill", args[2])
})
t.Run("a shell script receives the caller's arguments", func(t *testing.T) {
@@ -240,11 +240,11 @@ func TestIsHostSkillTarget(t *testing.T) {
}
func TestSkillDirUnderJoinsOneSegment(t *testing.T) {
dir, err := SkillDirUnder("/Users/dev/.weknora/skills", "pdf")
dir, err := SkillDirUnder("/Users/dev/.academy/skills", "pdf")
require.NoError(t, err)
require.Equal(t, "/Users/dev/.weknora/skills/pdf", dir)
require.Equal(t, "/Users/dev/.academy/skills/pdf", dir)
_, err = SkillDirUnder("/Users/dev/.weknora/skills", "../pdf")
_, err = SkillDirUnder("/Users/dev/.academy/skills", "../pdf")
require.ErrorIs(t, err, ErrInvalidSkillName)
_, err = SkillDirUnder("", "pdf")
require.Error(t, err)
@@ -255,7 +255,7 @@ func TestSkillDirUnderJoinsOneSegment(t *testing.T) {
}
func TestValidatedSkillDirUnderRejectsOtherRoots(t *testing.T) {
root := "/Users/dev/.weknora/skills/.versions"
root := "/Users/dev/.academy/skills/.versions"
got, ok := ValidatedSkillDirUnder(root, root+"/pdf-3")
require.True(t, ok)
require.Equal(t, root+"/pdf-3", got)
@@ -277,7 +277,7 @@ func TestImageSkillHelpersKeepTheImageRoot(t *testing.T) {
require.True(t, ok)
require.Equal(t, SkillsImageRoot+"/pdf", got)
require.Equal(t, SkillsImageRoot+"/pdf/.weknora/requirements.json", SkillRequirementsPath("pdf"))
require.Equal(t, "/x/pdf-1/.weknora/requirements.json", SkillRequirementsPathIn("/x/pdf-1"))
require.Equal(t, SkillsImageRoot+"/pdf/.academy/requirements.json", SkillRequirementsPath("pdf"))
require.Equal(t, "/x/pdf-1/.academy/requirements.json", SkillRequirementsPathIn("/x/pdf-1"))
require.Equal(t, "", SkillRequirementsPathIn(" "))
}
+8 -8
View File
@@ -7,12 +7,12 @@ import (
const (
// StandardTemplateName is the provider-side name of the CLI template.
StandardTemplateName = "weknora"
StandardTemplateName = "academy"
// DesktopTemplateName is the provider-side name of the desktop template.
// It is a sibling of StandardTemplateName, not a replacement: a config
// uses one or the other, decided by Config.DesktopEnabled.
DesktopTemplateName = "weknora-desktop"
DesktopTemplateName = "academy-desktop"
)
// DefaultE2BTemplateTag is the tag E2B resolves when a sandbox is created from a
@@ -59,11 +59,11 @@ type RemoteTemplateCatalog interface {
ListTemplates(ctx context.Context) ([]RemoteTemplate, error)
EnsureStandardTemplate(ctx context.Context) (*RemoteTemplate, error)
// ReplaceStandardTemplate applies the current spec to the cluster's
// WeKnora template (DNS, image). A READY template cannot pick those up
// Academy template (DNS, image). A READY template cannot pick those up
// any other way. It must not delete a usable template: callers persist
// the replacement ID first, then DeleteSupersededStandardTemplates.
ReplaceStandardTemplate(ctx context.Context) (*RemoteTemplate, error)
// DeleteSupersededStandardTemplates removes WeKnora templates other than
// DeleteSupersededStandardTemplates removes Academy templates other than
// keepID. Call only after keepID is spawnable and has been written onto
// every config that still pointed at the previous standard template.
DeleteSupersededStandardTemplates(ctx context.Context, keepID string) error
@@ -72,7 +72,7 @@ type RemoteTemplateCatalog interface {
// RemoteDesktopTemplateCatalog is the desktop sibling of RemoteTemplateCatalog.
// Cube and E2B implement it; Docker does not (SupportsDesktop stays false).
type RemoteDesktopTemplateCatalog interface {
// EnsureDesktopTemplate returns the cluster's WeKnora desktop template,
// EnsureDesktopTemplate returns the cluster's Academy desktop template,
// building it when absent.
EnsureDesktopTemplate(ctx context.Context) (*RemoteTemplate, error)
// ReplaceDesktopTemplate applies the current spec to the desktop
@@ -101,11 +101,11 @@ func isTemplateName(name, want string) bool {
return len(parts) > 1 && strings.EqualFold(parts[len(parts)-1], want)
}
// classifyWeKnoraTemplate decides whether a catalog entry is our CLI template,
// classifyAcademyTemplate decides whether a catalog entry is our CLI template,
// our desktop sibling, or neither. Name wins over image: a template aliased
// weknora-desktop is desktop even if the image repository matches the CLI
// academy-desktop is desktop even if the image repository matches the CLI
// image, and a nameless Cube template falls back to the image tag.
func classifyWeKnoraTemplate(name, image string) (standard, desktop bool) {
func classifyAcademyTemplate(name, image string) (standard, desktop bool) {
if isDesktopTemplate(name) {
return false, true
}
+14 -14
View File
@@ -3,12 +3,12 @@ package sandbox
import "testing"
func TestIsStandardTemplateRecognizesProviderScopedName(t *testing.T) {
for _, name := range []string{"weknora", "team/weknora", "project-b89e/WeKnora"} {
for _, name := range []string{"academy", "team/academy", "project-b89e/Academy"} {
if !isStandardTemplate(name) {
t.Fatalf("expected %q to identify the WeKnora standard template", name)
t.Fatalf("expected %q to identify the Academy standard template", name)
}
}
if isStandardTemplate("weknora-custom") {
if isStandardTemplate("academy-custom") {
t.Fatal("custom template must not be treated as the standard template")
}
if isStandardTemplate(DesktopTemplateName) {
@@ -17,28 +17,28 @@ func TestIsStandardTemplateRecognizesProviderScopedName(t *testing.T) {
}
func TestIsDesktopTemplateRecognizesProviderScopedName(t *testing.T) {
for _, name := range []string{"weknora-desktop", "team/weknora-desktop", "project-b89e/WeKnora-Desktop"} {
for _, name := range []string{"academy-desktop", "team/academy-desktop", "project-b89e/Academy-Desktop"} {
if !isDesktopTemplate(name) {
t.Fatalf("expected %q to identify the WeKnora desktop template", name)
t.Fatalf("expected %q to identify the Academy desktop template", name)
}
}
if isDesktopTemplate("weknora") {
if isDesktopTemplate("academy") {
t.Fatal("the CLI template must not be classified as desktop")
}
if isDesktopTemplate("weknora-desktop-custom") {
if isDesktopTemplate("academy-desktop-custom") {
t.Fatal("a similarly prefixed custom name must not be the desktop template")
}
}
func TestClassifyWeKnoraTemplatePrefersNameOverImage(t *testing.T) {
standard, desktop := classifyWeKnoraTemplate(DesktopTemplateName, DefaultDockerImage)
func TestClassifyAcademyTemplatePrefersNameOverImage(t *testing.T) {
standard, desktop := classifyAcademyTemplate(DesktopTemplateName, DefaultDockerImage)
if standard || !desktop {
t.Fatalf(
"named desktop template must be desktop even if the image repo matches CLI, got standard=%v desktop=%v",
standard, desktop,
)
}
standard, desktop = classifyWeKnoraTemplate(StandardTemplateName, DefaultDesktopDockerImage)
standard, desktop = classifyAcademyTemplate(StandardTemplateName, DefaultDesktopDockerImage)
if !standard || desktop {
t.Fatalf(
"named CLI template must stay CLI even if the image tag is desktop, got standard=%v desktop=%v",
@@ -47,16 +47,16 @@ func TestClassifyWeKnoraTemplatePrefersNameOverImage(t *testing.T) {
}
}
func TestClassifyWeKnoraTemplateNamelessImageUsesTag(t *testing.T) {
standard, desktop := classifyWeKnoraTemplate("", DefaultDockerImage)
func TestClassifyAcademyTemplateNamelessImageUsesTag(t *testing.T) {
standard, desktop := classifyAcademyTemplate("", DefaultDockerImage)
if !standard || desktop {
t.Fatalf("CLI image with no name must be standard, got standard=%v desktop=%v", standard, desktop)
}
standard, desktop = classifyWeKnoraTemplate("", DefaultDesktopDockerImage)
standard, desktop = classifyAcademyTemplate("", DefaultDesktopDockerImage)
if standard || !desktop {
t.Fatalf("desktop image with no name must be desktop, got standard=%v desktop=%v", standard, desktop)
}
standard, desktop = classifyWeKnoraTemplate("", DefaultCubeDesktopTemplateImage)
standard, desktop = classifyAcademyTemplate("", DefaultCubeDesktopTemplateImage)
if standard || !desktop {
t.Fatalf("Cube desktop image with no name must be desktop, got standard=%v desktop=%v", standard, desktop)
}
+2 -2
View File
@@ -25,7 +25,7 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// ResolveEffectiveConfig returns the Config to build a tenant's sandbox manager
@@ -310,7 +310,7 @@ func overrideSeconds(dst *time.Duration, seconds int) {
// that reaches this function without going through that merge cannot open
// the sandbox URL.
//
// A nil stored policy is not "unset": it resolves to WeKnora's default of
// A nil stored policy is not "unset": it resolves to Academy's default of
// egress allowed and inbound closed, so every downstream consumer sees one
// fully specified policy and nobody re-derives the default.
func resolveNetworkPolicy(stored *types.SandboxNetworkPolicy) RemoteNetworkPolicy {
+25 -25
View File
@@ -4,7 +4,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
@@ -492,7 +492,7 @@ func TestResolveEffectiveConfigRejectsDockerHostNetwork(t *testing.T) {
_, err := ResolveEffectiveConfig(&types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{
Image: "weknora:test",
Image: "academy:test",
NetworkMode: "host",
},
}, DefaultConfig())
@@ -508,7 +508,7 @@ func TestResolveEffectiveConfigDetectsLocalDockerHostWhenBlank(t *testing.T) {
effective, err := ResolveEffectiveConfig(&types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{Image: "weknora:test"},
Docker: &types.DockerSandboxConfig{Image: "academy:test"},
}, DefaultConfig())
require.NoError(t, err)
@@ -519,7 +519,7 @@ func TestResolveEffectiveConfigMapsDockerNoneToDeniedEgress(t *testing.T) {
effective, err := ResolveEffectiveConfig(&types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{
Image: "weknora:test",
Image: "academy:test",
NetworkMode: "none",
},
}, DefaultConfig())
@@ -533,7 +533,7 @@ func TestResolveEffectiveConfigKeepsDockerBridgeEgressOpen(t *testing.T) {
effective, err := ResolveEffectiveConfig(&types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{
Image: "weknora:test",
Image: "academy:test",
NetworkMode: "bridge",
},
}, DefaultConfig())
@@ -546,7 +546,7 @@ func TestResolveEffectiveConfigRejectsPlaintextDockerTCP(t *testing.T) {
SandboxType: "docker",
AllowPrivateEndpoints: true,
Docker: &types.DockerSandboxConfig{
Image: "weknora:test",
Image: "academy:test",
Host: "tcp://10.0.0.5:2376",
},
}, DefaultConfig())
@@ -563,7 +563,7 @@ func TestResolveEffectiveConfigRejectsResolvedPlaintextDockerTCP(t *testing.T) {
_, err := ResolveEffectiveConfig(&types.TenantSandboxConfig{
SandboxType: "docker",
AllowPrivateEndpoints: true,
Docker: &types.DockerSandboxConfig{Image: "weknora:test"},
Docker: &types.DockerSandboxConfig{Image: "academy:test"},
}, DefaultConfig())
require.Error(t, err)
}
@@ -576,8 +576,8 @@ func TestResolveEffectiveConfigRejectsResolvedPrivateDockerHostWithoutOptIn(t *t
_, err := ResolveEffectiveConfig(&types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{
Image: "weknora:test",
TLSCertPath: "/etc/weknora/docker-certs",
Image: "academy:test",
TLSCertPath: "/etc/academy/docker-certs",
},
}, DefaultConfig())
require.ErrorIs(t, err, ErrUnsafeOutboundURL)
@@ -705,7 +705,7 @@ func TestResolveEffectiveConfigUsesSkillSnapshotAsDockerImage(t *testing.T) {
base := &types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{
Image: "weknora/sandbox:base",
Image: "academy/sandbox:base",
Host: "unix:///var/run/docker.sock",
},
}
@@ -714,31 +714,31 @@ func TestResolveEffectiveConfigUsesSkillSnapshotAsDockerImage(t *testing.T) {
t.Run("usable snapshot overrides the base image", func(t *testing.T) {
cfg := *base
cfg.Docker = &types.DockerSandboxConfig{
Image: "weknora/sandbox:base", Host: "unix:///var/run/docker.sock",
Image: "academy/sandbox:base", Host: "unix:///var/run/docker.sock",
}
cfg.SkillImage = &types.SkillImageConfig{
SnapshotID: "weknora-skill/weknora-sk-cfg1-g1", OwnerFingerprint: fp,
SnapshotID: "academy-skill/academy-sk-cfg1-g1", OwnerFingerprint: fp,
}
eff, err := ResolveEffectiveConfig(&cfg, global)
require.NoError(t, err)
require.Equal(t, "weknora-skill/weknora-sk-cfg1-g1", eff.DockerImage)
require.Equal(t, "academy-skill/academy-sk-cfg1-g1", eff.DockerImage)
})
t.Run("fingerprint mismatch falls back to the base image", func(t *testing.T) {
cfg := *base
cfg.Docker = &types.DockerSandboxConfig{
Image: "weknora/sandbox:base", Host: "unix:///var/run/docker.sock",
Image: "academy/sandbox:base", Host: "unix:///var/run/docker.sock",
}
cfg.SkillImage = &types.SkillImageConfig{
SnapshotID: "weknora-skill/weknora-sk-cfg1-g1", OwnerFingerprint: "another-daemon",
SnapshotID: "academy-skill/academy-sk-cfg1-g1", OwnerFingerprint: "another-daemon",
}
eff, err := ResolveEffectiveConfig(&cfg, global)
require.NoError(t, err)
require.Equal(t, "weknora/sandbox:base", eff.DockerImage,
require.Equal(t, "academy/sandbox:base", eff.DockerImage,
"a snapshot from another daemon is invisible; the session must still boot")
})
@@ -751,12 +751,12 @@ func TestResolveEffectiveConfigUsesSkillSnapshotAsDockerImage(t *testing.T) {
newConfig := func() *types.TenantSandboxConfig {
return &types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{Image: "weknora/sandbox:base"},
Docker: &types.DockerSandboxConfig{Image: "academy/sandbox:base"},
SkillImage: &types.SkillImageConfig{
SnapshotID: "weknora-skill/weknora-sk-cfg1-g1",
SnapshotID: "academy-skill/academy-sk-cfg1-g1",
OwnerFingerprint: SkillOwnerFingerprint(&types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{Image: "weknora/sandbox:base"},
Docker: &types.DockerSandboxConfig{Image: "academy/sandbox:base"},
}),
},
}
@@ -772,7 +772,7 @@ func TestResolveEffectiveConfigUsesSkillSnapshotAsDockerImage(t *testing.T) {
eff, err := ResolveEffectiveConfig(cfg, global)
require.NoError(t, err)
require.Equal(t, "weknora-skill/weknora-sk-cfg1-g1", eff.DockerImage,
require.Equal(t, "academy-skill/academy-sk-cfg1-g1", eff.DockerImage,
"DOCKER_HOST=%s must not retire the config's skill image", host)
require.True(t, SkillImageActive(cfg))
}
@@ -783,17 +783,17 @@ func TestResolveEffectiveConfigUsesSkillSnapshotAsDockerImage(t *testing.T) {
t.Run("an explicit host change retires the image", func(t *testing.T) {
cfg := *base
cfg.Docker = &types.DockerSandboxConfig{
Image: "weknora/sandbox:base", Host: "tcp://198.51.100.10:2376",
Image: "academy/sandbox:base", Host: "tcp://198.51.100.10:2376",
TLSCertPath: "/certs",
}
cfg.SkillImage = &types.SkillImageConfig{
SnapshotID: "weknora-skill/weknora-sk-cfg1-g1", OwnerFingerprint: fp,
SnapshotID: "academy-skill/academy-sk-cfg1-g1", OwnerFingerprint: fp,
}
eff, err := ResolveEffectiveConfig(&cfg, global)
require.NoError(t, err)
require.Equal(t, "weknora/sandbox:base", eff.DockerImage)
require.Equal(t, "academy/sandbox:base", eff.DockerImage)
})
}
@@ -875,11 +875,11 @@ func TestSkillImageActiveAgreesWithTheResolvedTemplate(t *testing.T) {
config: &types.TenantSandboxConfig{
SandboxType: "docker",
Docker: &types.DockerSandboxConfig{
Image: "weknora/sandbox:base",
Image: "academy/sandbox:base",
Host: "unix:///var/run/docker.sock",
},
SkillImage: &types.SkillImageConfig{
SnapshotID: "weknora-skill/weknora-sk-cfg1-g1",
SnapshotID: "academy-skill/academy-sk-cfg1-g1",
OwnerFingerprint: SkillImageFingerprint(
"docker", "", "unix:///var/run/docker.sock",
),
+2 -2
View File
@@ -31,8 +31,8 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/sandbox/admission"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/sandbox/admission"
"academy/internal/types"
)
// ErrSandboxConfigNotFound means the referenced config is gone (deleted, or
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -80,7 +80,7 @@ type RemoteTerminalSession interface {
// Resize changes the PTY window size.
Resize(ctx context.Context, cols, rows uint32) error
// Close disconnects WeKnora from the PTY. A backend that can re-attach
// Close disconnects Academy from the PTY. A backend that can re-attach
// (Cube/E2B, via envd) leaves the remote shell running so a reconnect
// resumes it; a backend that cannot (Docker) terminates it, because the
// disconnect would otherwise strand the shell and its jobs. Safe to call
@@ -202,7 +202,7 @@ func TerminalManagerFrom(client RemoteSandboxClient) (RemoteTerminalManager, boo
}
// DefaultTerminalIdleDisconnect is how long an interactive terminal may sit
// without keystrokes or PTY output before WeKnora closes the WebSocket.
// without keystrokes or PTY output before Academy closes the WebSocket.
// Closing the socket stops TTL refresh so the sandbox can pause on its own
// provider timeout. 0 in a stored workspace config means this default.
const DefaultTerminalIdleDisconnect = 15 * time.Minute
+2 -2
View File
@@ -30,8 +30,8 @@ import (
"syscall"
"time"
"github.com/Tencent/WeKnora/internal/ipclass"
"github.com/Tencent/WeKnora/internal/utils"
"academy/internal/ipclass"
"academy/internal/utils"
)
// ErrUnsafeOutboundURL is returned for any endpoint that uses an unsupported
@@ -5,7 +5,7 @@ import (
"errors"
"testing"
"github.com/Tencent/WeKnora/internal/utils"
"academy/internal/utils"
)
func whitelistOnly(t *testing.T, whitelist, only string) {
+4 -4
View File
@@ -204,7 +204,7 @@ func TestCubeDialDesktopReachesWebsockifyPath(t *testing.T) {
t.Cleanup(cancel)
conn, err := client.DialDesktop(ctx,
&cubeRemoteHandle{sb: &cubesandbox.Sandbox{SandboxID: "sbx-9"}},
RemoteDesktopOptions{BasicAuthUser: "weknora", BasicAuthPassword: "s3cret"})
RemoteDesktopOptions{BasicAuthUser: "academy", BasicAuthPassword: "s3cret"})
require.NoError(t, err)
defer func() { _ = conn.Close() }()
@@ -213,7 +213,7 @@ func TestCubeDialDesktopReachesWebsockifyPath(t *testing.T) {
require.Equal(t, "tok-9", seen.Header.Get(InboundTokenHeader))
user, pass, ok := seen.BasicAuth()
require.True(t, ok)
require.Equal(t, "weknora", user)
require.Equal(t, "academy", user)
require.Equal(t, "s3cret", pass)
}
@@ -245,7 +245,7 @@ func TestCubeDialDesktopUsesHandleTokenWhenRegistryEmpty(t *testing.T) {
SandboxID: "sbx-9",
TrafficAccessToken: "from-handle",
}},
RemoteDesktopOptions{BasicAuthUser: "weknora", BasicAuthPassword: "s3cret"})
RemoteDesktopOptions{BasicAuthUser: "academy", BasicAuthPassword: "s3cret"})
require.NoError(t, err)
defer func() { _ = conn.Close() }()
@@ -253,6 +253,6 @@ func TestCubeDialDesktopUsesHandleTokenWhenRegistryEmpty(t *testing.T) {
"websockify dial must carry the handle's traffic token even when the registry is empty")
user, pass, ok := seen.BasicAuth()
require.True(t, ok)
require.Equal(t, "weknora", user)
require.Equal(t, "academy", user)
require.Equal(t, "s3cret", pass)
}
+3 -3
View File
@@ -18,15 +18,15 @@ const (
Root = "/workspace"
InputDir = "/workspace/input"
OutputDir = "/workspace/output"
GitDir = "/var/lib/weknora/workspace.git"
SkillsImageRoot = "/opt/weknora/tenant/skills"
GitDir = "/var/lib/academy/workspace.git"
SkillsImageRoot = "/opt/academy/tenant/skills"
TmpRoot = "/tmp"
// UserSessionsRoot holds one directory per session on a machine that
// several sessions of one owner share; UserGitRoot holds their checkpoint
// repositories, outside the work trees for the same reason GitDir is.
UserSessionsRoot = Root + "/sessions"
UserGitRoot = "/var/lib/weknora/sessions"
UserGitRoot = "/var/lib/academy/sessions"
)
// Origin says what kind of workspace a layout describes. Isolation policy
+2 -2
View File
@@ -17,7 +17,7 @@ func TestRemoteLayoutKeepsTheHistoricalContract(t *testing.T) {
require.Equal(t, "/workspace/input", l.InputDir)
require.Equal(t, "/workspace/output", l.OutputDir)
require.Equal(t, "/workspace", l.Hint)
require.Equal(t, "/var/lib/weknora/workspace.git", l.GitDir)
require.Equal(t, "/var/lib/academy/workspace.git", l.GitDir)
require.Empty(t, l.WorkDirRoots, "a session-owned machine keeps unrestricted work_dir")
require.False(t, l.IsSharedRemote())
}
@@ -39,7 +39,7 @@ func TestUserSessionLayoutUsesMachineWideWriteRoots(t *testing.T) {
"tools treat the machine like a session-owned one: the whole /workspace is writable")
require.Equal(t, []string{root + "/output", root + "/input", root, SkillsImageRoot}, l.ReadRoots)
require.Empty(t, l.WorkDirRoots, "no work_dir whitelist: any absolute directory is allowed")
require.Equal(t, "/var/lib/weknora/sessions/"+name+".git", l.GitDir)
require.Equal(t, "/var/lib/academy/sessions/"+name+".git", l.GitDir)
require.Equal(t, root, l.Hint)
}
+2 -2
View File
@@ -84,7 +84,7 @@ func TestCleanWorkDirIn(t *testing.T) {
require.Equal(t, "/opt/build", got)
_, err = CleanWorkDirIn(remote, "/opt/build", true)
require.EqualError(t, err,
`sandbox: work dir "/opt/build" is outside allowed roots (/workspace, /opt/weknora/tenant/skills)`)
`sandbox: work dir "/opt/build" is outside allowed roots (/workspace, /opt/academy/tenant/skills)`)
_, err = CleanWorkDirIn(remote, "rel", false)
require.EqualError(t, err, `sandbox: work dir "rel" must be absolute`)
@@ -95,7 +95,7 @@ func TestCleanWorkDirIn(t *testing.T) {
}
_, err = CleanWorkDirIn(shared, "/opt/build", true)
require.EqualError(t, err,
`sandbox: work dir "/opt/build" is outside allowed roots (`+shared.Root+`, /opt/weknora/tenant/skills)`)
`sandbox: work dir "/opt/build" is outside allowed roots (`+shared.Root+`, /opt/academy/tenant/skills)`)
}
func TestCleanInputPathIn(t *testing.T) {
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -1,6 +1,6 @@
package sandbox
import "github.com/Tencent/WeKnora/internal/sandbox/workspace"
import "academy/internal/sandbox/workspace"
// WorkspaceOrigin is where a workspace path is rooted. The type lives in the
// workspace subpackage; this alias keeps existing callers compiling.
+1 -1
View File
@@ -1,6 +1,6 @@
package sandbox
import "github.com/Tencent/WeKnora/internal/sandbox/workspace"
import "academy/internal/sandbox/workspace"
// ResolveWorkspacePathIn anchors a relative path at the layout root.
func ResolveWorkspacePathIn(l WorkspaceLayout, value string) string {