dongjoon-hyun commented on code in PR #60670:
URL: https://github.com/apache/spark/pull/60670#discussion_r4631604086


##########
AGENTS.md:
##########
@@ -53,27 +50,22 @@ Before the first code edit or running test in a session, 
ensure a clean working
 
 - Keep source lines within 100 characters; the linters enforce this for Scala, 
Java, and Python.
   Avoid non-ASCII characters in code and comments (string literals may contain 
them when the
-  content requires it). Before committing Scala, Java or Python changes: run 
the spot-checks in
-  `.agents/code-conventions.md`.
+  content requires it). When changing Scala, Java or Python code: read
+  `.agents/code-conventions.md`, and run its spot-checks before committing.
+- Every new file needs the Apache License header, copied from a neighboring 
file of the same type

Review Comment:
   **[15] The rule now covers file types that `dev/.rat-excludes` already 
skips.**
   
   `dev/.rat-excludes` exempts whole file types by pattern, not only single 
files. Its patterns include `.*md`, `.*\.sql`, `.*\.json`, `.*\.txt`, 
`.*\.csv`, `.*\.tsv`, `.*\.data` and `.*out`. So "Every new file needs the 
Apache License header" does not hold for most new files. This PR's own 
`.agents/agent-docs.md` and `.agents/pre-flight.md` have no header, and the 
License test passes. The `sql-tests/inputs/*.sql` files have none either. An 
agent that follows the text adds a header to a new `.agents/` file or `.sql` 
input. For a JSON, CSV or text fixture, which "cannot carry one, such as test 
data", it appends the file name to `dev/.rat-excludes` next to the pattern that 
already covers it. Restoring the clause from [1] fixes both cases: "Every new 
file that `dev/.rat-excludes` does not already match needs the Apache License 
header, ...".



##########
AGENTS.md:
##########
@@ -12,25 +12,13 @@ for that directory's scope. A directory may carry these 
instructions as `CLAUDE.
 `AGENTS.md`, so check **both** names. Where both exist, one is a symlink to 
the other, and reading
 either one is sufficient.
 
-New instructions go in `AGENTS.md` or the `.agents/` directory beside it. Keep 
a rule in
-`AGENTS.md` if most tasks need it, or if an agent could break it without 
noticing it is in that
-situation. Move procedures and reference material to `.agents/`, behind a 
pointer that starts with
-its trigger. When adding instructions to a directory that has neither file, 
create `AGENTS.md` as
-the real file and add a `CLAUDE.md` symlink beside it (`ln -s AGENTS.md 
CLAUDE.md`). After editing
-agent docs, run `dev/agent_docs_lint.py --strict`, which CI also runs: it 
checks the pairing, that
-every pointer resolves and every `.agents/` file has one, and Codex's 32 KiB 
budget per chain.
+Before editing agent docs (an `AGENTS.md`, `CLAUDE.md` or `.agents/` file): 
read

Review Comment:
   **[16] The agent-docs pointer fires only after an agent has picked one of 
the right files.**
   
   The moved paragraph opens with "New instructions go in `AGENTS.md` or the 
`.agents/` directory beside it". That sentence is for an agent that is still 
choosing where to write instructions. The new trigger, "Before editing agent 
docs (an `AGENTS.md`, `CLAUDE.md` or `.agents/` file)", matches only after that 
choice is made. An agent running under Gemini CLI or Copilot that is asked to 
"add a note for agents about X" naturally writes its own file, such as 
`GEMINI.md` or `.github/copilot-instructions.md`. Neither file matches the 
trigger, and `dev/agent_docs_lint.py` does not check them. Codex and Claude 
Code do not load them either, so neither tool ever sees those instructions. The 
moved rule itself keeps a rule here "if an agent could break it without 
noticing it is in that situation", so that first sentence qualifies to stay. 
Maybe "Agent instructions go in `AGENTS.md` or `.agents/`. Before adding or 
editing them: read `.agents/agent-docs.md`."



##########
AGENTS.md:
##########
@@ -53,27 +50,22 @@ Before the first code edit or running test in a session, 
ensure a clean working
 
 - Keep source lines within 100 characters; the linters enforce this for Scala, 
Java, and Python.
   Avoid non-ASCII characters in code and comments (string literals may contain 
them when the
-  content requires it). Before committing Scala, Java or Python changes: run 
the spot-checks in
-  `.agents/code-conventions.md`.
+  content requires it). When changing Scala, Java or Python code: read
+  `.agents/code-conventions.md`, and run its spot-checks before committing.
+- Every new file needs the Apache License header, copied from a neighboring 
file of the same type
+  and placed after the `#!` line of an executable script. A file that cannot 
carry one, such as
+  test data, goes in `dev/.rat-excludes` instead; the license check in CI 
fails otherwise.
 - When adding a member to an existing class or object, put it with the code it 
