This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git


The following commit(s) were added to refs/heads/main by this push:
     new d846e45f8 docs: add more agent harness rules (#3610)
d846e45f8 is described below

commit d846e45f8a28253f4044a82038119fc406578a65
Author: Shawn Yang <[email protected]>
AuthorDate: Thu Apr 23 20:57:28 2026 +0800

    docs: add more agent harness rules (#3610)
    
    ## Why?
    
    
    
    ## What does this PR do?
    
    
    
    ## Related issues
    
    
    
    ## AI Contribution Checklist
    
    
    
    - [ ] Substantial AI assistance was used in this PR: `yes` / `no`
    - [ ] If `yes`, I included a completed [AI Contribution
    
Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs)
    in this PR description and the required `AI Usage Disclosure`.
    - [ ] If `yes`, my PR description includes the required `ai_review`
    summary and screenshot evidence of the final clean AI review results
    from both fresh reviewers on the current PR diff or current HEAD after
    the latest code changes.
    
    
    
    ## Does this PR introduce any user-facing change?
    
    
    
    - [ ] Does this PR introduce any public API change?
    - [ ] Does this PR introduce any binary protocol compatibility change?
    
    ## Benchmark
---
 .agents/ci-and-pr.md                 | 16 ++++++++++++++++
 .agents/docs-and-formatting.md       |  7 +++++++
 .agents/languages/cpp.md             |  2 ++
 .agents/languages/csharp.md          |  1 +
 .agents/languages/dart.md            |  9 +++++++++
 .agents/languages/java.md            |  7 +++++++
 .agents/languages/javascript.md      |  6 ++++++
 .agents/languages/python.md          |  6 ++++++
 .agents/languages/rust.md            |  5 +++++
 .agents/languages/swift.md           |  3 +++
 .agents/testing/integration-tests.md |  4 ++++
 .gitignore                           |  2 ++
 AGENTS.md                            | 23 +++++++++++++++++++++++
 13 files changed, 91 insertions(+)

diff --git a/.agents/ci-and-pr.md b/.agents/ci-and-pr.md
index c21a3b00e..9a3ccd0fe 100644
--- a/.agents/ci-and-pr.md
+++ b/.agents/ci-and-pr.md
@@ -28,6 +28,14 @@ Typical flow:
 1. Run `gh pr checks <PR_NUMBER> --repo apache/fory`.
 2. Inspect the failed job with `gh run view ... --log-failed`.
 3. Reproduce the failure locally, fix the root cause, and rerun the relevant 
checks.
+4. Monitor the latest PR head SHA until all required workflows have settled; 
local targeted validation and remote all-green confirmation are separate 
requirements.
+
+## Scope And Worktrees
+
+- Keep review tasks and fix tasks separate. For review-only requests, report 
findings without editing files, committing, pushing, fixing tests, or updating 
docs unless the user explicitly starts a fix task.
+- Current-branch fixes should happen in the current workspace. Use extra 
worktrees for read-only baselines or isolated PR reviews unless the user asks 
for a separate implementation worktree.
+- Before pushing PR work, verify `git remote -v`, the current branch, and the 
PR head repository/branch; do not infer push targets from contributor names.
+- Do not stage or commit task scratch files such as `tasks/task-*.md`, 
`tasks/lessons.md`, or synthesis/plan notes unless the user explicitly asks to 
version them.
 
 ## Common CI Failures
 
@@ -35,6 +43,14 @@ Typical flow:
 - Markdown lint failures: run `prettier --write <file>`.
 - C++ build failures: check missing dependencies, includes, and 
architecture-specific Bazel flags.
 - Test failures: reproduce locally with the smallest command set that proves 
the fix.
+- Java harnesses that capture child stdout/stderr must drain those streams 
concurrently or redirect them before waiting, otherwise chatty peer tests can 
deadlock.
+
+## Workflow Changes
+
+- In ASF GitHub Actions, verify new `uses:` entries against approved Apache 
infrastructure action patterns; replace unapproved actions with approved 
actions plus shell or Python logic when needed.
+- Do not add workflow dependencies on new repository variables or secrets when 
GitHub Actions context, constants, or checked-in configuration can provide 
stable non-secret values. Coordinate required repo config before landing if no 
safe default exists.
+- If a setup action fails because of a runtime deprecation, verify the current 
official major and upgrade to the compatible major rather than adding temporary 
runner flags.
+- Reusable release automation belongs under `ci/` unless the user explicitly 
requests a language-local script.
 
 ## PR Expectations
 
diff --git a/.agents/docs-and-formatting.md b/.agents/docs-and-formatting.md
index 809b2eda3..e0cca50b9 100644
--- a/.agents/docs-and-formatting.md
+++ b/.agents/docs-and-formatting.md
@@ -21,6 +21,12 @@ Load this file when changing documentation, public APIs, 
protocol specs, benchma
 - `docs/DEVELOPMENT.md` plus updates under `docs/guide/` and 
`docs/benchmarks/` are synced to `apache/fory-site`; other website content 
should be changed there instead of this repo.
 - When benchmark logic, scripts, config, or compared serializers change, rerun 
the relevant benchmarks and refresh the report and plots under 
`docs/benchmarks/**`.
 - Never manually edit generated code for compiler or IDL outputs; regenerate 
from the source schema or IDL.
+- Do not treat checked-in benchmark reports as canonical for current numbers. 
Run the active harness or a source-aligned size check, and match schema, 
config, and mode before comparing runtimes.
+- Use portable repo-relative or web links in repository docs, not local 
filesystem paths. Package readmes rendered by external package managers should 
link to canonical published docs pages when that is the user-facing context.
+- Published `docs/guide/**` pages should prioritize end-user installation and 
usage flows unless the file is explicitly a contributor or development guide.
+- Documentation examples should use normal explicit imports, avoid unused 
imports, and keep common Fory types unqualified where that is the idiom.
+- Generated Markdown under `docs/benchmarks/**` should satisfy markdownlint 
blank-line rules at generation time: no repeated blank lines and no extra blank 
line after final content.
+- Keep default recommendations minimal. Put uncommon optimization or transport 
patterns in clearly labeled optional sections.
 
 ## Formatting Commands
 
@@ -32,3 +38,4 @@ Load this file when changing documentation, public APIs, 
protocol specs, benchma
 - Prefer precise, technically defensible claims over marketing language.
 - Keep terminology consistent with the specs and language guides.
 - If a protocol or behavior description differs between docs and code, treat 
that as an issue to resolve before finishing.
+- For comparison prose, split broad claims into concrete technical dimensions, 
mention meaningful exceptions, and avoid absolute competitor or winner/loser 
framing unless the user explicitly requests it.
diff --git a/.agents/languages/cpp.md b/.agents/languages/cpp.md
index 5bd6203a5..ab5df81b1 100644
--- a/.agents/languages/cpp.md
+++ b/.agents/languages/cpp.md
@@ -13,6 +13,8 @@ Load this file when changing `cpp/`, Cython build plumbing, 
or C++ xlang behavio
 - Wrap error checks with `FORY_PREDICT_FALSE` for branch prediction.
 - Continue on trivial errors; return early only for critical errors such as 
buffer overflow.
 - Put private methods last in class definitions, immediately before private 
fields.
+- Do not redesign alias-based or low-level public type shapes to add 
convenience methods unless the user explicitly asks for that API change.
+- For cross-language feature ports, match protocol behavior but use idiomatic 
C++ ownership and layering instead of mirroring Java structure literally.
 
 ## Key Paths
 
diff --git a/.agents/languages/csharp.md b/.agents/languages/csharp.md
index fc52947c9..fe66720c7 100644
--- a/.agents/languages/csharp.md
+++ b/.agents/languages/csharp.md
@@ -8,6 +8,7 @@ Load this file when changing `csharp/` or C# xlang behavior.
 - Changes under `csharp/` must pass formatting and tests.
 - Fory C# requires .NET SDK `8.0+` and C# `12+`.
 - Use `dotnet format` to keep C# code style consistent.
+- When extending C# tests from Java references, prioritize xlang spec behavior 
and the public C# contract before adding complex Java-specific parity cases.
 
 ## Commands
 
diff --git a/.agents/languages/dart.md b/.agents/languages/dart.md
index dcbdb10bf..b95081626 100644
--- a/.agents/languages/dart.md
+++ b/.agents/languages/dart.md
@@ -9,6 +9,15 @@ Load this file when changing `dart/`.
 - Do not design different user-facing generated-registration behavior for Dart 
VM and Flutter/no-mirrors. Cross-platform registration flow must stay 
consistent.
 - Users must never be required to call private generated helpers such as 
`_ensure...` or `_install...`.
 - If `Fory.register(...)` cannot be made self-sufficient across Dart 
platforms, use an explicit public wrapper API rather than splitting VM and 
Flutter behavior.
+- Generated registration is ownership-based: generated types register through 
`Fory.register(...)`, manual or custom serializers use 
`Fory.registerSerializer(...)`, and generated descriptors/support helpers stay 
internal.
+- Keep root numeric wrapper defaults separate from generated field metadata. 
Root wrapper resolution belongs in the builtin resolver, while annotations and 
generated metadata choose fixed, tagged, or declared-field encodings.
+- Dart 64-bit carriers are optimized for each platform. Do not replace native 
extension-type wrappers with allocation-heavy classes or route web/native hot 
paths through `BigInt` unless the user approves a representation change.
+- In `Buffer`, cursor, serializer, and generated-code hot paths, prefer direct 
byte/local integer operations and conditional import/export files over 
callbacks, records, holder objects, wrapper round-trips, or runtime platform 
branches.
+- Codegen must support private fields through same-library `part` generation. 
If generated file naming changes from `*.fory.dart`, update builder config, 
source `part` directives, analysis exclusions, docs, CI snippets, and stale 
artifacts together.
+- Keep generated Dart outputs (`*.fory.dart`) and Dart `pubspec.lock` files 
untracked in this repo.
+- For generated numeric or xlang changes, test root values and generated 
required/nullable fields across schema-consistent and compatible serializers, 
metadata type IDs, rejection paths, and every affected encoding mode.
+- Dart xlang or runtime ownership changes need local Dart package tests plus 
the Java-driven `DartXlangTest`; package-only smoke tests are not enough.
+- When claiming non-VM Dart support, prove a relevant non-VM compile path such 
as `dart compile js` against active runtime or example code.
 
 ## Commands
 
diff --git a/.agents/languages/java.md b/.agents/languages/java.md
index a1e42dc30..05b5d0877 100644
--- a/.agents/languages/java.md
+++ b/.agents/languages/java.md
@@ -16,6 +16,13 @@ Load this file when changing anything under `java/` or when 
Java drives a cross-
 - When the serializer class and constructor shape are known at the call site, 
prefer direct constructor lambdas or direct instantiation over reflective 
`Serializers.newSerializer(...)`.
 - For GraalVM, use `fory codegen` to generate serializers when building native 
images. Do not add reflection configuration except for JDK `proxy`.
 - In Java native mode (`xlang=false`), only `Types.BOOL` through 
`Types.STRING` share type IDs with xlang mode. Other native-mode type IDs 
differ.
+- Choose one serializer ownership location per logical Java type family. Add 
native/xlang serializer variants only when the wire format or constructor 
contract truly differs.
+- Do not add normal-JVM process-global caches keyed by user classes, generated 
classes, serializer classes, classloaders, or class-bound method handles. 
Prefer per-runtime state, immutable shared metadata, or build-time-only 
template data.
+- Concrete serializers may opt into sharing only after auditing retained 
fields. Treat serializers retaining `TypeResolver`, `RefResolver`, mutable 
scratch buffers, runtime state, or classloader-sensitive state as non-shareable 
unless that state is externalized.
+- Resolver and serializer hot paths should keep the fast-path/null-slow-path 
shape obvious. Hoist repeated buffer or cache-state access into locals for 
multi-step operations and keep rebuild/restoration logic cold.
+- Keep GraalVM feature code as a thin metadata/registration layer. Build time 
should publish metadata needed for runtime reconstruction, not retain concrete 
generated or user serializer instances in the image heap.
+- If changes touch GraalVM bootstrap, serializer retention, native-image 
metadata, or `ObjectStreamSerializer` GraalVM behavior, verify the native-image 
build and run the produced binary; a plain Java compile is insufficient.
+- Put latest-JDK or virtual-thread tests in the latest-JDK test modules with 
the matching compiler/profile floor, and centralize runtime-version probing in 
existing compatibility utilities.
 
 ## Key Modules
 
diff --git a/.agents/languages/javascript.md b/.agents/languages/javascript.md
index aa093ce86..b69393ad3 100644
--- a/.agents/languages/javascript.md
+++ b/.agents/languages/javascript.md
@@ -6,6 +6,12 @@ Load this file when changing `javascript/`.
 
 - Run JavaScript and TypeScript commands from within `javascript/`.
 - This implementation uses npm or yarn for package management.
+- IDL Jest tests should stay local to generated-code construction and local 
`Fory` serialize/deserialize assertions. Java-driven peer orchestration belongs 
in the existing integration harness.
+- Language peer entrypoints under `integration_tests/idl_tests` should mirror 
existing peers and validate semantic equality, not just deserialize and 
reserialize bytes.
+- Preserve generated serializer hot paths that bind writer, reader, ref, 
resolver, and metadata locals in outer closures; do not replace them with 
per-call context lookups without a measured reason.
+- Runtime value carriers such as decimal or reduced-precision numeric types 
belong under the core `types/` ownership boundary, with imports, exports, and 
codegen externals updated together.
+- Keep `TypeInfo` as schema metadata. Compatibility-sensitive decisions belong 
on `TypeResolver` or explicit operations, not as retained resolver state on 
metadata objects.
+- Normalize optional boolean config values at config construction; do not 
carry `null` through runtime paths when it means `false`.
 
 ## Commands
 
diff --git a/.agents/languages/python.md b/.agents/languages/python.md
index 9a470e474..08c6beb97 100644
--- a/.agents/languages/python.md
+++ b/.agents/languages/python.md
@@ -10,6 +10,12 @@ Load this file when changing `python/`, Cython 
serialization, or Python xlang be
 - Use `ENABLE_FORY_CYTHON_SERIALIZATION=0` first when debugging protocol 
behavior.
 - Python mode is the pure-Python xlang implementation and is mainly for 
debugging and testing.
 - Cython mode is the default high-performance implementation.
+- Cython mode owns the hot runtime path. Do not duplicate core runtime types 
between Python and Cython, tunnel Python facade methods into hidden Cython 
internals, or keep dead shims unless the user explicitly needs a compatibility 
module path.
+- Use explicit Cython fields and methods for fixed hot-path shapes. Avoid 
`__getattr__`, generic `object` fields, public bridge internals, or `Fory` 
backreferences where ownership can stay explicit.
+- Keep Python and Cython context/ref-tracking branch conditions and stack 
mutations semantically aligned unless a documented intentional difference 
exists.
+- Public value constructors should accept normal Python values. Raw-bit, 
raw-buffer, and memoryview entry points should be explicit low-level APIs, and 
packed carriers should expose the buffer protocol from the actual storage owner 
when appropriate.
+- When debugging runtime or benchmark behavior, install the local package into 
the exact interpreter under test instead of relying on mixed `PYTHONPATH` state.
+- For wheel or extension pipeline changes, derive extension-module paths from 
current build targets, packaging config, or wheel payload discovery rather than 
historical module names.
 - Keep new Python test names compact and behavior-focused; avoid 
sentence-length names that restate setup details already obvious from the test 
body.
 - `ENABLE_FORY_DEBUG_OUTPUT=1` enables detailed struct serialization and 
deserialization logs.
 
diff --git a/.agents/languages/rust.md b/.agents/languages/rust.md
index 502bd46a5..8e5e8066c 100644
--- a/.agents/languages/rust.md
+++ b/.agents/languages/rust.md
@@ -9,6 +9,11 @@ Load this file when changing `rust/` or Rust xlang behavior.
 - Use `RUST_BACKTRACE=1 FORY_PANIC_ON_ERROR=1` when debugging failing Rust 
tests.
 - Add `-- --nocapture` when you need test output during debugging.
 - Do not set `FORY_PANIC_ON_ERROR=1` when running the full Rust test suite, 
because some tests assert on error contents.
+- Avoid cosmetic filesystem or module churn when logical module names and call 
sites are already stable.
+- Operation contexts such as `ReadContext` and `WriteContext` should sit 
beside the runtime facade and aggregate resolver, buffer, and config state; 
they are not resolver-owned submodules.
+- Runtime carriers belong in `types/`, and schema or type-hash helpers belong 
with metadata hashing rather than generic wire/type-id modules.
+- If breakage is explicitly acceptable during a Rust module refactor, rewire 
macros, tests, and sibling crates directly to the new boundaries instead of 
adding compatibility re-exports.
+- For panic-safety in hot paths, preserve TLS context reuse. Add scoped guards 
or owned fallbacks rather than per-call context allocation, and reset reused 
contexts at entry and successful exit.
 
 ## Key Paths
 
diff --git a/.agents/languages/swift.md b/.agents/languages/swift.md
index 4c1b0b6ad..8c10848e0 100644
--- a/.agents/languages/swift.md
+++ b/.agents/languages/swift.md
@@ -8,6 +8,9 @@ Load this file when changing `swift/` or Swift xlang behavior.
 - Changes under `swift/` must pass lint and tests.
 - Swift lint uses `swift/.swiftlint.yml`.
 - Use `ENABLE_FORY_DEBUG_OUTPUT=1` when debugging Swift tests.
+- Prefer the user-requested or existing Foundation public value type when it 
is the intended Swift surface; do not invent Fory-prefixed wrappers only to 
avoid import ambiguity.
+- Preserve distinct temporal semantics. Timestamp values and day-only local 
dates should have protocol-accurate helper names and no stale aliases after a 
refactor.
+- When temporal or public-type refactors touch generated Swift code, sweep 
message fields, union payloads, macros, xlang harnesses, and integration 
fixtures together.
 
 ## Commands
 
diff --git a/.agents/testing/integration-tests.md 
b/.agents/testing/integration-tests.md
index 7a891f946..0f2086eed 100644
--- a/.agents/testing/integration-tests.md
+++ b/.agents/testing/integration-tests.md
@@ -10,7 +10,9 @@ Load this file when changing `integration_tests/`, xlang 
behavior, compiler-gene
 - For `integration_tests/idl_tests`:
   - Always run `cd ../java && mvn -T16 install -DskipTests` before the test if 
Java changed since the last install. If unsure, run it.
   - Always run `cd ../python && pip install -v -e .` before the test if Python 
or Cython code changed. Rebuild Cython if needed.
+  - Peer entrypoints must mirror the existing peer orchestration and validate 
semantic equality, not only deserialize and reserialize bytes.
 - Never manually edit code generated by the Fory compiler for IDL tests. 
Regenerate it from the source IDL.
+- For GraalVM changes, build the native image and run the produced binary; a 
plain Java compile is insufficient.
 
 ## Main Modules
 
@@ -41,3 +43,5 @@ cd "$it_dir/cpython_benchmark" && pip install -r 
requirements.txt && python benc
 ## Cross-Language Validation Note
 
 When a change affects xlang behavior, combine these integration checks with 
the relevant Java-driven xlang tests from the language-specific files under 
`.agents/languages/`.
+
+Local package tests and smoke tests do not replace the Java-driven xlang path 
when runtime wire behavior, IDL peers, or generated xlang code changed.
diff --git a/.gitignore b/.gitignore
index 8c4a0c2b7..646b11cf2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -132,3 +132,5 @@ test.md
 benchmarks/dart/profile_output
 **/*.fory.dart
 **/pubspec.lock
+
+**/tmp/*
\ No newline at end of file
diff --git a/AGENTS.md b/AGENTS.md
index f0a0c799b..4a333a1c3 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -22,6 +22,21 @@ This is the entry point for AI guidance in Apache Fory. Read 
this file first, th
 - `.agents/languages/scala.md`
 - For protocol or xlang changes, load the relevant language files plus 
`.agents/docs-and-formatting.md` and `.agents/testing/integration-tests.md`.
 
+## Agent Operating Rules
+
+- Preserve architecture. Do not introduce new layers, parallel flows, or 
public APIs unless explicitly requested; prefer local repair in the existing 
owner over shared-infra expansion, and stop if a fix conflicts with an ADR, 
spec, or invariant.
+- Respect ownership. Keep logic, state, and helpers in their natural owner, 
and do not move serializer-local, context-local, runtime-type-local, or 
protocol-local problems into global utilities.
+- Check the spec before implementation. For wire behavior and xlang mapping, 
use the specs as the source of truth and never copy one runtime's bug into 
another runtime just to make tests pass.
+- Reject semantic hacks. Do not bypass broken semantics by deleting cases, 
simplifying callers, adding coercion hooks, or using workaround fallbacks; fix 
the underlying bug and prove it with focused tests.
+- Protect hot paths. Avoid per-call allocations, callback objects, result 
tuples or records, unnecessary runtime branches, and wrapper-class 
substitutions in hot codec/runtime paths; prefer conditional imports and 
allocation-free concrete implementations where they fit the language.
+- Keep public APIs minimal. Public APIs must match user ownership and mental 
model, not internal implementation details; generated flows stay type-owned, 
while manual serializer registration stays explicit.
+- Use semantic naming only. Name things after protocol or domain concepts, not 
history, runtime origin, or workaround style; avoid vague names such as 
`Internal`, `java_style_*`, `Runtime`, `Session`, `Plan`, or `Binding` when 
they do not name the real concept.
+- Keep one implementation path. Do not keep parallel helpers, serializers, 
harnesses, wrappers, or registration flows for the same concept; extend the 
existing owner path instead of inventing another one.
+- Follow current scope exactly. The latest explicit user instruction overrides 
earlier plans, and when scope narrows, remove leaked out-of-scope edits 
immediately.
+- Verification is required. Match validation to the real ownership path: 
compile, tests, xlang, native-image, non-VM compile, benchmarks, and remote CI 
as applicable; reasoning alone is never enough.
+- Finish the whole surface. A feature or behavior change is incomplete until 
code, tests, docs, exports, examples, and build wiring agree, unless the user 
explicitly defers part of that surface.
+- Keep task boundaries strict. Review tasks do not edit code, analysis-only 
tasks do not silently turn into implementation, and active-branch fixes must 
land in the active branch/workspace.
+
 ## Repo-Wide Hard Rules
 
 - Do not preserve legacy, dead, or useless code, tests, or docs unless the 
user explicitly requests it.
@@ -39,6 +54,9 @@ This is the entry point for AI guidance in Apache Fory. Read 
this file first, th
 - Tests must exercise the actual code you wrote or changed. Do not write tests 
that pass by exercising a pre-existing code path that produces similar-looking 
results. Before writing a test, identify the exact new code path (annotation, 
codegen output, new API) and verify the test would fail if that code path were 
removed. When the change involves codegen or annotations, the test must use 
those annotations on real structs, run through the codegen pipeline, and verify 
the generated output  [...]
 - When reading code, skip files not tracked by git by default unless you 
generated them yourself or the task explicitly requires them.
 - Maintain cross-language consistency while respecting language-specific 
idioms.
+- Keep one active ownership path per concept. Do not leave duplicate 
serializers, resolvers, helpers, or registration paths for the same type family 
unless the split is deliberate and documented.
+- Name new or touched APIs, helpers, and tests after protocol concepts, 
data-model semantics, or user-visible behavior; avoid names based on runtime 
origin, bug history, storage details, or temporary workarounds.
+- For public cross-runtime or protocol features, update runtime support, 
compiler/codegen wiring, public exports, docs, specs/type mappings, integration 
fixtures, and tests together unless the user explicitly defers part of that 
scope.
 - Do not introduce checked exceptions in new code or new APIs.
 - Do not use `ThreadLocal` or other ambient runtime-context patterns in Java 
runtime code. `WriteContext`, `ReadContext`, and `CopyContext` state must stay 
explicit, generated serializers must not retain context fields, and `Fory` must 
stay a root-operation facade rather than accumulating serializer/runtime 
convenience state.
 - When a serializer class and constructor shape are known at the call site, 
prefer direct constructor lambdas or direct instantiation over reflective 
`Serializers.newSerializer(...)`. Keep reflection for dynamic or general 
construction paths only.
@@ -60,6 +78,9 @@ This is the entry point for AI guidance in Apache Fory. Read 
this file first, th
 ## Shared Engineering Expectations
 
 - Favor zero-copy techniques, JIT or codegen opportunities, and cache-friendly 
memory access patterns in performance-critical paths.
+- Keep hot paths allocation-minimal. Avoid per-call or per-element object 
allocation, boxing, wrapper round-trips, callbacks, iterator carriers, or 
holder objects unless there is a measured reason and no lower-allocation design 
preserves the same behavior.
+- Keep hot-path control flow direct and predictable. Hoist repeated 
buffer/cache/state lookups into locals for multi-step operations, keep cold 
rebuild or restoration logic on slow branches, and avoid tiny forwarding 
helpers that only obscure the owner.
+- In unified native/xlang hot paths, branch only where the wire format or 
protocol behavior actually differs. Do not add mode booleans or mode-specific 
helper parameters for equivalent behavior.
 - Public APIs must be well-documented and easy to understand.
 - Implement comprehensive error handling with meaningful messages.
 - Use strong typing and generics appropriately.
@@ -83,6 +104,8 @@ This is the entry point for AI guidance in Apache Fory. Read 
this file first, th
 - Use `integration_tests/` for cross-language compatibility validation when 
behavior crosses runtimes.
 - If xlang behavior or type mapping changes, run 
`org.apache.fory.xlang.CPPXlangTest`, `org.apache.fory.xlang.CSharpXlangTest`, 
`org.apache.fory.xlang.RustXlangTest`, `org.apache.fory.xlang.GoXlangTest`, and 
`org.apache.fory.xlang.PythonXlangTest`.
 - If Swift xlang behavior changes, run `org.apache.fory.xlang.SwiftXlangTest` 
too.
+- For performance regressions or optimizations, profile or otherwise measure 
the current branch and a fresh `apache/main` baseline before changing code; 
optimize the measured hotspot, not guessed code.
+- Do not change protocol behavior, benchmark payloads, or public APIs solely 
to manufacture performance wins.
 - For performance work, run the relevant benchmark immediately after each 
change and report the command plus before/after numbers.
 - For performance-optimization rounds, append the hypothesis, change, 
benchmark command, before/after numbers, and keep/revert decision to 
`tasks/perf_optimization_rounds.md`.
 - For refactors on performance-sensitive code, validate not only tests but 
also that no implementation-strategy drift was introduced relative to 
`apache/main` unless the user explicitly asked for that change.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to