{
  "repo": "yuanrong-datasystem",
  "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
  "date": "2026-11-06",
  "scope": "Local pinned source inspection, not an upstream release/support claim",
  "sources": [
    {
      "id": "D01",
      "title": "已有 Go/CGO 客户端",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "go/kv/kv_client.go",
      "start": 20,
      "end": 46,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D01",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "20: /*\n21: #cgo CFLAGS: -I../include/\n22: #cgo LDFLAGS: -L../lib -ldatasystem_c\n23: #include <stdlib.h>\n24: #include <string.h>\n25: #include \"datasystem/c_api/kv_client_c_wrapper.h\"\n26: #include \"datasystem/c_api/utilC.h\"\n27: */\n28: import \"C\"\n29: \n30: import (\n31: \t\"errors\"\n32: \t\"fmt\"\n33: \t\"math\"\n34: \t\"strconv\"\n35: \t\"sync\"\n36: \t\"unsafe\"\n37: \n38: \t\"clients/common\"\n39: )\n40: \n41: // KVClient is the main handle object that allows you to make calls into the client API's.\n42: // Create it with the call to CreateClient(), and then all subsequent api calls will flow through this handle.\n43: type KVClient struct {\n44: \tclient C.KVClient_p\n45: \t// lock Protect the KVClient\n46: \tmutex *sync.RWMutex",
      "claim": "Go SDK链接libdatasystem_c，使用现有C ABI；不是从零补Go客户端。",
      "legacyChapter": 7
    },
    {
      "id": "D02",
      "title": "Go Set 的现有通路",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "go/kv/kv_client.go",
      "start": 228,
      "end": 264,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D02",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "228: // Set function sets a string of data (value) into the worker.  The data is uniquely identified by key.\n229: func (t *KVClient) Set(key string, value string, param SetParam) common.Status {\n230: \trc := checkNullPtr(t)\n231: \tif int(rc.Code) != common.Ok {\n232: \t\treturn rc\n233: \t}\n234: \tcKey := C.CString(key)\n235: \tdefer C.free(unsafe.Pointer(cKey))\n236: \tkeyLen := C.size_t(len(key))\n237: \ttype MyString struct {\n238: \t\tStr *C.char\n239: \t\tLen int\n240: \t}\n241: \tmyString := (*MyString)(unsafe.Pointer(&value))\n242: \tcValue := myString.Str\n243: \tvalueLen := C.size_t(len(value))\n244: \t// WriteMode\n245: \tcWriteMode, err := getWriteMode(param.WriteMode)\n246: \tdefer C.free(unsafe.Pointer(cWriteMode))\n247: \tif err != nil {\n248: \t\treturn common.CreateStatus(common.InvalidParam, err.Error())\n249: \t}\n250: \tcTTLSecond := C.uint(param.TTLSecond)\n251: \t// ExistenceOpt\n252: \tcExistenceOpt, err := getExistenceOpt(param.ExistenceOpt)\n253: \tdefer C.free(unsafe.Pointer(cExistenceOpt))\n254: \tif err != nil {\n255: \t\treturn common.CreateStatus(common.InvalidParam, err.Error())\n256: \t}\n257: \tt.mutex.RLock()\n258: \tdefer t.mutex.RUnlock()\n259: \tstatusC := C.SCSet(t.client, cKey, keyLen, cValue, valueLen, cWriteMode, cTTLSecond, cExistenceOpt)\n260: \tif int(statusC.code) != common.Ok {\n261: \t\treturn common.CreateStatus(int(statusC.code),\n262: \t\t\tfmt.Sprintf(\"State cache client failed to Set. msg: %s\", C.GoString(&statusC.errMsg[0])))\n263: \t}\n264: \treturn common.CreateStatus(common.Ok, \"\")",
      "claim": "Set经SCSet传二进制长度与写入参数；首版Provider可复用现有调用。",
      "legacyChapter": 7
    },
    {
      "id": "D03",
      "title": "Go Get 返回字符串",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "go/kv/kv_client.go",
      "start": 317,
      "end": 348,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D03",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "317: // Get function takes key identifier as input and fetches the string of data for that key and returns it.\n318: func (t *KVClient) Get(key string, timeoutms ...uint32) (string, common.Status) {\n319: \trc := checkNullPtr(t)\n320: \tif int(rc.Code) != common.Ok {\n321: \t\treturn \"\", rc\n322: \t}\n323: \tcKey := C.CString(key)\n324: \tdefer C.free(unsafe.Pointer(cKey))\n325: \tvar cVal *C.char = nil\n326: \tdefer func() {\n327: \t\tC.free(unsafe.Pointer(cVal))\n328: \t}()\n329: \tkeyLen := C.size_t(len(key))\n330: \tvar valLen C.size_t\n331: \tctimeoutms := C.uint(0)\n332: \tif len(timeoutms) > 0 {\n333: \t\tctimeoutms = C.uint(timeoutms[0])\n334: \t}\n335: \tt.mutex.RLock()\n336: \tdefer t.mutex.RUnlock()\n337: \tstatusC := C.SCGet(t.client, cKey, keyLen, ctimeoutms, &cVal, &valLen)\n338: \tif int(statusC.code) != common.Ok {\n339: \t\treturn \"\", common.CreateStatus(int(statusC.code),\n340: \t\t\tfmt.Sprintf(\"State cache client failed to Get. msg: %s\", C.GoString(&statusC.errMsg[0])))\n341: \t}\n342: \n343: \tif math.MaxInt32 < valLen {\n344: \t\treturn \"\", common.CreateStatus(common.InvalidParam,\n345: \t\t\tfmt.Sprintf(\"Invalid value size %d is get, which should be between (0, %d]\", valLen, math.MaxInt32))\n346: \t}\n347: \tvalue := C.GoStringN(cVal, C.int(valLen))\n348: \treturn value, common.CreateStatus(common.Ok, \"\")",
      "claim": "SCGet得到C缓冲后C.GoStringN复制成Go字符串；并非任意调用方内存GetInto。",
      "legacyChapter": 7
    },
    {
      "id": "D04",
      "title": "C Get 分配并复制",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/c_api/util.cpp",
      "start": 137,
      "end": 159,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D04",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "137: StatusC BufferToCString(datasystem::Optional<datasystem::Buffer> input,\n138:                         const std::shared_ptr<datasystem::ThreadPool> &copyThreads, char **valPointer, size_t *valLen)\n139: {\n140:     size_t destSize = input->GetSize();\n141:     *valPointer = (char *)malloc(destSize);\n142:     if (*valPointer == nullptr) {\n143:         return StatusC{ datasystem::K_RUNTIME_ERROR, \"Memory allocation failed\" };\n144:     }\n145:     // Use the SDK-internal helper so the copy still happens when the buffer was\n146:     // returned with oc_metadata_header disabled (DisabledLock — no latch frame in\n147:     // the shm layout). Explicit user calls to Buffer::RLatch() continue to fail\n148:     // with K_NOT_SUPPORTED, but internal Get-and-copy paths must not.\n149:     datasystem::Status rc = input->CopyDataWithRLatch([&] {\n150:         *valLen = input->GetSize();\n151:         return datasystem::MemoryCopy(reinterpret_cast<uint8_t *>(*valPointer), destSize,\n152:                                       static_cast<const uint8_t *>(input->ImmutableData()), *valLen, copyThreads);\n153:     });\n154:     if (rc.IsError()) {\n155:         free(*valPointer);\n156:         *valPointer = nullptr;\n157:         return ToStatusC(rc);\n158:     }\n159:     return StatusC{ datasystem::K_OK, {} };",
      "claim": "BufferToCString malloc并MemoryCopy；返回值所有权需正确释放，SDK缓冲不直接暴露给Go。",
      "legacyChapter": 7
    },
    {
      "id": "D05",
      "title": "Go批读对应C层的逐项复制",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/c_api/util.cpp",
      "start": 337,
      "end": 365,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D05",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "337: struct StatusC ExecuteGetArray(void *clientPtr, const char **cObjKeys, const size_t *cObjKeysLen, uint64_t cObjKeysNum,\n338:                                uint32_t ctimeoutms, char **cVals, size_t *valsLen, size_t *totalSize)\n339: {\n340:     std::string errorMsg;\n341:     CheckNullptr(clientPtr, \"clientPtr\", errorMsg);\n342:     CheckNullptr(cObjKeys, \"cObjKeys\", errorMsg);\n343:     CheckNullptr(cVals, \"cVals\", errorMsg);\n344:     CheckNullptr(valsLen, \"valsLen\", errorMsg);\n345:     CheckNullptr(totalSize, \"totalSize\", errorMsg);\n346:     if (!errorMsg.empty()) {\n347:         return MakeStatusC(datasystem::K_INVALID, errorMsg);\n348:     }\n349:     auto client = reinterpret_cast<std::shared_ptr<datasystem::object_cache::ObjectClientImpl> *>(clientPtr);\n350:     std::vector<std::string> objsVec = GetObjKeysVector(cObjKeys, cObjKeysLen, cObjKeysNum);\n351:     std::vector<datasystem::Optional<datasystem::Buffer>> buffers;\n352:     datasystem::Status rc = (*client)->Get(objsVec, ctimeoutms, buffers);\n353:     // Even with errors we can have partial results\n354:     // send the results back as const char\n355:     for (size_t i = 0; i < buffers.size(); ++i) {\n356:         if (buffers[i]) {\n357:             StatusC s =\n358:                 BufferToCString(std::move(buffers[i]), (*client)->GetMemoryCopyThreadPool(), &cVals[i], &valsLen[i]);\n359:             if (s.code != datasystem::K_OK) {\n360:                 LOG(ERROR) << \"Converts buffer to c style char * failed, \" << s.errMsg;\n361:             }\n362:             *totalSize += valsLen[i];\n363:         }\n364:     }\n365:     return ToStatusC(rc);",
      "claim": "GetArray的C层只处理存在的Buffer；缺失项保持空槽。转换失败仅记录日志，最终仍返回底层批读rc，不能仅凭空字符串区分missing与本地转换失败。",
      "legacyChapter": 7
    },
    {
      "id": "D06",
      "title": "Go 批删与失败清单",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "go/kv/kv_client.go",
      "start": 427,
      "end": 471,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D06",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "427: // DelArray function is similar to Del(), except that it takes an array of keys\n428: // to delete as an argument instead of a single key.\n429: func (t *KVClient) DelArray(keys []string) ([]string, common.Status) {\n430: \trc := checkNullPtr(t)\n431: \tif int(rc.Code) != common.Ok {\n432: \t\treturn nil, rc\n433: \t}\n434: \tif len(keys) == 0 {\n435: \t\treturn nil, common.CreateStatus(common.InvalidParam, \"invalid param: objectKeys is null\")\n436: \t}\n437: \n438: \t// keys golang string array to c string array\n439: \tfailedKeysC := C.MakeCharsArray(C.int(len(keys)))\n440: \tdefer C.FreeCharsArray(failedKeysC, C.int(len(keys)))\n441: \n442: \t// converting from golang to cstyle strings\n443: \tkeyArray := C.MakeCharsArray(C.int(len(keys)))\n444: \tdefer C.FreeCharsArray(keyArray, C.int(len(keys)))\n445: \n446: \tfor idx, str := range keys {\n447: \t\tcstr := C.CString(str)\n448: \t\tC.SetCharsAtIdx(keyArray, cstr, C.int(idx))\n449: \t}\n450: \n451: \tvar failedCount C.ulong\n452: \tt.mutex.RLock()\n453: \tdefer t.mutex.RUnlock()\n454: \tstatusC := C.SCDelArray(t.client, keyArray, C.ulong(len(keys)), failedKeysC, &failedCount)\n455: \n456: \tif failedCount > C.ulong(len(keys)) {\n457: \t\treturn nil, common.CreateStatus(common.UnexpectedError,\n458: \t\t\tfmt.Sprintf(\"Unexpected failed key count %d.\", failedCount))\n459: \t}\n460: \t// We can have partial results even if their is an error on a key\n461: \tfailedKeys := make([]string, failedCount)\n462: \tfor i := C.ulong(0); i < failedCount; i++ {\n463: \t\tfailedKeys[i] = C.GoString(C.GetCharsAtIdx(failedKeysC, C.int(i)))\n464: \t}\n465: \n466: \tif int(statusC.code) != common.Ok {\n467: \t\treturn failedKeys, common.CreateStatus(int(statusC.code),\n468: \t\t\tfmt.Sprintf(\"State cache client failed to Del. msg: %s\", C.GoString(&statusC.errMsg[0])))\n469: \t}\n470: \n471: \treturn failedKeys, common.CreateStatus(common.Ok, \"\")",
      "claim": "DelArray返回failedKeys，不等同按prefix/regex扫描删除。",
      "legacyChapter": 7
    },
    {
      "id": "D07",
      "title": "写参数默认、NX与范围参数",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/kv_client.h",
      "start": 48,
      "end": 72,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D07",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "48: enum class ExistenceOpt : int {\n49:     NONE = 0,  // Does not check for existence.\n50:     NX = 1,    // Set if key does not exist; if key exists, return success and keep existing value unchanged.\n51: };\n52: struct SetParam {\n53:     WriteMode writeMode = WriteMode::NONE_L2_CACHE;  // The default value of writeMode is WriteMode::NONE_L2_CACHE.\n54:     // The default value 0 means the key will keep alive until you call Del api to delete the key explicitly.\n55:     uint32_t ttlSecond = 0;\n56:     ExistenceOpt existence = ExistenceOpt::NONE;\n57:     CacheType cacheType = CacheType::MEMORY;\n58: };\n59: \n60: struct MSetParam {\n61:     WriteMode writeMode = WriteMode::NONE_L2_CACHE;  // The default value of writeMode is WriteMode::NONE_L2_CACHE.\n62:     uint32_t ttlSecond =\n63:         0;  // The default value means the key will keep alive until you call Del api to delete the key.\n64:     ExistenceOpt existence = ExistenceOpt::NONE;\n65:     CacheType cacheType = CacheType::MEMORY;\n66: };\n67: \n68: struct ReadParam {\n69:     std::string key;\n70:     uint64_t offset = 0;\n71:     uint64_t size = 0;\n72: };",
      "claim": "默认无L2、TTL0；NX命中已有key也返回成功；ReadParam有key/offset/size。",
      "legacyChapter": 7
    },
    {
      "id": "D08",
      "title": "批量写部分成功及废弃事务API",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/kv_client.h",
      "start": 212,
      "end": 236,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D08",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "212:     /// \\brief Batch setter for multiple buffers.\n213:     ///\n214:     /// This interface is used together with MCreate to cache a batch of\n215:     /// shared-memory Buffers into the data system.\n216:     ///\n217:     /// \\param[in] buffers The buffers to set.\n218:     ///\n219:     /// \\return K_OK on success; the error code otherwise.\n220:     ///         K_INVALID: buffers is empty.\n221:     ///         K_RUNTIME_ERROR: client fd mmap failed\n222:     ///         K_METADATA_OWNER_UNAVAILABLE: all objects failed and metadata publication result is unknown; do not\n223:     ///         automatically replay. Partial success returns K_OK; this overload does not report failed keys.\n224:     Status MSet(const std::vector<std::shared_ptr<Buffer>> &buffers);\n225: \n226:     /// \\brief Deprecated transactional multi-key set interface.\n227:     ///\n228:     /// This API is kept only for SDK API compatibility and always returns K_RUNTIME_ERROR.\n229:     ///\n230:     /// \\param[in] keys The keys to be set.\n231:     /// \\param[in] vals The values for the keys.\n232:     /// \\param[in] param The set parameters.\n233:     ///\n234:     /// \\return K_RUNTIME_ERROR because MSetTx is a deprecated API.\n235:     Status MSetTx(const std::vector<std::string> &keys, const std::vector<StringView> &vals,\n236:                   const MSetParam &param = {});",
      "claim": "MSet(Buffer)部分成功可返回K_OK且不返回failedKeys；MSetTx已废弃，不能做跨分片事务。",
      "legacyChapter": 7
    },
    {
      "id": "D09",
      "title": "C++ 部分读取与批次语义",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/kv_client.h",
      "start": 341,
      "end": 373,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D09",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "341:     /// \\brief Invoke worker client to get the values of all the given keys.\n342:     ///\n343:     /// \\param[in] keys The vector of the keys.\n344:     /// \\param[in] subTimeoutMs timeoutMs of waiting for the result return if object not ready. A positive integer\n345:     ///  number required. 0 means no waiting time allowed.\n346:     /// \\param[out] readOnlyBuffers The vector of the values.\n347:     ///\n348:     /// \\return K_OK on any key success; the error code otherwise.\n349:     ///         K_INVALID: the vector of keys is empty or include empty key.\n350:     ///         K_NOT_FOUND: the key not found.\n351:     ///         K_RUNTIME_ERROR: Cannot get values from worker.\n352:     /// \\verbatim\n353:     ///  If some keys are not found, The Status OK will return,\n354:     ///  and the existing keys will set the vals with the same index of keys.\n355:     /// \\endverbatim\n356:     Status Get(const std::vector<std::string> &keys, std::vector<Optional<ReadOnlyBuffer>> &readOnlyBuffers,\n357:                int32_t subTimeoutMs = 0);\n358: \n359:     /// \\brief Some data in an object can be read based on the specified key and parameters.\n360:     ///         In some scenarios, read amplification can be avoided.\n361:     ///\n362:     /// \\param[in] readParams The vector of the keys and offset.\n363:     /// \\param[out] readOnlyBuffers The vector of the values.\n364:     ///\n365:     /// \\return K_OK on any key success; the error code otherwise.\n366:     ///         K_INVALID: the vector of keys is empty or include empty key.\n367:     ///         K_NOT_FOUND: the key not found.\n368:     ///         K_RUNTIME_ERROR: Cannot get values from worker.\n369:     /// \\verbatim\n370:     ///  If some keys are not found, The Status OK will return,\n371:     ///  and the existing keys will set the vals with the same index of keys.\n372:     /// \\endverbatim\n373:     Status Read(const std::vector<ReadParam> &readParams, std::vector<Optional<ReadOnlyBuffer>> &readOnlyBuffers);",
      "claim": "Get/Read可部分成功，结果需按Optional逐项判断；Read提供指定offset/size。",
      "legacyChapter": 7
    },
    {
      "id": "D10",
      "title": "C++ QuerySize",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/kv_client.h",
      "start": 422,
      "end": 433,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D10",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "422:     /**\n423:      * @brief Invoke worker client to query the size of objectKeys.\n424:      * @param[in] objectKeys The objectKeys need to query size.\n425:      * @param[out] outSizes The size for the objectKeys in bytes.\n426:      * @return K_OK on success; the error code otherwise.\n427:      *         K_INVALID: The objectKeys are empty or invalid.\n428:      *         K_NOT_FOUND: All objectKeys not found.\n429:      *         K_RPC_UNAVAILABLE: Network error.\n430:      *         K_NOT_READY: Worker not ready.\n431:      *         K_RUNTIME_ERROR: Can not get objectKey size from worker.\n432:      */\n433:     Status QuerySize(const std::vector<std::string> &objectKeys, std::vector<uint64_t> &outSizes);",
      "claim": "QuerySize是已有C++ API，不是待研发的数据系统能力；现有Go未暴露。",
      "legacyChapter": 7
    },
    {
      "id": "D11",
      "title": "C++ Exist与Expire",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/kv_client.h",
      "start": 481,
      "end": 503,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D11",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "481:     /// \\brief Check whether the keys exist in the data system.\n482:     ///\n483:     /// \\param[in] keys The non-empty keys to be checked. Each key must have a valid object-key format, and the number\n484:     /// of keys cannot exceed 100000.\n485:     /// \\param[in] exists The existence of the corresponding key.\n486:     ///\n487:     /// \\return K_OK if at least one key is successfully processed; K_INVALID when keys are empty or contain an invalid\n488:     /// key; the error code otherwise.\n489:     Status Exist(const std::vector<std::string> &keys, std::vector<bool> &exists);\n490: \n491:     /// \\brief Sets expiration time for key list (in seconds)\n492:     ///\n493:     /// \\param[in] key The keys to set expiration for.\n494:     /// \\param[in] ttlSeconds TTL in seconds. If the value is greater than 0, the data will be deleted automatically\n495:     /// after expired. If set to 0, the data need to be manually deleted.\n496:     /// \\param[out] failedKeys The failed expire keys.\n497:     /// \\return K_OK on success; the error code otherwise.\n498:     ///         K_INVALID: The key is empty or contains invalid characters.\n499:     ///         K_NOT_FOUND: The key is not exist.\n500:     ///         K_NOT_READY: Worker is not ready.\n501:     ///         K_RPC_UNAVAILABLE: Network error.\n502:     ///         K_RUNTIME_ERROR: Inner error happen.\n503:     Status Expire(const std::vector<std::string> &keys, uint32_t ttlSeconds, std::vector<std::string> &failedKeys);",
      "claim": "Exist提供逐key布尔结果；TTL为秒，长期模板/祖先块不能随意过期。",
      "legacyChapter": 7
    },
    {
      "id": "D12",
      "title": "Key约束常量与实际正则",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/common/util/validator.h",
      "start": 42,
      "end": 69,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D12",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "42: constexpr int32_t THREAD_POOL_SIZE_LIMIT = 4096;\n43: constexpr int32_t OBJECT_KEYS_MAX_SIZE_LIMIT = 10000;\n44: constexpr int32_t EXIST_KEYS_MAX_SIZE_LIMIT = 100000;\n45: constexpr int32_t NODE_TIMEOUT_LIMIT = 1;\n46: constexpr int32_t MS_PER_SECOND = 1000;\n47: constexpr int32_t URMA_CONNECTION_LIMIT = 16384;\n48: static std::string ENCRYPT_KIT_PLAINTEXT = \"plaintext\";\n49: constexpr uint32_t MAX_KEY_LENGTH = 1024;\n50: \n51: \n52: DS_DECLARE_double(eviction_high_watermark_ratio);\n53: DS_DECLARE_double(eviction_low_watermark_ratio);\n54: DS_DECLARE_double(spill_high_watermark_ratio);\n55: DS_DECLARE_double(spill_low_watermark_ratio);\n56: \n57: using namespace datasystem;\n58: \n59: class Validator {\n60: public:\n61:     Validator() = default;\n62: \n63:     ~Validator() = default;\n64: \n65:     static const int threadMultiplier = 512;\n66:     static constexpr uint64_t MB_TO_BYTES = 1024 * 1024;  // mb to bytes;\n67:     static constexpr uint64_t MB_LIMIT = std::numeric_limits<uint64_t>::max() / MB_TO_BYTES;\n68:     inline static const std::string idFormat = \"^[a-zA-Z0-9\\\\~\\\\.\\\\-\\\\/_!@#%\\\\^\\\\&\\\\*\\\\(\\\\)\\\\+\\\\=\\\\:;]*$\";\n69:     inline static const std::string objKeyFormat = \"^[a-zA-Z0-9\\\\.\\\\-_!@#%\\\\^\\\\*\\\\(\\\\)\\\\+\\\\=\\\\:;]*$\";",
      "claim": "key最长1024字节；objKeyFormat不允许斜杠，KAS路径key需要编码。",
      "legacyChapter": 7
    },
    {
      "id": "D13",
      "title": "Key校验实际使用对象正则",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/common/util/validator.h",
      "start": 690,
      "end": 705,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D13",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "690:     /**\n691:      * @brief Check passed in string is a valid ID format. The ID format refers to\n692:      *        any IDs like objectKey, streamName, key, etc. used in the datasystem.\n693:      * @param[in] value The string to be checked.\n694:      * @return True if param is a valid ID format. Otherwise false.\n695:      */\n696:     static bool IsIdFormat(const std::string &value)\n697:     {\n698:         static const re2::RE2 re(objKeyFormat);\n699: \n700:         if (value.size() <= MAX_KEY_LENGTH && (re2::RE2::FullMatch(value, re) || value.empty())) {\n701:             return true;\n702:         }\n703:         LOG(ERROR) << value << \" is not a legal ID format, allowed format: \" << objKeyFormat;\n704:         return false;\n705:     }",
      "claim": "IsIdFormat使用objKeyFormat，不可把另一个允许斜杠的idFormat当KV key格式。",
      "legacyChapter": 7
    },
    {
      "id": "D14",
      "title": "Set/Put拒绝空Value并有请求deadline",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/client/object_cache/object_client_impl.cpp",
      "start": 2816,
      "end": 2837,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D14",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "2816: Status ObjectClientImpl::Put(const std::string &objectKey, const uint8_t *data, uint64_t size, const FullParam &param,\n2817:                              const std::unordered_set<std::string> &nestedObjectKeys, uint32_t ttlSecond, int existence,\n2818:                              int32_t requestTimeoutMs)\n2819: {\n2820:     std::shared_lock<std::shared_timed_mutex> shutdownLck(shutdownMux_);\n2821:     RETURN_IF_NOT_OK(IsClientReady());\n2822:     PerfPoint perfPoint(PerfKey::CLIENT_PUT_OBJECT);\n2823:     CHECK_FAIL_RETURN_STATUS(!objectKey.empty(), K_INVALID, \"The objectKey should not be empty.\");\n2824:     RETURN_IF_NOT_OK(CheckValidObjectKey(objectKey));\n2825:     CHECK_FAIL_RETURN_STATUS(data != nullptr, K_INVALID, \"The data pointer should not be null.\");\n2826:     CHECK_FAIL_RETURN_STATUS(size > 0, K_INVALID, \"The dataSize value should be bigger than zero.\");\n2827:     CHECK_FAIL_RETURN_STATUS(nestedObjectKeys.find(objectKey) == nestedObjectKeys.end(), K_UNKNOWN_ERROR,\n2828:                              \"Nested object references cannot be nested in a loop.\");\n2829:     RETURN_IF_NOT_OK(CheckLocalUbNodeAdmission());\n2830:     auto config = GetClientLatencyTraceConfig();\n2831:     const bool traceEnabled = ShouldCollectLatencyTrace(config);\n2832:     if (traceEnabled) {\n2833:         Trace::Instance().AddLatencyTick(LatencyTickKey::CLIENT_SET_START);\n2834:     }\n2835:     const int32_t effectiveTimeoutMs = requestTimeoutMs > 0 ? requestTimeoutMs : requestTimeoutMs_;\n2836:     ApiDeadlineGuard deadlineGuard(effectiveTimeoutMs);\n2837:     GetRequestContext()->reqTimeoutDuration.InitUs(ApiDeadline::Instance().ApiRemainingUs());",
      "claim": "Put要求非空key、非空data、size>0；合法空Blob需要适配层表示；请求timeout与连接timeout分开。",
      "legacyChapter": 7
    },
    {
      "id": "D15",
      "title": "Range实现当前仍经绑定Worker",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/client/object_cache/object_client_impl.cpp",
      "start": 3799,
      "end": 3827,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D15",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "3799: Status ObjectClientImpl::Read(const std::vector<ReadParam> &readParams, std::vector<Optional<Buffer>> &buffers)\n3800: {\n3801:     PerfPoint perfPoint(PerfKey::CLIENT_READ_OBJECT);\n3802:     RETURN_IF_NOT_OK(IsClientReady());\n3803:     CHECK_FAIL_RETURN_STATUS_PRINT_ERROR(Validator::IsBatchSizeUnderLimit(readParams.size()), K_INVALID,\n3804:                                          FormatString(\"The objectKeys size exceed %d.\", OBJECT_KEYS_MAX_SIZE_LIMIT));\n3805:     std::shared_ptr<IClientWorkerApi> workerApi;\n3806:     std::unique_ptr<Raii> raii;\n3807:     RETURN_IF_NOT_OK(GetAvailableWorkerApi(workerApi, raii));\n3808:     std::vector<std::shared_ptr<Buffer>> objectBuffers(readParams.size());\n3809:     std::vector<std::string> objectKeys;\n3810:     for (const auto &param : readParams) {\n3811:         objectKeys.emplace_back(param.key);\n3812:     }\n3813:     RETURN_IF_NOT_OK(CheckValidObjectKeyVector(objectKeys));\n3814:     ApiDeadlineGuard deadlineGuard(requestTimeoutMs_);\n3815:     GetParam getParam{ .objectKeys = objectKeys, .subTimeoutMs = 0, .readParams = readParams };\n3816:     Status rc = boundMode_->GetBuffersFromWorker(workerApi, getParam, objectBuffers);\n3817:     buffers.clear();\n3818:     for (auto &objectBuffer : objectBuffers) {\n3819:         if (objectBuffer == nullptr) {\n3820:             buffers.emplace_back();\n3821:         } else {\n3822:             buffers.emplace_back(std::move(*objectBuffer));\n3823:         }\n3824:     }\n3825:     perfPoint.Record();\n3826:     LOG(INFO) << \"Finish to Get objects \" << VectorToString(objectKeys);\n3827:     return rc;",
      "claim": "Read构造readParams并走boundMode.GetBuffersFromWorker，不可自动套用full-object direct-route结论。",
      "legacyChapter": 7
    },
    {
      "id": "D16",
      "title": "只读Buffer指针与所有权",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/kv/read_only_buffer.h",
      "start": 38,
      "end": 72,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D16",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "38:     /**\n39:      * @brief Get the data size of the buffer.\n40:      * @return The data size of the buffer.\n41:      */\n42:     int64_t GetSize() const;\n43: \n44:     /**\n45:      * @brief Get a immutable data pointer.\n46:      * @return A const void * to the data.\n47:      */\n48:     const void *ImmutableData();\n49: \n50:     /**\n51:      * @brief A Read lock is executed on the memory to protect the memory from concurrent writes (allow concurrent\n52:      * reads).\n53:      * @param[in] timeout Try-lock timeout, default value is 60 seconds.\n54:      * @return Status of the result.\n55:      */\n56:     Status RLatch(uint64_t timeout = 60 /* default is 60s */);\n57: \n58:     /**\n59:      * @brief Unlock the read latch on memory.\n60:      * @return Status of the result.\n61:      */\n62:     Status UnRLatch();\n63: \n64: private:\n65:     friend KVClient;\n66: \n67:     explicit ReadOnlyBuffer(std::shared_ptr<Buffer> &buffer)\n68:     {\n69:         buffer_ = buffer;\n70:     }\n71: \n72:     std::shared_ptr<Buffer> buffer_;",
      "claim": "ReadOnlyBuffer暴露ImmutableData/GetSize并持有shared Buffer；跨FFI需保留owner与明确release。",
      "legacyChapter": 7
    },
    {
      "id": "D17",
      "title": "Go连接Timeout不是请求预算",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/c_api/util.cpp",
      "start": 46,
      "end": 79,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D17",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "46: void ConstructConnectOptions(const int timeOut, const char *token, size_t tokenLen, const char *clientPublicKey,\n47:                              size_t cClientPublicKeyLen, const char *clientPrivateKey, size_t clientPrivateKeyLen,\n48:                              const char *serverPublicKey, size_t cServerPublicKeyLen, const char *accessKey,\n49:                              size_t cAccessKeyLen, const char *secretKey, size_t secretKeyLen, const char *tenantId,\n50:                              size_t cTenantIdLen, const char *enableCrossNodeConnection,\n51:                              datasystem::ConnectOptions &opts)\n52: {\n53:     if (timeOut > 0) {\n54:         opts.connectTimeoutMs = timeOut;\n55:     }\n56:     ExecHandlerIfParamValid(\n57:         token, [&opts, token, tokenLen]() { opts.token = datasystem::SensitiveValue(token, tokenLen); });\n58:     ExecHandlerIfParamValid(clientPublicKey, [&opts, clientPublicKey, cClientPublicKeyLen]() {\n59:         opts.clientPublicKey = std::string(clientPublicKey, cClientPublicKeyLen);\n60:     });\n61:     ExecHandlerIfParamValid(clientPrivateKey, [&opts, clientPrivateKey, clientPrivateKeyLen]() {\n62:         opts.clientPrivateKey = datasystem::SensitiveValue(clientPrivateKey, clientPrivateKeyLen);\n63:     });\n64:     ExecHandlerIfParamValid(serverPublicKey, [&opts, serverPublicKey, cServerPublicKeyLen]() {\n65:         opts.serverPublicKey = std::string(serverPublicKey, cServerPublicKeyLen);\n66:     });\n67:     ExecHandlerIfParamValid(\n68:         accessKey, [&opts, accessKey, cAccessKeyLen]() { opts.accessKey = std::string(accessKey, cAccessKeyLen); });\n69:     ExecHandlerIfParamValid(secretKey, [&opts, secretKey, secretKeyLen]() {\n70:         opts.secretKey = datasystem::SensitiveValue(secretKey, secretKeyLen);\n71:     });\n72:     ExecHandlerIfParamValid(tenantId,\n73:                             [&opts, tenantId, cTenantIdLen]() { opts.tenantId = std::string(tenantId, cTenantIdLen); });\n74: \n75:     // The default value of enableCrossNodeConnection is \"false\".\n76:     // If the value transferred from the Go is \"true\", assign a new value.\n77:     if (enableCrossNodeConnection != nullptr && strcmp(enableCrossNodeConnection, \"true\") == 0) {\n78:         opts.enableCrossNodeConnection = true;\n79:     }",
      "claim": "timeOut只赋connectTimeoutMs；不能将其表述为Go context端到端请求deadline。",
      "legacyChapter": 7
    },
    {
      "id": "D18",
      "title": "同步/异步L2写模式",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/object/object_enum.h",
      "start": 28,
      "end": 46,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D18",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "28: namespace datasystem {\n29: \n30: enum class WriteMode : int {\n31:     NONE_L2_CACHE = 0,\n32:     WRITE_THROUGH_L2_CACHE = 1,     // sync write\n33:     WRITE_BACK_L2_CACHE = 2,        // async write\n34:     NONE_L2_CACHE_EVICT = 3,        // evictable write\n35:     WRITE_BACK_L2_CACHE_EVICT = 4,  // evictable async write\n36: };\n37: \n38: enum class ConsistencyType : int {\n39:     PRAM = 0,\n40:     CAUSAL = 1,\n41: };\n42: \n43: enum class CacheType : int {\n44:     MEMORY = 0,\n45:     DISK = 1,\n46: };",
      "claim": "WRITE_THROUGH是同步L2，WRITE_BACK是异步L2；不凭枚举名承诺fsync或全系统HA。",
      "legacyChapter": 7
    },
    {
      "id": "D19",
      "title": "写穿先保存L2再设对象完成",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/worker/object_cache/service/worker_oc_service_publish_impl.cpp",
      "start": 529,
      "end": 564,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D19",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "529: Status WorkerOcServicePublishImpl::PublishObject(ObjectKV &objectKV, const PublishParams &params,\n530:                                                  std::vector<RpcMessage> &payloads)\n531: {\n532:     const auto &objectKey = objectKV.GetObjKey();\n533:     SafeObjType &safeObj = objectKV.GetObjEntry();\n534:     auto oldLifeState = safeObj->GetLifeState();\n535:     VLOG(1) << FormatString(\"Current life state: %d, next state: %d, ttl second: %u.\", (int)oldLifeState,\n536:                             (int)params.lifeState, params.ttlSecond);\n537:     // Step 1: Verify and request to master, object may be expired due to network latency.\n538:     RETURN_IF_NOT_OK(RequestingToMaster(objectKV, params));\n539: \n540:     if (!payloads.empty()) {\n541:         RETURN_IF_NOT_OK(SaveBinaryObjectToMemory(objectKV, payloads, evictionManager_, memCpyThreadPool_));\n542:     }\n543:     INJECT_POINT(\"worker.free_object_resource\", [&safeObj]() {\n544:         LOG_IF_ERROR(safeObj->FreeResources(), \"SafeObj free failed\");\n545:         return Status::OK();\n546:     });\n547:     if (safeObj->IsWriteThroughMode() && IsSupportL2Storage(supportL2Storage_)) {\n548:         LOG(INFO) << \"Save binary object to l2cache begin\";\n549:         Status res = SaveBinaryObjectToPersistence(objectKV);\n550:         if (res.IsError()) {\n551:             LOG(ERROR) << \"SaveBinaryObjectToPersistence failed. status:\" << res.ToString();\n552:             RETURN_IF_NOT_OK(RollbackPublishFailure(objectKV, oldLifeState, params.lifeState));\n553:             return res;\n554:         }\n555:     }\n556: \n557:     // Step 3: Notify GetRequest for subscription purpose.\n558:     safeObj->stateInfo.SetNeedToDelete(false);\n559:     RETURN_IF_NOT_OK(workerRequestManager_.NotifyPendingGetRequest(objectKV));\n560:     safeObj->SetLifeState(params.lifeState);\n561:     safeObj->stateInfo.SetPrimaryCopy(true);\n562:     safeObj->stateInfo.SetCacheInvalid(false);\n563:     safeObj->stateInfo.SetIncompleted(false);\n564:     if (safeObj->IsSpilled()) {",
      "claim": "WriteThrough调用SaveBinaryObjectToPersistence，失败会回滚本对象发布；其成功边界依赖具体L2实现与配置。",
      "legacyChapter": 7
    },
    {
      "id": "D20",
      "title": "Go SDK与C共享库的打包路径",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "cmake/package.cmake",
      "start": 222,
      "end": 254,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D20",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "222: ############################################################\n223: # Datasystem go header files and share libraries.\n224: ############################################################\n225: if (BUILD_GO_API)\n226:     set(DATASYSTEM_GO_INCLUDEDIR datasystem/sdk/go/include)\n227:     set(DATASYSTEM_GO_LIBPATH datasystem/sdk/go/lib)\n228:     set(DATASYSTEM_GO_PATH datasystem/sdk)\n229: \n230:     install(DIRECTORY ${CMAKE_SOURCE_DIR}/go\n231:             DESTINATION ${DATASYSTEM_GO_PATH}\n232:             FILES_MATCHING PATTERN \"*\")\n233: \n234:     install(FILES ${CMAKE_SOURCE_DIR}/src/datasystem/c_api/status_definition.h\n235:             ${CMAKE_SOURCE_DIR}/src/datasystem/c_api/kv_client_c_wrapper.h\n236:             ${CMAKE_SOURCE_DIR}/src/datasystem/c_api/stream_client_c_wrapper.h\n237:             ${CMAKE_SOURCE_DIR}/src/datasystem/c_api/object_client_c_wrapper.h\n238:             ${CMAKE_SOURCE_DIR}/src/datasystem/c_api/utilC.h\n239:             DESTINATION ${DATASYSTEM_GO_INCLUDEDIR}/datasystem/c_api)\n240: \n241:     set(common_flags_INSTALL_LIBPATH ${DATASYSTEM_GO_LIBPATH})\n242:     install_datasystem_target(common_flags)\n243: \n244:     set(etcdapi_proto_INSTALL_LIBPATH ${DATASYSTEM_GO_LIBPATH})\n245:     install_datasystem_target(etcdapi_proto)\n246: \n247:     set(rpc_option_protos_INSTALL_LIBPATH ${DATASYSTEM_GO_LIBPATH})\n248:     install_datasystem_target(rpc_option_protos)\n249: \n250:     set(datasystem_c_INSTALL_LIBPATH ${DATASYSTEM_GO_LIBPATH})\n251:     install_datasystem_target(datasystem_c)\n252: \n253:     set(datasystem_INSTALL_LIBPATH ${DATASYSTEM_GO_LIBPATH})\n254:     install_datasystem_target(datasystem)",
      "claim": "BUILD_GO_API时安装Go源码、C头与datasystem_c/libdatasystem；部署需匹配SDK/库版本。",
      "legacyChapter": 7
    },
    {
      "id": "D21",
      "title": "Range 同批拒绝重复 key 与溢出",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/client/kv_cache/kv_client.cpp",
      "start": 465,
      "end": 483,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D21",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "465: Status ValidateReadParams(const std::vector<ReadParam> &readParams, ObjectAccessRecorder &access)\n466: {\n467:     std::unordered_set<std::string> keys;\n468:     for (const auto &param : readParams) {\n469:         if (keys.find(param.key) != keys.end()) {\n470:             auto status = Status(K_INVALID, FormatString(\"The input parameter contains duplicate key %s. Keys: %s\",\n471:                                                          param.key, VectorToString(keys)));\n472:             access.Result(K_INVALID, status.GetMsg()).Record();\n473:             return status;\n474:         }\n475:         if (UINT64_MAX - param.size < param.offset) {\n476:             auto status =\n477:                 Status(K_INVALID, FormatString(\"The %s's offset: %llu + size: %llu overflow\",\n478:                                                param.key, param.offset, param.size));\n479:             access.Result(K_INVALID, status.GetMsg()).Record();\n480:             return status;\n481:         }\n482:         keys.insert(param.key);\n483:     }",
      "claim": "ReadParam 批次要求 key 唯一，且检查 offset+size 溢出；同片多个小范围必须先合并或分批，不能原样逐页放进一个批次。",
      "legacyChapter": 7
    },
    {
      "id": "D22",
      "title": "WriteBack 写入异步 L2 管理器",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/worker/object_cache/service/worker_oc_service_publish_impl.cpp",
      "start": 621,
      "end": 625,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D22",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "621:     if ((*entry)->IsWriteBackMode() && IsSupportL2Storage(supportL2Storage_)) {\n622:         LOG(INFO) << \"Asyn save binary object to l2cache\";\n623:         return asyncSendManager_->Add(objectKey, entry, future);\n624:     }\n625:     return Status::OK();",
      "claim": "WriteBack 在发布后进入 asyncSendManager；此处不同于 WriteThrough 先等待 SaveBinaryObjectToPersistence，不能把普通写回成功直接等同 L2 已完成。",
      "legacyChapter": 7
    },
    {
      "id": "D23",
      "title": "元数据恢复默认关闭并筛选可恢复模式",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/worker/object_cache/metadata_recovery_manager.cpp",
      "start": 38,
      "end": 68,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D23",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "38: DS_DEFINE_bool(enable_metadata_recovery, false, \"enable metadata recovery when worker failed\");\n39: \n40: namespace datasystem {\n41: namespace object_cache {\n42: namespace {\n43: bool IsRestartRecoverableWriteMode(uint32_t writeMode)\n44: {\n45:     auto mode = static_cast<WriteMode>(writeMode);\n46:     return mode == WriteMode::WRITE_THROUGH_L2_CACHE || mode == WriteMode::WRITE_BACK_L2_CACHE\n47:            || mode == WriteMode::WRITE_BACK_L2_CACHE_EVICT;\n48: }\n49: \n50: bool CanRecoverRestartMeta(const ObjectMetaPb &meta)\n51: {\n52:     if (meta.object_key().empty()) {\n53:         LOG(WARNING) << \"Skip restart recovery metadata with empty object key.\";\n54:         return false;\n55:     }\n56:     if (static_cast<DataFormat>(meta.config().data_format()) != DataFormat::BINARY) {\n57:         LOG(INFO) << FormatString(\"[ObjectKey %s] Skip non-binary restart recovery metadata.\", meta.object_key());\n58:         return false;\n59:     }\n60:     if (!IsRestartRecoverableWriteMode(meta.config().write_mode())) {\n61:         LOG(INFO) << FormatString(\"[ObjectKey %s] Skip non-L2 restart recovery metadata.\", meta.object_key());\n62:         return false;\n63:     }\n64:     if (static_cast<ObjectLifeState>(meta.life_state()) == ObjectLifeState::OBJECT_INVALID) {\n65:         LOG(INFO) << FormatString(\"[ObjectKey %s] Skip invalid restart recovery metadata.\", meta.object_key());\n66:         return false;\n67:     }\n68:     return true;",
      "claim": "enable_metadata_recovery 缺省 false；重启恢复元数据还要求 Binary、L2-backed 写模式、非 invalid 等条件。这是该恢复路径的条件，不代表所有配置自动 HA，也不能概括所有恢复能力都关闭。",
      "legacyChapter": 7
    },
    {
      "id": "D24",
      "title": "数据复制开关描述本地副本缓存",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/common/flags/common_flag_define.cpp",
      "start": 235,
      "end": 236,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D24",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "235: DS_DEFINE_bool(enable_data_replication, true,\n236:                \"Allow data replica cache locally; mainly for performance validation, keep enabled unless needed.\");",
      "claim": "enable_data_replication 缺省 true，声明说明为允许数据 replica cache locally；此开关不能直接当作 Provider 每次写的同步 N 副本提交承诺。",
      "legacyChapter": 7
    },
    {
      "id": "D25",
      "title": "未配置 L2 时拒绝 L2 写模式",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/worker/object_cache/service/worker_oc_service_crud_common_api.cpp",
      "start": 430,
      "end": 441,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D25",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "430: Status WorkerOcServiceCrudCommonApi::CheckIfL2CacheNeededAndWritable(const L2StorageType &supportType,\n431:                                                                      WriteMode writeMode)\n432: {\n433:     if (supportType == L2StorageType::NONE) {\n434:         bool isSetWriteL2Cache =\n435:             (writeMode == WriteMode::WRITE_THROUGH_L2_CACHE || writeMode == WriteMode::WRITE_BACK_L2_CACHE\n436:              || writeMode == WriteMode::WRITE_BACK_L2_CACHE_EVICT);\n437:         CHECK_FAIL_RETURN_STATUS_PRINT_ERROR(!isSetWriteL2Cache, K_INVALID,\n438:                                              \"The key is set to WRITE_THROUGH_L2_CACHE, WRITE_BACK_L2_CACHE or \"\n439:                                              \"WRITE_BACK_L2_CACHE_EVICT, but L2_cache_type is set to none.\");\n440:     }\n441:     return Status::OK();",
      "claim": "L2StorageType::NONE 时，WriteThrough、WriteBack、WriteBackEvict 写模式返回 K_INVALID；不能只在客户端选择 L2 模式而省略 Worker 后端配置。",
      "legacyChapter": 7
    },
    {
      "id": "D26",
      "title": "Go GetArray 部分 missing 的测试源码",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "go/kv/kv_client_test.go",
      "start": 444,
      "end": 470,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D26",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "444: func TestGetArrayFail(t *testing.T) {\n445: \tvar theClient *KVClient\n446: \tvar s common.Status\n447: \tconst TimeoutMs uint32 = 5 // Waiting 5ms for the result return if not ready.\n448: \tif theClient, s = CreateClientForTest(); theClient == nil {\n449: \t\tt.Fatalf(s.ToString())\n450: \t}\n451: \tdefer theClient.DestroyClient()\n452: \n453: \t// Set a value\n454: \tvar key2 string = \"key67789\"\n455: \tvar value2 string = \"data2\"\n456: \tvar setParam = SetParam{WriteMode: NoneL2Cache}\n457: \ts = theClient.Set(key2, value2, setParam)\n458: \tif s.IsError() {\n459: \t\tt.Fatalf(s.ToString())\n460: \t}\n461: \n462: \t// Getting multiple keys -> Key1 missing\n463: \toutputE, s := theClient.GetArray([]string{\"key12637\", \"key67789\"}, TimeoutMs)\n464: \tif s.IsError() {\n465: \t\tt.Fatalf(s.ToString())\n466: \t}\n467: \n468: \tif len(outputE[0]) != 0 || outputE[1] != value2 {\n469: \t\tt.Fatalf(\"Output Strings for GetArray Doesn't match\")\n470: \t}",
      "claim": "此测试源码期望第一个 key missing、第二个存在时批次状态不报错，结果位置分别为空字符串与 data2；说明批次 OK 不能代替逐项检查。本轮未运行该测试。",
      "legacyChapter": 7
    },
    {
      "id": "D27",
      "title": "ObjectClient已有全局引用原语",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/object_client.h",
      "start": 72,
      "end": 117,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D27",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "72:     /// \\brief Increase the global reference count to objects in the data system.\n73:     ///\n74:     /// \\param[in] objectKeys The object keys to increase, it cannot be empty. ID should not be empty and should only\n75:     ///  alphabetics (a-zA-Z), numbers and ~!@#$%^&*.-_ only. ID length should be no more than 1024.\n76:     /// \\param[out] failedObjectKeys Increase failed object keys.\n77:     /// \\param[in] remoteClientId The remote client id of the client that outside the cloud. Resolve scenarios that ELB\n78:     ///  forwards requests to different gateways, resulting in incorrect increase or decrease in reference counts, and\n79:     ///  system availability after gateway crash.\n80:     ///\n81:     /// \\return K_OK on any object success, the failedObjectKeys indicate the failed list.\n82:     ///         K_RPC_UNAVAILABLE: Disconnect from worker or master.\n83:     ///         K_INVALID: The parameter is invalid.\n84:     Status GIncreaseRef(const std::vector<std::string> &objectKeys, std::vector<std::string> &failedObjectKeys,\n85:                         const std::string &remoteClientId = \"\");\n86: \n87:     /// \\brief Decrease the global reference count to objects in the data system.\n88:     ///\n89:     /// \\param[in] objectKeys The object keys to decrease, it cannot be empty. ID should not be empty and should only\n90:     ///  alphabetics (a-zA-Z), numbers and ~!@#$%^&*.-_ only. ID length should be no more than 1024.\n91:     /// \\param[out] failedObjectKeys Decrease failed object keys.\n92:     /// \\param[in] remoteClientId The remote client id of the client that outside the cloud. Resolve scenarios that ELB\n93:     ///  forwards requests to different gateways, resulting in incorrect increase or decrease in reference counts, and\n94:     ///  system availability after gateway crash.\n95:     ///\n96:     /// \\return K_OK on any object success, the failedObjectKeys indicate the failed list.\n97:     ///         K_RPC_UNAVAILABLE: Disconnect from worker or master.\n98:     ///         K_INVALID: The parameter is invalid.\n99:     Status GDecreaseRef(const std::vector<std::string> &objectKeys, std::vector<std::string> &failedObjectKey,\n100:                         const std::string &remoteClientId = \"\");\n101: \n102:     /// \\brief Release obj Ref of remote client id when remote client that outside the cloud crash.\n103:     ///\n104:     /// \\param[in] remoteClientId The remote client id of the client that outside the cloud.\n105:     ///\n106:     /// \\return K_OK on any object success, the failedObjectKeys indicate the failed list.\n107:     ///         K_RPC_UNAVAILABLE: Disconnect from worker or master.\n108:     ///         K_INVALID: The parameter is invalid.\n109:     Status ReleaseGRefs(const std::string &remoteClientId);\n110: \n111:     /// \\brief Query all objects global references in the cluster (out-cloud reference not included).\n112:     ///\n113:     /// \\param[in] objectKey The specific object key that to query. ID should not be empty and should only contains\n114:     ///  alphabetics (a-zA-Z), numbers and ~!@#$%^&*.-_ only. ID length should be no more than 1024.\n115:     ///\n116:     /// \\return The objects' global reference num; -1 in case of failure.\n117:     int QueryGlobalRefNum(const std::string &objectKey);",
      "claim": "GIncreaseRef/GDecreaseRef/ReleaseGRefs/QueryGlobalRefNum可作为root/ancestor持有机制的复用候选，不等同已完成File版本持久GC/lease。",
      "legacyChapter": 7
    },
    {
      "id": "D28",
      "title": "ObjectClient默认PRAM",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/object_client.h",
      "start": 43,
      "end": 46,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D28",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "43: struct CreateParam {\n44:     ConsistencyType consistencyType = ConsistencyType::PRAM;\n45:     CacheType cacheType = CacheType::MEMORY;\n46: };",
      "claim": "ObjectClient CreateParam缺省PRAM；不能未经验证直接混同KV默认CAUSAL与保有策略。",
      "legacyChapter": 7
    },
    {
      "id": "D29",
      "title": "Buffer发布与嵌套依赖",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/object/buffer.h",
      "start": 71,
      "end": 88,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D29",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "71:     /// \\brief Get the data size of the buffer.\n72:     ///\n73:     /// \\return The data size of the buffer.\n74:     int64_t GetSize() const;\n75: \n76:     /// \\brief Publish mutable data to the server.\n77:     ///\n78:     /// \\param[in] nestedKeys Object key of the nested object.\n79:     ///\n80:     /// \\return Status of the result.\n81:     Status Publish(const std::unordered_set<std::string> &nestedKeys = {});\n82: \n83:     /// \\brief Publish immutable data to the server.\n84:     ///\n85:     /// \\param[in] nestedKeys Object key of the nested object.\n86:     ///\n87:     /// \\return Status of the result.\n88:     Status Seal(const std::unordered_set<std::string> &nestedKeys = {});",
      "claim": "Buffer.Publish/Seal接受nestedKeys，值得评估复用于manifest依赖；持久性和跨模式语义仍需验证。",
      "legacyChapter": 7
    },
    {
      "id": "D30",
      "title": "ObjectClient嵌套引用写接口",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "include/datasystem/object_client.h",
      "start": 133,
      "end": 144,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D30",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "133:     /// \\brief Invoke worker client to put an object (publish semantics).\n134:     ///\n135:     /// \\param[in] objectKey The ID of the object to create. ID should not be empty and should only contains english\n136:     ///  alphabetics (a-zA-Z), numbers and ~!@#$%^&*.-_ only. ID length should be no more than 1024.\n137:     /// \\param[in] data The data pointer of the user.\n138:     /// \\param[in] size The size in bytes of object.\n139:     /// \\param[in] param The create parameters.\n140:     /// \\param[in] nestedObjectKeys Objects that depend on objectKey.\n141:     ///\n142:     /// \\return K_OK on success; the error code otherwise.\n143:     Status Put(const std::string &objectKey, const uint8_t *data, uint64_t size, const CreateParam &param,\n144:                const std::unordered_set<std::string> &nestedObjectKeys = {});",
      "claim": "ObjectClient.Put有nestedObjectKeys参数；这是已有原语，不是文件版本/快照GC成品。",
      "legacyChapter": 7
    },
    {
      "id": "D31",
      "title": "L2 PersistenceApi所在层次",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/common/l2cache/persistence_api.h",
      "start": 32,
      "end": 116,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D31",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "32: class PersistenceApi {\n33: public:\n34:     virtual ~PersistenceApi() = default;\n35: \n36:     static std::unique_ptr<PersistenceApi> Create();\n37: \n38:     static std::shared_ptr<PersistenceApi> CreateShared();\n39: \n40:     /**\n41:      * @brief init the PersistenceApi\n42:      * @return execute result\n43:      */\n44:     virtual Status Init() = 0;\n45: \n46:     /**\n47:      * @brief save the object to 3rd storage, for example obs\n48:      * @param[in] objectKey the object namespace in datastystem. i.e. <tenantId>/<objectKey>\n49:      * @param[in] version the version of the object\n50:      * @param[in] timeoutMs the connect and request timeout in million second\n51:      * @param[in] body the content of the object\n52:      * @param[in] asyncElapse The time this object being in the async queue\n53:      * @return execute result\n54:      */\n55:     virtual Status Save(const std::string &objectKey, uint64_t version, int64_t timeoutMs,\n56:                         const std::shared_ptr<std::iostream> &body, uint64_t asyncElapse = 0,\n57:                         WriteMode writeMode = WriteMode::NONE_L2_CACHE, uint32_t ttlSecond = 0) = 0;\n58: \n59:     /**\n60:      * @brief get the persistence object with the given version.\n61:      * if the given version is not exist, return the max version exist in persistence.\n62:      *\n63:      * @param[in] objectKey the object key:<TenantId>/<ObjectKey>\n64:      * @param[in] version the object meta version\n65:      * @param[in] timeoutMs the connect and request timeout in million second\n66:      * @param[out] content the string stream byte of the object\n67:      * @return Status of call\n68:      */\n69:     virtual Status Get(const std::string &objectKey, uint64_t version, int64_t timeoutMs,\n70:                        std::shared_ptr<std::stringstream> &content) = 0;\n71: \n72:     /**\n73:      * @brief get the persistence object without any given version.\n74:      * @param[in] objectKey the object key:<TenantId>/<ObjectKey>\n75:      * @param[in] timeoutMs the connect and request timeout in million second\n76:      * @param[in] minVersion the min version for object.\n77:      * @param[out] content the string stream byte of the object\n78:      * @return Status of call\n79:      */\n80:     virtual Status GetWithoutVersion(const std::string &objectKey, int64_t timeoutMs, uint64_t minVersion,\n81:                                      std::shared_ptr<std::stringstream> &content) = 0;\n82: \n83:     /**\n84:      * @brief delete all the satisfied version of the object\n85:      * satisfied version means: version <= maxVerToDelete.\n86:      *\n87:      * two scenarios:\n88:      * 1) deleteAllVersion=false indicate datasystem don't delete the object, but only clear the old version of the\n89:      * object, in this scenarios, invoker need to know that:\n90:      * if existMaxVersion(the max version exist persistence) <= maxVerToDelete, we must not delete the existMaxVersion,\n91:      * the purpose is that we need keep a version of object in cloud storage, finally we will delete the version\n92:      * satisfied: version <= existMaxVersion - 1\n93:      *\n94:      * 2) deleteAllVersion=true, datasystem delete the object, it means clear all the version of the object,\n95:      * in this scenarios, invoker need to know that:\n96:      * if the maxVerToDelete is not found in persistence(i.e. maybe the maxVerToDelete version is in upload process),\n97:      * we do not consider the deletion is complete, even though all other version success to delete.\n98:      *\n99:      * @param[in] objectKey the object path in persistence\n100:      * @param[in] maxVerToDelete the max version can be delete\n101:      * @param[in] deleteAllVersion true if the datasystem delete the object, otherwise false\n102:      * @param[in] asyncElapse The time this object being in the async queue\n103:      * @param[in] objectVersion The object version.\n104:      * @param[in] listIncompleteVersions whether to list those incomplete versions. Usually they are partially uploaded.\n105:      * @return Status of call\n106:      */\n107:     virtual Status Del(const std::string &objectKey, uint64_t maxVerToDelete, bool deleteAllVersion,\n108:                        uint64_t asyncElapse = 0, const uint64_t *const objectVersion = nullptr,\n109:                        bool listIncompleteVersions = false) = 0;\n110: \n111:     virtual Status PreloadSlot(const std::string &sourceWorkerAddress, uint32_t slotId,\n112:                                const SlotPreloadCallback &callback = SlotPreloadCallback{}) = 0;\n113: \n114:     virtual Status MergeSlot(const std::string &sourceWorkerAddress, uint32_t slotId) = 0;\n115: \n116:     virtual Status CleanupLocalSlots() = 0;",
      "claim": "PersistenceApi处理单对象L2保存/版本/删除和slot维护；拟议File跨KV布局与extent映射应在上层SDK，不直接塞入L2接口。",
      "legacyChapter": 7
    },
    {
      "id": "D32",
      "title": "C ABI共享库构建入口",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "path": "src/datasystem/c_api/CMakeLists.txt",
      "start": 1,
      "end": 12,
      "kind": "code",
      "chapter": 6,
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D32",
      "sourceType": "pinned-local-git-blob",
      "excerpt": "1: file(GLOB CLIENT_C_API_SRC ./*.cpp)\n2: set(CLIENT_C_DEPEND_LIBS\n3:         datasystem_static\n4:         ds_spdlog::spdlog\n5:         CURL::libcurl)\n6: \n7: add_library(datasystem_c SHARED ${CLIENT_C_API_SRC})\n8: target_link_libraries(datasystem_c PRIVATE \"${CLIENT_C_DEPEND_LIBS}\")\n9: \n10: # just for ut\n11: add_library(datasystem_c_static STATIC ${CLIENT_C_API_SRC})\n12: target_link_libraries(datasystem_c_static PRIVATE \"${CLIENT_C_DEPEND_LIBS}\")",
      "claim": "现有C API生成datasystem_c；新增File opaque handle需纳入构建、包装及SDK打包，尚未实施。",
      "legacyChapter": 7
    },
    {
      "id": "D33",
      "title": "ObjectClient Put 的默认写入路径",
      "repo": "yuanrong-datasystem",
      "commit": "c0bbb1582e49ecc2d2d925836d1288633d322012",
      "chapter": 6,
      "path": "src/datasystem/client/object_cache/object_client.cpp",
      "start": 135,
      "end": 145,
      "kind": "code",
      "sourceType": "pinned-local-git-blob",
      "url": "kasandbox-architecture-20261106/datasystem-source-evidence.json#D33",
      "excerpt": "135: Status ObjectClient::Put(const std::string &objectKey, const uint8_t *data, uint64_t size, const CreateParam &param,\n136:                          const std::unordered_set<std::string> &nestedObjectKeys)\n137: {\n138:     TraceGuard traceGuard = Trace::Instance().SetRequestTraceUUID();\n139:     object_cache::FullParam innerParam;\n140:     innerParam.writeMode = WriteMode::NONE_L2_CACHE;\n141:     innerParam.consistencyType = param.consistencyType;\n142:     innerParam.cacheType = param.cacheType;\n143:     auto access = AccessRecorder::Object(AccessRecorderKey::DS_OBJECT_CLIENT_PUT);\n144:     Status rc = impl_->Put(objectKey, data, size, innerParam, nestedObjectKeys);\n145:     access.ObjectKeyRef(objectKey).WriteMode(static_cast<int>(innerParam.writeMode))",
      "claim": "ObjectClient::Put 将 writeMode 设为 NONE_L2_CACHE；不能直接换API就继承原KV所选持久化策略。",
      "legacyChapter": 7
    }
  ]
}