belongs with,
   following the file's existing sectioning. Do not reorganize existing members 
unless the change
   requires it.
 - Spark Connect protocol is defined in proto files under 
`sql/connect/common/src/main/protobuf/`.
   Read the README there before modifying proto definitions.
-- A change that needs a version (`@since`, config `.version("...")`, new 
`MimaExcludes`
-  sections): read `.agents/versioning.md` first. It is usually not `master`'s 
version.
+- A change that needs a version (`@since`, config `.version("...")`, a 
`MimaExcludes` entry): read
+  `.agents/versioning.md` first. It is usually not `master`'s version.
 
 ## Pull Requests
 
-- PR title format is `[SPARK-xxxx][COMPONENT] Title`. Draft, WIP, MINOR, and 
TRIVIAL PRs may omit
-  the JIRA ID. The component tag comes from the `COMPONENTS` registry in 
`dev/merge_spark_pr.py`,
-  the source of truth: each entry pairs a PR-title tag with its canonical JIRA 
component name and
-  accepted aliases (e.g. `Documentation` → `[DOC]`, `Pandas API on Spark` → 
`[PS]`,
-  `SQL` → `[SQL]`). Read that registry to pick the right tag.
-- Use `[FOLLOWUP]` only for small PRs that directly modify or correct 
unreleased earlier PRs. For
-  separately planned work, non-trivial changes, or work outside the earlier 
JIRA's scope, create a
-  separate JIRA ticket for each PR and use the normal title format without 
`[FOLLOWUP]`.
-- Before creating a JIRA ticket or a PR, or writing a PR description: read
+- Before creating a JIRA ticket or a PR, or writing a PR title or description: 
read

Review Comment:
   **[18] A title-only request now reaches the JIRA creation step.**
   
   Adding "or writing a PR title" to this trigger sends an agent that only 
needs a title, as in "suggest a PR title for this branch", to 
`.agents/pr-workflow.md`. Right after the title rules, that file says "If no 
ticket ID is given and the PR is not draft, WIP, MINOR, or TRIVIAL, create one 
using `dev/create_spark_jira.py`". So the agent creates a JIRA ticket, an 
external side effect nobody asked for. Before this PR the title format was in 
this file, so writing a title never led there. Only the general approval rule 
at L74 stands in the way, and its examples are pushing commits, creating PRs 
and posting comments. Maybe start that step in `.agents/pr-workflow.md` with 
"When creating a PR and no ticket ID is given".



##########
.agents/pre-flight.md:
##########
@@ -0,0 +1,11 @@
+# Pre-flight Checks

Review Comment:
   **[19] Three dev scripts still point to the root `AGENTS.md` for the moved 
content.**
   
   - `dev/next_version_candidates.py` L32: "the `upstream` the AGENTS.md 
pre-flight has you configure";
   - `dev/pr_merge_status.py` L108: "the remote named `upstream` (the AGENTS.md 
convention)";
   - `dev/agent_docs_lint.py` L27: the pairing check is described "as the root 
AGENTS.md asks".
   
   The remote convention now lives in this file and the pairing rule in 
`.agents/agent-docs.md`. A reader who follows these docstrings finds only a 
pointer in the root. Naming the new files in the docstrings would save that 
extra step.



