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
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ cran-comments.md
^\.positai$
^\.claude$
^\.codex$
^\.agents$
^\.cursor$
^AGENTS\.md$
^CLAUDE\.md$
16 changes: 16 additions & 0 deletions .claude/rules/agent-runtime.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
---
paths:
- "R/agent_*.R"
- "R/final_models.R"
- "R/forecast_selection.R"
- "R/run_info.R"
- "R/input_checks.R"
- "R/prep_data.R"
- "R/prep_models.R"
- "R/read_write_data.R"
- "tests/testthat/helper-forecast-selection.R"
- "tests/testthat/test-agent*.R"
- "tests/testthat/test-final-models-restart.R"
- "tests/testthat/test-forecast-selection*.R"
- "tests/testthat/test-reconciled-forecast-selection.R"
- "tests/testthat/test-finalize_run.R"
- "tests/testthat/test-combo-normalization.R"
- "tests/testthat/test-prep_models.R"
Expand All @@ -27,3 +33,13 @@ paths:
- Propagate every best-run blob-listing provider error, including post-write verification errors. Never reinterpret listing failures as no files, and do not add per-retry or per-worker wildcard listings to large ADLS folders.
- Use `normalize_combo_values()` before validation, `Combo` construction, hierarchy processing, or artifact writes in both `set_agent_info()` and `prep_data()`. Trim character boundaries only; preserve internal spaces, missing values, and numeric identifiers. Fail before writing when normalization creates a blank value or duplicate combo/date. Do not trim generic `hash_data()` inputs.
- Never send `Inf`, `-Inf`, or `NaN` in EDA summaries to an LLM. Represent absent outlier dates explicitly and omit unavailable regressor-lag rankings while preserving raw EDA artifacts.

## Iteration Selection Policy

- Average model accuracy is a critical search-direction signal, not redundant logging. The best individual model can stay unchanged while an input or setting change improves other models that may become the winners after further iterations.
- For example, ARIMA may remain the most accurate model after adding an external regressor (`xreg`), while the regressor improves MAPE across the multivariate models. Preserve that evidence when choosing the iteration context for continued optimization; do not discard the change solely because ARIMA did not improve. This is a useful signal, not a guarantee of future accuracy.
- Preserve the original near-best iteration-ranking rule: start from the earliest minimum-WMAPE iteration, then consider later eligible iterations within 10% relative of that WMAPE and prefer a strictly lower `model_avg_wmape`. Do not replace this with strict minimum-WMAPE-only ranking. Keep the existing current-version eligibility and distinct best-forecast persistence safeguards.
- `model_avg_wmape` is the mean of the individual model candidates' WMAPEs, not the WMAPE of an averaged forecast. Preserve the existing local/global meanings of `model_avg_wmape`, `model_median_wmape`, and `model_std_wmape`. Do not replace genuine model-pool statistics with copies of the winning model's WMAPE or a fabricated zero spread.
- Future-plausibility checks select models within each iteration. Avoiding repeated future-quality assessments across iterations must not remove these existing backtest-accuracy signals. Reuse available predictions and recorded metrics without introducing repeated artifact discovery or rereading past forecasts.
- All globally selected series must reference one winning global iteration so forecast updates reuse one global run. Promote global winners as one run-level decision, not per-series improvements across iterations. Preserve superior local winners and allow different model IDs or component subsets within that one global iteration. Reject mixed saved global iteration metadata before publication or update, including after interrupted writes; never silently split it into several global updates.
- Changes to this heuristic, its tolerance, metric meanings, rounding, or run-level versus per-series publishing rules require separate explicit user approval. Tests and documentation must protect the intended policy, not silently redefine it to match a refactor.
2 changes: 1 addition & 1 deletion .cursor/rules/agent-runtime.mdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Use when working on FinnTS agent runtime rules."
globs: "R/agent_*.R,R/run_info.R,R/input_checks.R,R/prep_data.R,R/prep_models.R,R/read_write_data.R,tests/testthat/test-agent*.R,tests/testthat/test-finalize_run.R,tests/testthat/test-combo-normalization.R,tests/testthat/test-prep_models.R"
globs: "R/agent_*.R,R/final_models.R,R/forecast_selection.R,R/run_info.R,R/input_checks.R,R/prep_data.R,R/prep_models.R,R/read_write_data.R,tests/testthat/helper-forecast-selection.R,tests/testthat/test-agent*.R,tests/testthat/test-final-models-restart.R,tests/testthat/test-forecast-selection*.R,tests/testthat/test-reconciled-forecast-selection.R,tests/testthat/test-finalize_run.R,tests/testthat/test-combo-normalization.R,tests/testthat/test-prep_models.R"
alwaysApply: false
---

Expand Down
2 changes: 1 addition & 1 deletion .github/instructions/agent-runtime.instructions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
applyTo: "R/agent_*.R,R/run_info.R,R/input_checks.R,R/prep_data.R,R/prep_models.R,R/read_write_data.R,tests/testthat/test-agent*.R,tests/testthat/test-finalize_run.R,tests/testthat/test-combo-normalization.R,tests/testthat/test-prep_models.R"
applyTo: "R/agent_*.R,R/final_models.R,R/forecast_selection.R,R/run_info.R,R/input_checks.R,R/prep_data.R,R/prep_models.R,R/read_write_data.R,tests/testthat/helper-forecast-selection.R,tests/testthat/test-agent*.R,tests/testthat/test-final-models-restart.R,tests/testthat/test-forecast-selection*.R,tests/testthat/test-reconciled-forecast-selection.R,tests/testthat/test-finalize_run.R,tests/testthat/test-combo-normalization.R,tests/testthat/test-prep_models.R"
---

# Agent Runtime Rules
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Detailed rules load conditionally from `.claude/rules/`, a format shared by Clau

- `.claude/rules/r-package.md` for R source, package metadata, roxygen, vignettes, and release notes.
- `.claude/rules/testing.md` for tests, CRAN profiles, credentials, runtime budgets, and PSOCK behavior.
- `.claude/rules/agent-runtime.md` for Agent graphs, LLM sessions, reasoning retries, history, artifacts, combo identity, and EDA prompts.
- `.claude/rules/agent-runtime.md` for Agent graphs, iteration selection and its accuracy signals, LLM sessions, reasoning retries, history, artifacts, combo identity, and EDA prompts.
- `.claude/rules/multistep.md` for multistep adapters, lag generation, routing, and prediction.
- `.claude/rules/optional-dependencies.md` for feature selection, TimeGPT, and optional package boundaries.

Expand Down Expand Up @@ -75,6 +75,7 @@ Keep edits focused. Do not refactor unrelated code, change public APIs without a
## Safety And Quality

- Never commit secrets, tokens, local paths, or machine-specific configuration.
- Preserve established forecasting decision policies unless the user explicitly approves changing them. In particular, protect the Agent's average-model accuracy signal for iteration selection; its rationale and rules are in [.claude/rules/agent-runtime.md](.claude/rules/agent-runtime.md#iteration-selection-policy). Logging or performance work is not permission to simplify those decisions.
- Prefer existing dependencies and established package patterns. New dependencies require a concrete feature need and explicit justification.
- Do not weaken or delete tests to hide a failure; fix the underlying behavior.
- Do not create code or functions that delete files.
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: finnts
Title: Microsoft Finance Time Series Forecasting Framework
Version: 0.7.0.9005
Version: 0.7.0.9006
Authors@R:
c(person(given = "Mike",
family = "Tokic",
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# finnts 0.7.0.9005 (DEVELOPMENT VERSION)
# finnts 0.7.0.9006 (DEVELOPMENT VERSION)

## Improvements

- Improved model selection to balance backtest accuracy with forecast plausibility, preserve supported growth and seasonal patterns, and reject invalid predictions, with more reliable averaging, forecast updates, and run recovery.

## Bug Fixes

Expand Down
Loading
Loading