diff --git a/.opencode/agents/cmake-expert.md b/.opencode/agents/cmake-expert.md index 211f104..e93cecc 100644 --- a/.opencode/agents/cmake-expert.md +++ b/.opencode/agents/cmake-expert.md @@ -27,16 +27,19 @@ FetchContent_Declare(xxhash GIT_REPOSITORY https://github.com/Cyan4973/xxHash GI FetchContent_MakeAvailable(xxhash) # Sanitizer option -set(SANITIZER "none" CACHE STRING "Sanitizer to enable (address, thread, none)") -set_property(CACHE SANITIZER PROPERTY STRINGS address thread none) +set(SANITIZER "none" CACHE STRING "Sanitizer to enable (address, thread, undefined, none)") +set_property(CACHE SANITIZER PROPERTY STRINGS address thread undefined none) if(SANITIZER STREQUAL "address") add_compile_options(-fsanitize=address -fno-omit-frame-pointer -g) add_link_options(-fsanitize=address) elseif(SANITIZER STREQUAL "thread") add_compile_options(-fsanitize=thread -fno-omit-frame-pointer -g) add_link_options(-fsanitize=thread) +elseif(SANITIZER STREQUAL "undefined") + add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer -g) + add_link_options(-fsanitize=undefined) elseif(NOT SANITIZER STREQUAL "none") - message(FATAL_ERROR "Unknown sanitizer: ${SANITIZER}. Supported values: address, thread, none") + message(FATAL_ERROR "Unknown sanitizer: ${SANITIZER}. Supported values: address, thread, undefined, none") endif() option(STRICT_WARNINGS "Enable strict warnings" OFF) @@ -94,7 +97,7 @@ tests/integration/ — Python pytest integration tests - Use `file(GLOB ...)` for source collection (existing pattern). - All targets link `Threads::Threads`, `${ZSTD_LIBRARY}`, `OpenSSL::SSL`, `OpenSSL::Crypto`, and `xxhash`. - Include directories: `src/shared`, `src/server`, `src/client`, `tests` (for test target). -- Sanitizer support: pass `-DSANITIZER=address` or `-DSANITIZER=thread` to cmake (live option in CMakeLists.txt). +- Sanitizer support: pass `-DSANITIZER=address`, `-DSANITIZER=thread`, or `-DSANITIZER=undefined` to cmake (live option in CMakeLists.txt). - Build with `cmake -B build -S . && cmake --build build -j$(nproc)`. - For CI, dependencies are provided by the project's custom Docker image (repo-root `Dockerfile`, same image CI uses). For local development, use `nix-shell`. Never add `apt-get install` / `pip install` to CI workflows. See `AGENTS.md`. @@ -105,7 +108,7 @@ tests/integration/ — Python pytest integration tests 3. Add new dependencies with `find_package` or `find_library`. 4. When adding a new executable target, follow the pattern of existing targets. 5. When adding a new library (static/shared), use `add_library` and follow the project's naming. -6. For sanitizer builds, pass `-DSANITIZER=address` or `-DSANITIZER=thread` to cmake (matching CI's matrix strategy). +6. For sanitizer builds, pass `-DSANITIZER=address`, `-DSANITIZER=thread`, or `-DSANITIZER=undefined` to cmake (matching CI's matrix strategy). 7. Always verify the build compiles after changes. ## Sanitizer Configurations @@ -119,11 +122,9 @@ cmake -B build -S . -DSANITIZER=thread # ThreadSanitizer (race conditions) cmake --build build -j$(nproc) ``` -For UndefinedBehaviorSanitizer (no `-DSANITIZER=undefined` option in CMakeLists.txt yet), use the manual flag approach: +UndefinedBehaviorSanitizer uses the same built-in option: ```bash -cmake -B build -S . \ - -DCMAKE_C_FLAGS="-fsanitize=undefined -fno-omit-frame-pointer -g" \ - -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=undefined" +cmake -B build -S . -DSANITIZER=undefined cmake --build build -j$(nproc) ``` diff --git a/.opencode/agents/integrator.md b/.opencode/agents/integrator.md index 567729e..47d9afb 100644 --- a/.opencode/agents/integrator.md +++ b/.opencode/agents/integrator.md @@ -21,7 +21,7 @@ Design integration tests that verify the full transfer pipeline works end-to-end - Multiple configurations (TCP, SSH, TLS, compression, multithreading) - Network shaping (LAN, WAN profiles) - Feature tests (dry run, archive, exclude, delete, incremental, bandwidth limit) -- Run: `python3 -m pytest tests/ -v --tb=short` +- Run: `python3 -m pytest tests/integration/ -n 4 --dist=load -m "not setpriv"` ### 3. New: Focused Integration Tests When adding new features or fixing bugs, write targeted integration tests. @@ -77,7 +77,7 @@ openssl req -x509 -newkey rsa:2048 -keyout /tmp/key.pem -out /tmp/cert.pem \ ### Pattern 4: Incremental Sync ```bash # First sync -./build/client --source-dir /tmp/src --dest-dir /tmp/dst --save-to-disk -M +./build/client --source-dir /tmp/src --dest-dir /tmp/dst --save-to-disk # Modify source echo "updated" >> /tmp/src/file.txt @@ -90,14 +90,14 @@ echo "updated" >> /tmp/src/file.txt ### Pattern 5: Delete Verification ```bash # Initial sync -./build/client --source-dir /tmp/src --dest-dir /tmp/dst --save-to-disk -M +./build/client --source-dir /tmp/src --dest-dir /tmp/dst --save-to-disk # Add extra file to dest echo "extra" > /tmp/dst/.../extra.txt # Sync with --delete ./build/client --source-dir /tmp/src --dest-dir /tmp/dst \ - --save-to-disk --delete -M + --save-to-disk --delete # Verify extra.txt is gone test ! -f /tmp/dst/.../extra.txt @@ -116,7 +116,7 @@ The project uses Gitea Actions. Key jobs: jobs: new-job: runs-on: ubuntu-latest - container: gitea.tap-tap.win/taptap/fastsync-ci:v7 + container: gitea.tap-tap.win/taptap/fastsync-ci:v10 steps: - uses: actions/checkout@v4 - name: Configure @@ -128,7 +128,7 @@ jobs: - name: Unit Tests run: ./build-${{ matrix.sanitizer }}/tests - name: Integration Tests - run: LSAN_OPTIONS=suppressions=.lsan-suppressions.txt python3 -m pytest tests/ -v --tb=short + run: LSAN_OPTIONS=suppressions=.lsan-suppressions.txt python3 -m pytest tests/integration/ -n 4 --dist=load -m "not setpriv" ``` The symlink step is required because `tests/conftest.py` expects `./build` to exist. @@ -136,7 +136,7 @@ The symlink step is required because `tests/conftest.py` expects `./build` to ex After any code change: - [ ] Unit tests pass: `./build/tests` -- [ ] Integration tests pass: `python3 -m pytest tests/ -v --tb=short` +- [ ] Integration tests pass: `python3 -m pytest tests/integration/ -n 4 --dist=load -m "not setpriv"` - [ ] Build clean: no warnings with `-Wall` - [ ] No memory errors: ASan clean - [ ] No thread errors: TSan clean (if threading involved) diff --git a/.opencode/agents/test-writer.md b/.opencode/agents/test-writer.md index 9d15d8c..3f24055 100644 --- a/.opencode/agents/test-writer.md +++ b/.opencode/agents/test-writer.md @@ -138,11 +138,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { Build for fuzzing: ```bash -cmake -B build-fuzz -S . \ - -DCMAKE_C_FLAGS="-fsanitize=fuzzer,address,undefined -g" \ - -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=fuzzer,address,undefined" +CC=clang CXX=clang++ cmake -B build-fuzz -S . -DENABLE_FUZZ=ON cmake --build build-fuzz -j$(nproc) -./build-fuzz/tests/fuzz_chunk_deserialize corpus/ -max_len=1048576 +./build-fuzz/fuzz_chunk_deserialize corpus/ -max_len=1048576 ``` ### AFL++ Harness diff --git a/.opencode/skills/pr-review/SKILL.md b/.opencode/skills/pr-review/SKILL.md index 395abc2..99e4fcd 100644 --- a/.opencode/skills/pr-review/SKILL.md +++ b/.opencode/skills/pr-review/SKILL.md @@ -125,7 +125,7 @@ STYLE: If the user wants to post the review as a PR comment: ```bash -tea pr comment --comment "" +tea comment --repo TapTap/FastSync "" ``` ## Rules diff --git a/AGENTS.md b/AGENTS.md index a41dcc5..abdb967 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -80,7 +80,7 @@ docker run --rm -v "$PWD:/workspace" -w /workspace gitea.tap-tap.win/taptap/fast ### If integration tests fail Run locally before pushing: ```bash -python3 -m pytest tests/ -v --tb=short +python3 -m pytest tests/integration/ -n 4 --dist=load -m "not setpriv" ``` ## Branch Strategy diff --git a/README.md b/README.md index 0c3bc9f..ee5627c 100644 --- a/README.md +++ b/README.md @@ -314,7 +314,7 @@ ssh user@host 'mkdir -p destination' Start the FastSync server: ```bash -./build/server --destination-root /path/to -p 8080 +./build/server --destination-root /path/to -p 8080 --allow-unauthenticated ``` Then run the client: @@ -366,7 +366,7 @@ FastSync-native are optional performance or transport extensions. ./build/client --incremental --checksum /source/ user@host:destination/ #Preserve supported mode and timestamp metadata -./build/client -M /source/ user@host:destination/ +./build/client --preserve /source/ user@host:destination/ #Keep backups of overwritten destination files ./build/client --backup --backup-dir backups \ @@ -643,7 +643,7 @@ Run the unit test binary: Run the Python integration suite: ```bash -python3 -m pytest tests/ +python3 -m pytest tests/integration/ -n 4 --dist=load -m "not setpriv" ``` For stricter local validation: