Skip to content

Latest commit

 

History

History
287 lines (193 loc) · 5.94 KB

AGENTS.md

File metadata and controls

287 lines (193 loc) · 5.94 KB

AGENTS.md

Project

This repository is KinOpt, a scientific Python package for optimization-based estimation of cumulative kinase effects on substrate phosphorylation, including kinase autophosphorylation effects on its own activity.

The repository should be treated as a working scientific software package. Do not rewrite it from scratch.

Primary code areas:

  • kinopt/
  • processing/
  • config/
  • config_loader.py
  • docs/
  • pixi.toml

Do not assume the existence of unrelated packages unless they are present in the filesystem.


General Rules for AI Agents

  1. Preserve the existing package flow.
  2. Make minimal, targeted changes.
  3. Do not perform broad rewrites unless explicitly requested.
  4. Do not rename public functions, modules, CLI tasks, or output files unless required.
  5. Do not change scientific meaning, objective functions, parameter interpretation, or output semantics without documenting why.
  6. Do not delete working functionality to make a task easier.
  7. Prefer small, reviewable patches over large architectural changes.
  8. Keep existing folder structure unless explicitly instructed otherwise.
  9. Do not introduce hidden global state except for required numerical backend configuration.
  10. Always validate changes with Pixi commands where possible.

Environment Management

This project uses Pixi, not Poetry, Conda directly, or plain pip.

Use:

pixi run -e dev check-import
pixi run -e dev test
pixi run -e docs docs-build

Do not add Poetry files.

Do not create requirements.txt unless explicitly requested.

Dependency changes must go into pixi.toml.

If adding publishing/build dependencies, prefer a dedicated Pixi feature/environment.


Current Repository Scope

The actual project modules are:

kinopt/
processing/
config/
config_loader.py

Do not document or import nonexistent modules such as:

tfopt
protwise
networkmodel
common
config.config

unless they actually exist in the repository.

If an existing task still references nonexistent modules, update it carefully. For example:

check-import = "PYTHONPATH=. python -c \"import kinopt, processing, config, config_loader; print('project imports ok')\""

Optimization Backend Migration Rules

The intended backend migration is:

  • Replace SciPy local optimization with JAX/JAXopt.
  • Replace pymoo evolutionary optimization with QDax.
  • Use jax.numpy in optimization core functions.
  • Enable JAX float64 globally in optimization modules.

Required JAX setup:

import jax

jax.config.update("jax_enable_x64", True)

Use:

import jax.numpy as jnp

Convert numerical inputs entering optimization cores with:

jnp.asarray(x, dtype=jnp.float64)

Convert back to NumPy/Pandas only at export, plotting, or reporting boundaries.

Do not convert the whole package blindly to JAX. Restrict JAX conversion to optimization-relevant numerical cores.


Local Optimization Rules

Local optimization code is primarily under:

kinopt/local/

Replace SciPy optimizer calls with JAXopt.

Preferred mappings:

  • Bounded optimization: jaxopt.ProjectedGradient with projection_box
  • Non-negative optimization: projection_non_negative
  • Unconstrained optimization: jaxopt.LBFGS or jaxopt.GradientDescent

Preserve existing function names and return structure where possible.

Do not silently ignore unsupported solver names. Either map old names explicitly or raise a clear error.


Config Rules

Do not redesign configuration.

Files such as:

config.toml
config/
config_loader.py

should remain stable.

Allowed config changes:

  • solver/backend option names
  • bounds handling required for JAXopt/QDax
  • tech-stack labels
  • backward-compatible mapping of old solver names to new backends

Disallowed config changes:

  • changing unrelated defaults
  • changing file formats
  • renaming unrelated keys
  • removing existing working options without replacement

Documentation Rules

Docs must reflect the real repository.

Allowed mkdocstrings targets include only importable modules, for example:

::: kinopt
::: kinopt.local
::: kinopt.fitanalysis
::: kinopt.optimality
::: processing
::: config
::: config.cli
::: config.logconf
::: config_loader

Do not use:

::: config.config

because config/config.py does not exist.

When updating docs for backend migration, replace implementation references to:

  • SciPy optimization
  • scipy.optimize
  • pymoo
  • COBYLA/SLSQP/pymoo NSGA-II as active backends

with:

  • JAX
  • JAX NumPy
  • JAXopt
  • QDax
  • QDax NSGA2/SPEA2

Historical mentions are acceptable only in changelog/migration notes.


Testing and Validation

After code changes, run:

pixi run -e dev check-import
pixi run -e dev test

After documentation changes, run:

pixi run -e docs docs-build

If docs fail due to mkdocstrings, fix the broken module path. Do not disable mkdocstrings globally just to pass the build.

If tests fail, identify whether the failure is caused by the current changes or pre-existing issues.


Style Rules

  • Keep code readable and explicit.
  • Avoid clever abstractions.
  • Prefer direct numerical code.
  • Keep scientific logic transparent.
  • Do not add excessive comments.
  • Add comments only where backend translation or numerical semantics could be unclear.
  • Avoid broad formatting-only diffs.

Git / Filesystem Rules

Do not modify generated/cache/build files unless explicitly requested.

Do not commit or generate:

.pixi/
.venv/
__pycache__/
.pytest_cache/
dist/
build/
*.egg-info/
logs/
results_*/

Keep .gitignore aligned with these exclusions.


Final Response Expectations for Agents

When finished, report:

  1. What files were changed.
  2. What backend or docs changes were made.
  3. What validation commands were run.
  4. Which commands passed or failed.
  5. Any remaining limitations.

Do not claim success unless the relevant validation command actually passed.