Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_library(highbar_command_queue_test_support STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/CommandQueue.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/LiveControlState.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/Counters.cpp")
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/Counters.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/StockQueueReader.cpp")
# The tactical helper lands in the native implementation lane. Keep this
# contract checkpoint independently buildable while registering the helper
# as soon as the coherent join supplies it.
Expand Down Expand Up @@ -107,6 +108,17 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_test(NAME tactical_native_state_test COMMAND tactical_native_state_test)
endif ()

if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/stock_queue_reader_test.cc")
add_executable(stock_queue_reader_test
"${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/stock_queue_reader_test.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/StockQueueReader.cpp")
target_include_directories(stock_queue_reader_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit")
target_link_libraries(stock_queue_reader_test PRIVATE
GTest::gtest GTest::gtest_main)
add_test(NAME stock_queue_reader_test COMMAND stock_queue_reader_test)
endif ()

if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/tactical_feature_capacity_test.cc")
add_executable(tactical_feature_capacity_test
"${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/tactical_feature_capacity_test.cc")
Expand Down Expand Up @@ -162,6 +174,13 @@ endif ()

set(CMAKE_CXX_STANDARD 20)

option(HIGHBAR_STOCK_RECOIL
"Build the stock Recoil 2025.06.19 tactical profile without appended callbacks" OFF)
if (HIGHBAR_STOCK_RECOIL AND HIGHBAR_FACTORY_REPLACEMENT_V1)
message(FATAL_ERROR
"HIGHBAR_STOCK_RECOIL cannot be combined with the custom factory replacement extension")
endif ()

set(mySourceDirRel "src/") # Common values are "" or "src"
set(additionalSources ${CMAKE_SOURCE_DIR}/rts/System/StringUtil.cpp)
set(additionalSources ${additionalSources} ${CMAKE_SOURCE_DIR}/rts/System/Misc/SpringTime.cpp)
Expand All @@ -186,6 +205,10 @@ else (CIRCUIT_DEBUG)
set(additionalCompileFlags "-Wall")
# set(additionalCompileFlags "-Wall -fno-omit-frame-pointer -O1")
endif (CIRCUIT_DEBUG)
if (HIGHBAR_STOCK_RECOIL)
set(additionalCompileFlags
"${additionalCompileFlags} -DHIGHBAR_STOCK_RECOIL=1")
endif ()

# set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libgcc -static-libstdc++ -lasan")

Expand Down Expand Up @@ -307,6 +330,11 @@ if (BUILD_Cpp_AIWRAPPER)
set(HIGHBAR_ENGINE_RELEASE_ID "${CMAKE_MATCH_1}")
string(REGEX MATCH "sha256[ \t]*=[ \t]*\"([^\"]+)\"" _ "${_highbar_pin_content}")
set(HIGHBAR_ENGINE_SHA256 "${CMAKE_MATCH_1}")
if (HIGHBAR_STOCK_RECOIL)
set(HIGHBAR_ENGINE_RELEASE_ID "2025.06.19")
set(HIGHBAR_ENGINE_SHA256
"e4f63c1a391f9ddfbb4d1da225d9533b1d56c65133687d036422a7380c84e833")
endif ()
if (NOT HIGHBAR_ENGINE_RELEASE_ID OR NOT HIGHBAR_ENGINE_SHA256)
message(FATAL_ERROR
"HighBarV3: failed to parse release_id/sha256 from ${HIGHBAR_PIN_FILE}")
Expand Down Expand Up @@ -362,7 +390,8 @@ constexpr const char* kEngineSha256 = "@HIGHBAR_ENGINE_SHA256@";
add_library(highbar_command_queue_test_support STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/CommandQueue.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/LiveControlState.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/Counters.cpp")
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/Counters.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/StockQueueReader.cpp")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/TacticalNativeState.cpp")
target_sources(highbar_command_queue_test_support PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src/circuit/grpc/TacticalNativeState.cpp")
Expand Down Expand Up @@ -454,6 +483,7 @@ constexpr const char* kEngineSha256 = "@HIGHBAR_ENGINE_SHA256@";
OR _test_name STREQUAL "coordinator_command_admission_test"
OR _test_name STREQUAL "live_control_state_test"
OR _test_name STREQUAL "tactical_native_state_test"
OR _test_name STREQUAL "stock_queue_reader_test"
OR _test_name STREQUAL "tactical_feature_capacity_test")
target_link_libraries("${_test_name}" PRIVATE
highbar_command_queue_test_support)
Expand Down
202 changes: 202 additions & 0 deletions contracts/barc-stock-queue-v1/contract.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
{
"schema": "barc.stock-queue-contract/1",
"owner": "FS-GG/HighBarV3",
"consumer": "FS-GG/FSBarV2",
"stockEngine": {
"sourceCommit": "2639eedac7d1fd67d793ec93ebd27f014f336a14",
"headlessSha256": "e4f63c1a391f9ddfbb4d1da225d9533b1d56c65133687d036422a7380c84e833",
"release": "2025.06.19"
},
"profiles": {
"legacy": {
"name": "barc-live-tactical-v1",
"revision": 1,
"acceptedEvidenceSchemeNumbers": [
0,
1
],
"defaultZeroMeaning": "full-native-tuple-v1"
},
"stock": {
"name": "barc-live-tactical-stock-v1",
"revision": 2,
"requiredEvidenceSchemeNumber": 2
}
},
"evidenceSchemes": {
"unspecified": 0,
"fullNativeTupleV1": 1,
"stockLuaSupportedFieldsV1": 2
},
"stockFields": [
"domain",
"id",
"options.coded",
"tag",
"float32params"
],
"unavailableFields": [
"timeout"
],
"catalogueBinding": [
"profile",
"revision",
"catalogueId",
"catalogueRevision",
"engineVersion",
"gameName",
"gameVersion",
"gameContentSha256"
],
"revisionBinding": [
"evidenceScheme",
"profile",
"revision",
"catalogueBinding",
"actorId",
"actorLifetime",
"queueDomain",
"completeOrderedRows"
],
"revisionAlgorithm": {
"name": "barc-stock-queue-revision-sha256-u64be-v1",
"preimageMagic": "UTF-8 bytes barc-stock-queue-revision/1 followed by one NUL byte",
"fieldEncoding": "ordered fields: one-byte tag, four-byte unsigned big-endian byte length, then raw value bytes; repeated row tag 14 preserves row order; the preimage is binary and has no terminator",
"stringEncoding": "strict UTF-8; lengths count encoded bytes",
"scalarEncoding": "evidence scheme, tactical revision, actor id and row count are unsigned 32-bit big-endian raw values; catalogue revision and actor lifetime are unsigned 64-bit big-endian raw values",
"byteEncoding": "catalogue id and game content SHA-256 are raw bytes, not hex text",
"rowEncoding": "tag 14 contains the canonical ASCII bridge row payload after row= and before newline; domain,id,options.coded,tag,float32params; no timeout",
"orderedTags": [
{
"tag": 1,
"field": "evidenceScheme"
},
{
"tag": 2,
"field": "profile"
},
{
"tag": 3,
"field": "revision"
},
{
"tag": 4,
"field": "catalogueId"
},
{
"tag": 5,
"field": "catalogueRevision"
},
{
"tag": 6,
"field": "engineVersion"
},
{
"tag": 7,
"field": "gameName"
},
{
"tag": 8,
"field": "gameVersion"
},
{
"tag": 9,
"field": "gameContentSha256"
},
{
"tag": 10,
"field": "actorId"
},
{
"tag": 11,
"field": "actorLifetime"
},
{
"tag": 12,
"field": "domain"
},
{
"tag": 13,
"field": "rowCount"
},
{
"tag": 14,
"field": "orderedRow",
"repeated": true
}
],
"fixedValues": {
"evidenceScheme": 2,
"profile": "barc-live-tactical-stock-v1",
"revision": 2
},
"domainValues": [
"actor-order",
"production",
"rally"
],
"validation": "all fixed values must match; actor id is any uint32 including zero; catalogue revision and actor lifetime are nonzero; catalogue id and content SHA-256 are exact bound bytes; every row domain equals the envelope domain; unavailable/incomplete observations mint no revision",
"projection": "SHA-256 over the complete binary preimage; first eight digest bytes interpreted as unsigned big-endian uint64",
"zeroRule": "if the projected uint64 is zero, use one"
},
"factoryProductionPolicies": {
"append": "supported",
"rejectIfBusy": "supported only for an observed empty production queue",
"replace": "unsupported including empty queue; refuse without append fallback"
},
"bridge": {
"id": "barc-stock-queue-reader-v1",
"requestMagic": "BARC_QUEUE_REQUEST/1",
"responseMagic": "BARC_QUEUE_RESPONSE/1",
"encoding": "7-bit ASCII without NUL",
"length": "eight decimal digits equal total bytes including terminal newline",
"terminal": "end\\n",
"requestFields": [
"bridge",
"domain",
"unit"
],
"responseFields": [
"bridge",
"request-sha256",
"status",
"domain",
"unit",
"reason only when unavailable",
"count",
"ordered row records only when ok"
],
"rowGrammar": "row=<domain>|<signed int32 id>|<uint16 options.coded>|<signed int32 tag>|<comma-separated lowercase float32 bit hex>",
"float32": "exactly eight lowercase IEEE-754 binary32 hex digits; finite only; 80000000 is negative zero and must round-trip or the bridge refuses the value",
"limits": {
"maxInputBytes": 8192,
"maxResponseBytes": 8192,
"maxEntries": 64,
"overflowProbeEntries": 65,
"maxParamsPerEntry": 16,
"maxTotalParams": 256,
"maxLineBytes": 512
},
"domains": [
"production",
"rally"
],
"statuses": [
"ok",
"unavailable"
],
"unavailableReasons": [
"missing-bridge",
"wrong-version",
"wrong-team",
"not-factory",
"unsupported-domain",
"malformed",
"overflow",
"nonfinite-float",
"negative-zero-unsupported",
"oversize"
]
},
"vectorsFile": "vectors.json"
}
58 changes: 58 additions & 0 deletions contracts/barc-stock-queue-v1/vectors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"schema": "barc.stock-queue-bridge-vectors/1",
"requestSha256": "b01b44c1eaea587730eae794c0b87e4e05dddecfb508abd295ac1e138a0f5960",
"vectors": [
{
"name": "production-request",
"kind": "request",
"ascii": "BARC_QUEUE_REQUEST/1\nlength=00000101\nbridge=barc-stock-queue-reader-v1\ndomain=production\nunit=42\nend\n",
"byteLength": 101,
"sha256": "b01b44c1eaea587730eae794c0b87e4e05dddecfb508abd295ac1e138a0f5960"
},
{
"name": "empty-production",
"kind": "response",
"ascii": "BARC_QUEUE_RESPONSE/1\nlength=00000200\nbridge=barc-stock-queue-reader-v1\nrequest-sha256=b01b44c1eaea587730eae794c0b87e4e05dddecfb508abd295ac1e138a0f5960\nstatus=ok\ndomain=production\nunit=42\ncount=0\nend\n",
"byteLength": 200,
"sha256": "996539730370dcee4240a0d66c24a94fd9cda77ef5fea3aff07eed90cb7409bb"
},
{
"name": "one-production-with-negative-zero",
"kind": "response",
"ascii": "BARC_QUEUE_RESPONSE/1\nlength=00000244\nbridge=barc-stock-queue-reader-v1\nrequest-sha256=b01b44c1eaea587730eae794c0b87e4e05dddecfb508abd295ac1e138a0f5960\nstatus=ok\ndomain=production\nunit=42\ncount=1\nrow=production|-710|32|41|3f800000,80000000\nend\n",
"byteLength": 244,
"sha256": "b9294f24faaad63777f99c44dd6201dabf41ec32772b862d657698d3c5d32ec5"
},
{
"name": "wrong-team-unavailable",
"kind": "response",
"ascii": "BARC_QUEUE_RESPONSE/1\nlength=00000227\nbridge=barc-stock-queue-reader-v1\nrequest-sha256=b01b44c1eaea587730eae794c0b87e4e05dddecfb508abd295ac1e138a0f5960\nstatus=unavailable\ndomain=production\nunit=42\nreason=wrong-team\ncount=0\nend\n",
"byteLength": 227,
"sha256": "63861e8f1682fbd8e8551a24a4c39d1217a8b98e269bd44aceaf266c144acb6e"
}
],
"revisionVector": {
"name": "one-production-bound-revision",
"context": {
"evidenceScheme": 2,
"profile": "barc-live-tactical-stock-v1",
"revision": 2,
"catalogueIdHex": "000102030405060708090a0b0c0d0e0f",
"catalogueRevision": "9007199254741107",
"engineVersion": "2025.06.19",
"gameName": "BAR",
"gameVersion": "test-29926-0571aa8",
"gameContentSha256Hex": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"actorId": 42,
"actorLifetime": "9007199254741105",
"domain": "production",
"rows": [
"production|-710|32|41|3f800000,80000000"
]
},
"preimageByteLength": 285,
"preimageHex": "626172632d73746f636b2d71756575652d7265766973696f6e2f3100010000000400000002020000001b626172632d6c6976652d746163746963616c2d73746f636b2d76310300000004000000020400000010000102030405060708090a0b0c0d0e0f05000000080020000000000073060000000a323032352e30362e313907000000034241520800000012746573742d32393932362d303537316161380900000020000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f0a000000040000002a0b0000000800200000000000710c0000000a70726f64756374696f6e0d00000004000000010e0000002770726f64756374696f6e7c2d3731307c33327c34317c33663830303030302c3830303030303030",
"sha256": "fbd1b79418f394d4e8a8e847c155d43c65e071b76375f9682266453933302c37",
"projectedUint64": "18145486220354098388"
}
}
17 changes: 17 additions & 0 deletions data/barc-stock-observer/CONTENT-METADATA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"schema": "barc.stock-observer-content/1",
"bridge": "barc-stock-queue-reader-v1",
"profile": "barc-live-tactical-stock-v1",
"revision": 3,
"evidenceScheme": "STOCK_LUA_SUPPORTED_FIELDS_V1",
"baseGameDependency": "Beyond All Reason test-29926-0571aa8",
"baseGameRelease": "2025.06.19",
"baseGameHeadlessSha256": "e4f63c1a391f9ddfbb4d1da225d9533b1d56c65133687d036422a7380c84e833",
"stockEngineSourceCommit": "2639eedac7d1fd67d793ec93ebd27f014f336a14",
"stockCompatibility": {
"actorMinimum": 0,
"floatEncoding": "SYNCED_VFS_PACKF32_BYTES",
"requestDigest": "SHA256_BYTE_LIMBS",
"syncedGlobals": "NO_RAW_ACCESS"
}
}
Loading
Loading