(Patrick Semansky/AP)

THE SENATE is set to vote Tuesday on the USA Freedom Act, the most promising National Security Agency reform proposal before Congress. Neither national security hawks nor civil libertarians get everything they want from the legislation, which means it could fail to get the 60 votes it needs to advance, or it could get pulled too far in one direction or another during an open amendment process after that. Either road to demise would be unfortunate: The bill deserves to be approved, reconciled with a House-approved version and sent to President Obama.

The headline of the Senate’s bill, sponsored by a varied group of Democrats and Republicans with Sen. Patrick Leahy (D-Vt.) in the lead, is that it would end the government’s bulk collection of so-called metadata — phone calling records, for example. In its place, the bill would give the government authority to demand calling records from phone companies in specific cases, if the collection is “narrowly” limited. Even then, the government would have to discard information lacking bona-fide intelligence value, and its metadata collection operations would be subject to more oversight.

That’s fine, but bulk metadata collection is not the most important issue the bill addresses. The act would bring change to the Foreign Intelligence Surveillance Court, which helps oversee the NSA’s activities. The court, which generally hears only the government’s side of any issue, would get balance from a panel of advocates tasked with arguing for civil liberties when the judges are considering important questions of law. The proposal also foresees appeals courts reconsidering more FISA cases, and the bill would press for major court decisions to be released.

The bill would enable a more orderly and informed debate on NSA activities as well. It would require the government to release much more information on how much it is using various authorities and, crucially, on how many people’s information it has swept up in the process. It also harmonizes the expiration of many surveillance authorities. Americans, then, would have more information to assess surveillance activities and a single date on which surveillance policy will be up for debate.

Technology companies have come out strongly in favor of the plan, as have many — though not all — civil liberties advocates. So, too, has the Obama administration. Though the intelligence community would have to change its behavior — significantly in certain programs — it would get clear legal authorities that it wants and an extended expiration timeline for some of them. It would also maintain its core, foreign-focused surveillance authorities without much change.

Therein lies the bill’s careful balance. As the Senate works on the proposal over the coming days, it should preserve that delicate and authentic compromise.