##########
AGENTS.md:
##########
@@ -12,25 +12,13 @@ for that directory's scope. A directory may carry these 
instructions as `CLAUDE.
 `AGENTS.md`, so check **both** names. Where both exist, one is a symlink to 
the other, and reading
 either one is sufficient.
 
-New instructions go in `AGENTS.md` or the `.agents/` directory beside it. Keep 
a rule in
-`AGENTS.md` if most tasks need it, or if an agent could break it without 
noticing it is in that
-situation. Move procedures and reference material to `.agents/`, behind a 
pointer that starts with
-its trigger. When adding instructions to a directory that has neither file, 
create `AGENTS.md` as
-the real file and add a `CLAUDE.md` symlink beside it (`ln -s AGENTS.md 
CLAUDE.md`). After editing
-agent docs, run `dev/agent_docs_lint.py --strict`, which CI also runs: it 
checks the pairing, that
-every pointer resolves and every `.agents/` file has one, and Codex's 32 KiB 
budget per chain.
+Before editing agent docs (an `AGENTS.md`, `CLAUDE.md` or `.agents/` file): 
read
+`.agents/agent-docs.md`.
 
 ## Pre-flight Checks
 
-Before the first code edit or running test in a session, ensure a clean 
working environment. DO NOT skip these checks:
-
-1. Run `git remote -v` to identify the personal fork and upstream 
(`apache/spark`). If unclear, ask the user to configure their remotes following 
the standard convention (`origin` for the fork, `upstream` for `apache/spark`).
-2. If the latest commit on `<upstream>/master` is more than a day old (check 
with `git log -1 --format="%ci" <upstream>/master`), run `git fetch <upstream> 
master`.
-3. If there are uncommitted changes (check with `git status`), ask the user to 
stash them before proceeding.
-4. Switch to the appropriate branch:
-   - **Existing PR**: resolve the PR branch name via `gh api 
repos/apache/spark/pulls/<number> --jq '.head.ref'`, then look for a local 
branch matching that name. If found, switch to it and inform the user. If not 
found, ask whether to fetch it or if there is a local branch under a different 
name.
-   - **New edits**: ask the user to choose: create a new git worktree from 
`<upstream>/master` with `--no-track` and work from there (recommended), or 
create and switch to a new branch from `<upstream>/master` with `--no-track`.
-   - **Running tests**: use `<upstream>/master`.
+Before the first code edit or running test in a session, follow 
`.agents/pre-flight.md`. DO NOT

Review Comment:
   **[17] Most tasks need the pre-flight checks, so the move costs most 
sessions an extra read.**
   
   The rule moved to `.agents/agent-docs.md` keeps a rule in `AGENTS.md` "if 
most tasks need it". Pre-flight runs before the first code edit or test run of 
every session, which covers most tasks. The PR description gives the same 
reason for the moves: "keep the root to what most tasks need". Before this PR 
the root was 6637 bytes, under its 8 KiB target, so the budget did not need the 
1.1 KB this move saves. In exchange, almost every session now needs one more 
file read before its first edit. An agent that skims pointers also ends up 
starting on a stale or dirty branch, which is what "DO NOT skip" is there to 
prevent. Keeping the four steps inline, and moving only the agent-docs 
paragraph and the PR title rules, would follow the stated rule.



##########
.agents/pre-flight.md:
##########
@@ -0,0 +1,11 @@
+# Pre-flight Checks
+
+Before the first code edit or running test in a session, ensure a clean 
working environment. DO NOT skip these checks:

Review Comment:
   **[21] Nit: the trigger and "DO NOT skip" are repeated from the pointer.**
   
   `AGENTS.md` L20 already says "Before the first code edit or running test in 
a session" and "DO NOT skip it". Because both are repeated here, any change to 
the trigger has to be made in two files, and reviewers are least likely to 
notice the copy in this file. Starting this file at "Ensure a clean working 
environment:" keeps the trigger in one place. If [17] keeps the steps inline, 
this comment no longer applies.



##########
.agents/versioning.md:
##########
@@ -1,12 +1,14 @@
 # Versioning and Branch Policy
 
-When a change needs a version — `@since` annotations, config `.version("...")` 
(`SQLConf` / `*Conf`), new `MimaExcludes` sections, etc. — use the version of 
the branch it first ships in, with `-SNAPSHOT` stripped. Determine that branch:
+When a change needs a version — `@since` annotations, config `.version("...")` 
(`SQLConf` / `*Conf`), `MimaExcludes` entries, etc. — use the version of the 
branch it first ships in, with `-SNAPSHOT` stripped. Determine that branch:
 
 - **PR opened against a non-`master` base branch** (e.g. a maintenance line 
like `branch-4.2`): use that base branch's version -- when you're checked out 
on it, that's just the working tree's `pom.xml`. The helper below covers only 
the common `master`-base case.
 - **PR opened against `master`:** most PRs merge to **both** `master` and the 
latest `branch-<N>.x` (the branch for the next feature release, e.g. 
`branch-4.x`), so use the `branch-<N>.x` version. The exception is 
**master-only** changes — use `master`'s version — which are only:
   - breaking / binary-incompatible changes that can't ship in a minor release;
   - dependency upgrades that don't fix a critical issue worth backporting.
 
+  A MiMa exclusion alone does not make a change master-only: most are for 
changes a minor release may ship, such as a new public method or a removed 
internal member, so they go in the `branch-<N>.x` version's section.

Review Comment:
   **[24] Nit: MiMa flags a new abstract method, not a new public method.**
   
   Adding a concrete public method to a class keeps binary compatibility, so 
MiMa does not report it. The new-API entries in `v44excludes` are 
`ReversedMissingMethodProblem` filters for abstract members added to the public 
abstract classes `Dataset` and `TableValuedFunction`: `Dataset.binBy` and 
`TableValuedFunction.variant_explode` (`MimaExcludes.scala:58-63`). An agent 
that reads the example as "a new public method needs an exclusion" may add a 
filter that nothing needs. "such as a new abstract method in a public trait or 
abstract class, or a removed internal member" matches the existing entries.



##########
AGENTS.md:
##########
@@ -42,6 +30,15 @@ Before the first code edit or running test in a session, 
ensure a clean working
   read `.agents/build-and-test.md`. For setup and local troubleshooting: 
`docs/building-spark.md`.
 - Before writing a new Scala or Python test suite: read 
`.agents/test-base-classes.md` and pick
   the lowest base class that provides what the test actually needs.
+- When writing or changing a test, pin the configs its assertions depend on: 
runtime SQL configs
+  with `withSQLConf` (`self.sql_conf` in Python), static SQL and core configs 
in the suite's Spark

Review Comment:
   **[23] `sparkConf` exists only in SQL session suites.**
   
   `sparkConf` is defined in `SparkSessionBinderBase` 
(`SparkSessionBinder.scala:80`), so only `SharedSparkSession` suites have it. 
Other suites have no `sparkConf`:
   
   - A core suite on `SharedSparkContext` sets its `val conf` 
(`SharedSparkContext.scala:33`) or passes a `SparkConf` to `new SparkContext`.
   - Hive suites on `TestHiveSingleton` share one session, so a static config 
cannot be set per suite at all.
   
   Pinning a core config such as `spark.task.cpus` in a `SharedSparkContext` 
suite, an agent finds no `sparkConf` to override and may fall back to 
`withSQLConf`. The running `SparkContext` ignores that, which is the trap from 
[9]. Maybe "(`sparkConf` in `SharedSparkSession` suites, `conf` in 
`SharedSparkContext` suites, `conf()` in Python)".



##########
.agents/pr-workflow.md:
##########
@@ -1,5 +1,8 @@
 # Pull Request Workflow
 
+- PR title format is `[SPARK-xxxx][COMPONENT] Title`. Draft, WIP, MINOR, and 
TRIVIAL PRs may omit the JIRA ID. The component tag comes from the `COMPONENTS` 
registry in `dev/merge_spark_pr.py`, the source of truth: each entry pairs a 
PR-title tag with its canonical JIRA component name and accepted aliases (e.g. 
`Documentation` → `[DOC]`, `Pandas API on Spark` → `[PS]`, `SQL` → `[SQL]`). 
Read that registry to pick the right tag.

Review Comment:
   **[20] Nit: the JIRA ID exemption is now stated twice in this file.**
   
   Now that the title rules are here, L3 ("Draft, WIP, MINOR, and TRIVIAL PRs 
may omit the JIRA ID") and L6 ("If no ticket ID is given and the PR is not 
draft, WIP, MINOR, or TRIVIAL") list the same exemptions three lines apart. A 
later change to that list has to touch both lines. L6 could say "If no ticket 
ID is given and the title needs one, ...".



##########
AGENTS.md:
##########
@@ -42,6 +30,15 @@ Before the first code edit or running test in a session, 
ensure a clean working
   read `.agents/build-and-test.md`. For setup and local troubleshooting: 
`docs/building-spark.md`.
 - Before writing a new Scala or Python test suite: read 
`.agents/test-base-classes.md` and pick
   the lowest base class that provides what the test actually needs.
+- When writing or changing a test, pin the configs its assertions depend on: 
runtime SQL configs
+  with `withSQLConf` (`self.sql_conf` in Python), static SQL and core configs 
in the suite's Spark
+  conf (`sparkConf` in Scala, `conf()` in Python). Scheduled jobs rerun the 
suites with other
+  defaults set through env vars, such as the Non-ANSI job 
(`SPARK_ANSI_SQL_MODE=false`) and the
+  UDS, JDK codegen and RocksDB UI jobs. When a result differs by ANSI mode and 
both matter, assert

Review Comment:
   **[22] The RocksDB UI job's default cannot be pinned through a config.**
   
   `spark.ui.store.path` is `createOptional`, and none of its values means 
"keep the store in memory". When it is unset, `AppStatusStore.createLiveStore` 
falls back to the `LIVE_UI_LOCAL_STORE_DIR` env var 
(`AppStatusStore.scala:874-875`), and `build_rockdb_as_ui_backend.yml` sets 
that variable. So a UI or listener test that relies on the in-memory store has 
no config to pin. An agent following this rule either finds nothing to pin or 
sets `spark.ui.store.path`, which forces the disk store. The other three jobs 
change a config default (`spark.sql.ansi.enabled`, 
`spark.python.unix.domain.socket.enabled` and `spark.sql.codegen.compiler`), so 
pinning works for them. Maybe add "for the RocksDB UI job, make the assertion 
independent of the store".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to